PageSourceSearch

https://molbubi.hu/assets/BillingAddressesPage-C_GYymal.js

js molbubi.hu collected 2026-10-01 11:56:59 UTC 7,309 bytes, 1 lines download raw bytes

1import{j as e,o as J,p as V,q as X,s as Z,i as k,k as F,P as ee,B as A,S,ah as U,aq as se,ar as ie,as as T,x as E,at as ne,al as te,au as le,T as h,av as ae,aw as re,A as oe}from"./vendor-mui-CO7ndWfg.js";import{a as p}from"./vendor-react-xiLgNGE9.js";import{u as v,aA as B,aO as de,b as ce,g as I,aP as ue,P as ge}from"./main-Bc0VL40j.js";import{u as _,a as pe,B as me,c as be,f as fe,g as xe,b as ye}from"./useBillingAddressForm-SsqH56Ta.js";import{u as L}from"./ConfirmDialog-C52AI7yL.js";import"./vendor-mapbox-D8F1hoiy.js";const Be=({systemId:s,defaultCountryCode:d,streetAddress:c,address:t,kind:i,onClose:n,onSaved:u})=>{const{t:a}=v(),{confirm:m,ConfirmDialog:r}=L(),o=!!t,l=pe({systemId:s,kind:i,streetAddress:c,defaultCountryCode:d,initialAddress:t,onSave:async(b,w)=>{const x=be(i,b.address,i==="business"?b.legalEntityNumber:void 0,b.fullName||void 0,(t==null?void 0:t.isDefault)??!1,w);t?await B.onboardingControllerUpdateBillingAddress(s,String(t.id),x):await B.onboardingControllerCreateBillingAddress(s,x),u()}}),C=i==="business"?o?"BudapestOnboarding.BillingAddresses.editBusinessTitle":"BudapestOnboarding.BillingAddresses.addBusinessTitle":o?"BudapestOnboarding.BillingAddresses.editPersonalTitle":"BudapestOnboarding.BillingAddresses.addPersonalTitle",j=i==="business"?o?"Edit business billing address":"Add business billing address":o?"Edit personal billing address":"Add personal billing address",D=async()=>{o&&!await m({title:a("BudapestOnboarding.BillingAddresses.updateConfirmTitle","Update billing address?"),message:a("BudapestOnboarding.BillingAddresses.updateConfirm","Are you sure you want to update this billing address?")})||l.save()};return e.jsxs(e.Fragment,{children:[e.jsx(V,{children:a(C,j)}),e.jsx(X,{dividers:!0,children:e.jsx(me,{form:l,streetAddress:c,autoFocus:!0})}),e.jsxs(Z,{children:[e.jsx(k,{onClick:n,disabled:l.saving,children:a("cancel","Cancel")}),e.jsx(k,{variant:"contained",onClick:()=>void D(),disabled:l.saving||l.isSaveDisabled,children:l.saving?e.jsx(F,{size:24}):a("components.buttons-i18n.save","Save")})]}),r]})},Ae=({open:s,onClose:d,systemId:c,defaultCountryCode:t,streetAddress:i,address:n,addressTypeForNew:u,onSaved:a})=>{const m=n?_(n):u;return e.jsx(J,{open:s,onClose:d,fullWidth:!0,maxWidth:"sm",children:s&&m&&e.jsx(Be,{systemId:c,defaultCountryCode:t,streetAddress:i,address:n,kind:m,onClose:d,onSaved:a},`${(n==null?void 0:n.id)??"new"}-${m}`)})},he=({address:s,onEdit:d,onDelete:c,onSetDefault:t,isDeleting:i,isSettingDefault:n})=>{const{t:u}=v(),a=s.type===de.type.BUSINESS;return e.jsxs(ee,{variant:"outlined",sx:{p:2,borderColor:s.isDefault?"primary.main":"divider"},children:[e.jsxs(A,{sx:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:1},children:[e.jsxs(S,{direction:"row",spacing:1,sx:{flexWrap:"wrap",gap:.5},children:[s.isDefault&&e.jsx(U,{size:"small",color:"primary",label:u("BudapestOnboarding.BillingAddresses.defaultBadge","Default")}),e.jsx(U,{size:"small",variant:"outlined",icon:a?e.jsx(se,{}):e.jsx(ie,{}),label:a?u("BudapestOnboarding.BillingAddresses.businessBadge","Business"):u("BudapestOnboarding.BillingAddresses.personalBadge","Personal")})]}),e.jsxs(S,{direction:"row",spacing:.5,children:[!s.isDefault&&e.jsx(T,{title:u("BudapestOnboarding.BillingAddresses.setAsDefault","Set as default"),children:e.jsx("span",{children:e.jsx(E,{size:"small",onClick:t,disabled:n,children:n?e.jsx(F,{size:18}):e.jsx(ne,{fontSize:"small"})})})}),e.jsx(T,{title:u("common.edit","Edit"),children:e.jsx(E,{size:"small",onClick:d,children:e.jsx(te,{fontSize:"small"})})}),e.jsx(T,{title:u("common.delete","Delete"),children:e.jsx("span",{children:e.jsx(E,{size:"small",color:"error",onClick:c,disabled:i,children:i?e.jsx(F,{size:18}):e.jsx(le,{fontSize:"small"})})})})]})]}),e.jsxs(A,{sx:{mt:1},children:[s.name&&e.jsx(h,{variant:"subtitle2",children:s.name}),e.jsx(h,{variant:"body2",color:"text.secondary",sx:{whiteSpace:"pre-line"},children:fe(s)})]})]})},K=[{type:"personal",titleKey:"BudapestOnboarding.BillingAddresses.personalSectionTitle",titleFallback:"Personal billing addresses",emptyKey:"BudapestOnboarding.BillingAddresses.personalSectionEmpty",emptyFallback:"No personal billing addresses yet."},{type:"business",titleKey:"BudapestOnboarding.BillingAddresses.businessSectionTitle",titleFallback:"Business billing addresses",emptyKey:"BudapestOnboarding.BillingAddresses.businessSectionEmpty",emptyFallback:"No business billing addresses yet."}],je=s=>[...s].sort((d,c)=>d.isDefault&&!c.isDefault?-1:!d.isDefault&&c.isDefault?1:c.id-d.id),Se=({addresses:s,onAddAddress:d,onEditAddress:c,onDelete:t,onSetDefault:i,deletingId:n,settingDefaultId:u})=>{const{t:a}=v(),m=p.useMemo(()=>K.reduce((r,o)=>(r[o.type]=je(s.filter(f=>_(f)===o.type)),r),{personal:[],business:[]}),[s]);return e.jsx(S,{spacing:3,children:K.map((r,o)=>{const f=m[r.type];return e.jsxs(A,{children:[o>0&&e.jsx(ae,{sx:{mb:3}}),e.jsxs(A,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:1.5},children:[e.jsx(h,{variant:"subtitle2",color:"text.secondary",children:a(r.titleKey,r.titleFallback)}),e.jsx(k,{size:"small",startIcon:e.jsx(re,{}),onClick:()=>d(r.type),children:a("BudapestOnboarding.BillingAddresses.addNew","Add new")})]}),f.length===0?e.jsx(h,{variant:"body2",color:"text.secondary",children:a(r.emptyKey,r.emptyFallback)}):e.jsx(S,{spacing:2,children:f.map(l=>e.jsx(he,{address:l,onEdit:()=>c(l),onDelete:()=>t(l),onSetDefault:()=>i(l),isDeleting:n===l.id,isSettingDefault:u===l.id},l.id))})]},r.type)})})};function Ee(){var z;const{t:s}=v(),{confirm:d,ConfirmDialog:c}=L(),{data:t}=ce(),i=((z=t==null?void 0:t.system)==null?void 0:z.id)??null,[n,u]=p.useState(null),[a,m]=p.useState(!0),[r,o]=p.useState(""),[f,l]=p.useState(null),[C,j]=p.useState(null),[D,b]=p.useState(!1),[w,x]=p.useState(void 0),[M,P]=p.useState(void 0),y=p.useCallback(async()=>
1{if(i)try{const g=await B.onboardingControllerGetUserOnboarding(i);u(g.data),o("")}catch(g){o(I(g,s("error_generic","Something went wrong.")))}finally{m(!1)}},[i,s]);p.useEffect(()=>{i&&(m(!0),y())},[i,y]);const R=(n==null?void 0:n.billingAddresses)??[],O=(n==null?void 0:n.countryCode)??ue,W=p.useMemo(()=>xe(n,O),[n,O]),q=g=>{x(void 0),P(g),b(!0)},G=g=>{P(void 0),x(g),b(!0)},$=()=>{b(!1),y()},Q=async g=>{if(!(!i||!await d({message:s("BudapestOnboarding.BillingAddresses.deleteConfirm","This address will be permanently removed from your account.")}))){l(g.id);try{await B.onboardingControllerRemoveBillingAddress(i,String(g.id)),await y()}catch(H){o(I(H,s("error_generic","Something went wrong.")))}finally{l(null)}}},Y=async g=>{if(i){j(g.id);try{await B.onboardingControllerUpdateBillingAddress(i,String(g.id),ye(g)),await y()}catch(N){o(I(N,s("error_generic","Something went wrong.")))}finally{j(null)}}};return a?e.jsx(ge,{variant:"form"}):e.jsxs(A,{children:[e.jsx(h,{variant:"h5",mb:3,textAlign:"center",children:s("BudapestOnboarding.BillingAddresses.sectionTitle","Billing addresses")}),r&&e.jsx(oe,{severity:"error",sx:{mb:2},children:r}),e.jsx(Se,{addresses:R,onAddAddress:q,onEditAddress:G,onDelete:Q,onSetDefault:Y,deletingId:f,settingDefaultId:C}),i&&e.jsx(Ae,{open:D,onClose:()=>b(!1),systemId:i,defaultCountryCode:O,streetAddress:W,address:w,addressTypeForNew:M,onSaved:$}),c]})}export{Ee as BillingAddressesPage};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.