1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[943],{8465:function(e,a,l){l.d(a,{Z:function(){return j}});var i=l(5893),d=l(7294),n=l(4054),r=l(7312),s=l(7419),o=l(3599),t=l(6815),c=l(1143),u=l(5846),v=l(5601);let m=e=>{switch(e){case"provinces":return v.f.LOCATION_DATA.PROVINCES;case"regencies":return v.f.LOCATION_DATA.REGENCIES;case"districts":return v.f.LOCATION_DATA.DISTRICTS;default:return v.f.LOCATION_DATA.VILLAGES}};var h=function(e,a){let{data:l,error:i,isLoading:d}=(0,c.Z)("".concat(m(e)).concat(a),u.M4.get);return{data:(null==l?void 0:l.data)||[],isLoading:d,error:i}},p=l(5697),x=l.n(p);function g(e,a){var l;let{label:c,type:u,parentValue:v,handleChange:m,error:p,...x}=e,{data:g,isLoading:j,error:b}=h(u,v),f=(0,d.useMemo)(()=>u?g:[],[g,u]);if(j||b)return null;let _=e=>{var a;let l=(null===(a=f.find(a=>a.id===e))||void 0===a?void 0:a.name)||"";m(e,l)};return(0,i.jsxs)(n.Z,{fullWidth:!0,size:"small",error:!!p,children:[(0,i.jsx)(r.Z,{id:"".concat(u,"-label"),children:c}),(0,i.jsxs)(s.Z,{labelId:u,id:u,label:c,ref:a,...x,disabled:("regencies"===u||"districts"===u||"villages"===u)&&!v,onChange:e=>_(e.target.value),children:[(0,i.jsx)(o.Z,{value:"",children:(0,i.jsx)("em",{children:"Pilih"})}),(l="name",0===f.length?[]:f.sort((e,a)=>e[l]<a[l]?-1:e[l]>a[l]?1:0)).map(e=>(0,i.jsx)(o.Z,{value:e.id,children:e.name},e.id))]}),p&&(0,i.jsx)(t.Z,{children:p})]})}g.propTypes={label:x().string,type:x().string,parentValue:x().string,handleChange:x().func,error:x().string};var j=d.forwardRef(g)},1943:function(e,a,l){l.d(a,{Z:function(){return I}});var i=l(5893),d=l(8325),n=l(2687),r=l(7294),s=l(6010),o=l(9964),t=l(4054),c=l(135),u=l(6815),v=l(741),m=l(8465),h=l(7536),p=l(5697),x=l.n(p);function g(e){var a,l,d,n,r;let{item:s,onSubmit:o,isSubmitLoading:p}=e,{control:x,formState:{errors:g},setValue:j,getValues:b,handleSubmit:f,watch:_}=(0,h.cI)({defaultValues:{name:(null==s?void 0:s.name)||"",phone:(null==s?void 0:s.phone)||"",address:(null==s?void 0:s.address)||"",additionalInfo:(null==s?void 0:s.additionalInfo)||"",province:(null==s?void 0:s.province)||{id:"",name:""},regency:(null==s?void 0:s.regency)||{id:"",name:""},district:(null==s?void 0:s.district)||{id:"",name:""},village:(null==s?void 0:s.village)||{id:"",name:""},postalCode:(null==s?void 0:s.postalCode)||""}}),Z=(e,a,l)=>{j("".concat(e,".id"),a),j("".concat(e,".name"),l)},N=(e,a)=>{e!==b("province")&&(Z("district","",""),Z("regency","","")),Z("province",e,a)},C=(e,a)=>{e!==b("district")&&Z("district","",""),Z("regency",e,a)},A=(e,a)=>{e!==b("village")&&Z("village","",""),Z("district",e,a)},y=(e,a)=>{Z("village",e,a)},k=()=>{};return(0,i.jsxs)("form",{className:"address__form",onSubmit:f(o,k),children:[(0,i.jsxs)(t.Z,{className:"address__form__input",error:!!g.name,children:[(0,i.jsx)(h.Qr,{name:"name",control:x,rules:{required:"Nama tidak boleh kosong"},render:e=>{let{field:a}=e;return(0,i.jsx)(c.Z,{id:"outlined-basic",label:"Nama",variant:"outlined",size:"small",fullWidth:!0,...a})}}),g.name&&(0,i.jsx)(u.Z,{children:null===(a=g.name)||void 0===a?void 0:a.message})]}),(0,i.jsxs)(t.Z,{className:"address__form__input",error:!!g.phone,children:[(0,i.jsx)(h.Qr,{name:"phone",control:x,rules:{required:"No. Handphone tidak boleh kosong"},render:e=>{let{field:a}=e;return(0,i.jsx)(c.Z,{id:"outlined-basic",label:"No. Handphone",variant:"outlined",size:"small",fullWidth:!0,...a})}}),g.phone&&(0,i.jsx)(u.Z,{children:null===(l=g.phone)||void 0===l?void 0:l.message})]}),(0,i.jsxs)(t.Z,{className:"address__form__input",error:!!g.address,children:[(0,i.jsx)(h.Qr,{name:"address",control:x,rules:{required:"Alamat tidak boleh kosong"},render:e=>{let{field:a}=e;return(0,i.jsx)(c.Z,{id:"outlined-basic",label:"Alamat Lengkap",variant:"outlined",size:"small",fullWidth:!0,...a})}}),g.address&&(0,i.jsx)(u.Z,{children:null===(d=g.address)||void 0===d?void 0:d.message})]}),(0,i.jsxs)(t.Z,{className:"address__form__input",error:!!g.postalCode,children:[(0,i.jsx)(h.Qr,{name:"postalCode",control:x,rules:{required:"Kodepos tidak boleh kosong"},render:e=>{let{field:a}=e;return(0,i.jsx)(c.Z,{id:"outlined-basic",label:"Kodepos",variant:"outlined",size:"small",fullWidth:!0,...a})}}),g.postalCode&&(0,i.jsx)(u.Z,{children:null===(n=g.postalCode)||void 0===n?void 0:n.message})]}),(0,i.jsxs)(t.Z,{className:"address__form__input",children:[(0,i.jsx)(h.Qr,{name:"additionalInfo",control:x,render:e=>{let{field:a}=e;return(0,i.jsx)(c.Z,{id:"outlined-basic",label:"Apartment, address number, suites, etc",variant:"outlined",size:"small",fullWidth:!0,...a})}}),g.additionalInfo&&(0,i.jsx)(u.Z,{children:null===(r=g.additionalInfo)||void 0===r?void 0:r.message})]}),(0,i.jsxs)("div",{className:"address__form__input address__form__location",children:[(0,i.jsx)(h.Qr,{name:"province.id",control:x,rules:{required:"Provinsi tidak boleh kosong"},render:e=>{var a,l;let{field:d}=e;return(0,i.jsx)(m.Z,{label:"Provinsi",type:"provinces",parentValue:"100",handleChange:N,error:null===(a=g.province)||void 0===a?void 0:null===(l=a.id)||void 0===l?void 0:l.message,...d})}}),(0,i.jsx)(h.Qr,{name:"regency.id",control:x,rules:{required:"Kota / Kabupaten tidak boleh kosong"},render:e=>{var a,l;let{field:d}=e;return(0,i.jsx)(m.Z,{label:"Kota / Kabupaten",type:"regencies",parentValue:_("province.id"),handleChange:C,error:null===(a=g.regency)||void 0===a?void 0:null===(l=a.id)||void 0===l?void 0:l.message,...d})}}),(0,i.jsx)(h.Qr,{name:"district.id",control:x,rules:{required:"Kecamatan tidak boleh kosong"},render:e=>{var a,l;let{field:d}=e;return(0,i.jsx)(m.Z,{label:"Kecamatan",type:"districts",parentValue:_("regency.id"),handleChange:A,error:null===(a=g.district)||void 0===a?void 0:null===(l=a.id)||void 0===l?void 0:l.message,...d})}}),(0,i.jsx)(h.Qr,{name:"village.id",control:x,rules:{required:"Kelurahan tidak boleh kosong"},render:e=>{var a,l;let{field:d}=e;return(0,i.jsx)(m.Z,{label:"Kelurahan",type:"villages",parentValue:_("district.id"),handleChange:y,error:null===(a=g.village)||void 0===a?void 0:null===(l=a.id)||void 0===l?void 0:l.message,...d})}})]}),(0,i.jsx)(v.Z,{type:"submit",color:"primary",loading:p,children:"Submit"})]})}g.propTypes={item:x().object,onSubmit:x().func,isSubmitLoading:x().bool};var j=l(5601),b=l(5678),f=l(1889),_=l(7554),Z=l(5846),N=l(7288);let C=(0,r.createContext)({savedAddresses:[]}),A=()=>(0,r.useContext)(C),y=e=>{let{user:a,setUser:l}=(0,N.aC)(),[d,n]=(0,r.useState)([]),[s,o]=(0,_.Z)(Z.S2.get),[t,c]=(0,_.Z)(Z.dF.post),[u,v]=(0,_.Z)(Z.dF.put),m=(0,r.useCallback)(async()=>{try{var e;let a=await s(j.f.ADDRESS.GET);n(null==a?void 0:null===(e=a.data)||void 0===e?void 0:e.data)}catch(e){n([])}},[s]),h=async e=>{try{var i,r,s,o,c,u,v,m,h,p,x,g,_,Z,C,A,y;let f=await t(j.f.ADDRESS.CREATE,{...e,phone:(0,N.mX)(e.phone)});n(d.concat(null==f?void 0:null===(i=f.data)||void 0===i?void 0:i.data));let k=null==f?void 0:null===(r=f.data)||void 0===r?void 0:null===(s=r.data)||void 0===s?void 0:s.isPhoneChanged,S=null==f?void 0:null===(o=f.data)||void 0===o?void 0:null===(c=o.data)||void 0===c?void 0:c.isNameChanged;return k&&S?l({...a,handphone:null==f?void 0:null===(u=f.data)||void 0===u?void 0:null===(v=u.data)||void 0===v?void 0:v.phone,firstName:null==f?void 0:null===(m=f.data)||void 0===m?void 0:null===(h=m.data)||void 0===h?void 0:h.firstName,lastName:null==f?void 0:null===(p=f.data)||void 0===p?void 0:null===(x=p.data)||void 0===x?void 0:x.lastName}):k?l({...a,handphone:null==f?void 0:null===(g=f.data)||void 0===g?void 0:null===(_=g.data)||void 0===_?void 0:_.phone}):S&&l({...a,firstName:null==f?void 0:null===(Z=f.data)||void 0===Z?void 0:null===(C=Z.data)||void 0===C?void 0:C.firstName,lastName:null==f?void 0:null===(A=f.data)||void 0===A?void 0:null===(y=A.data)||void 0===y?void 0:y.lastName}),b.Am.success("Alamat berhasil ditambahkan."),d}catch(e){b.Am.error((0,f.E)(e,"Failed to add new address. Please try again."))}},p=async(e,a)=>{try{return await u(j.f.ADDRESS.EDIT,{ggAddressId:e,addressDetail
1s:{...a,phone:(0,N.mX)(a.phone)}}),n(d.map(l=>l.id===e?{...l,...a}:l)),b.Am.success("Alamat berhasil diubah."),d}catch(e){b.Am.error((0,f.E)(e,"Failed to add edit address. Please try again."))}};return(0,i.jsx)(C.Provider,{value:{savedAddresses:d,getSavedAddresses:m,isGetSavedAddressesLoading:o,addNewAddress:h,isAddNewAddressLoading:c,editAddress:p,isEditAddressLoading:v},children:e.children})};y.propTypes={children:x().node};var k=function(){let[e,a]=(0,r.useState)(!1),{addNewAddress:l,isAddNewAddressLoading:s}=A(),t=async e=>{let i=await l(e);i&&a(!1)};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{className:"box box--400 box--white address__box box--center box--column",onClick:()=>a(!0),children:[(0,i.jsx)(d.Z,{name:"plus",size:"l"}),(0,i.jsx)(n.Z,{color:"light-gray",size:"s",children:"Tambah Alamat"})]}),(0,i.jsx)(o.Z,{open:e,onClose:()=>a(!1),children:(0,i.jsxs)("div",{className:"modal modal--column-center modal--l",children:[(0,i.jsx)(d.Z,{name:"location",size:"m"}),(0,i.jsx)(n.Z,{weight:"bold",children:"Tambah Alamat Pengiriman"}),(0,i.jsx)(g,{onSubmit:t,isSubmitLoading:s})]})})]})};function S(e){let{item:a}=e,[l,s]=(0,r.useState)(!1),{editAddress:t,isEditAddressLoading:c}=A(),u=async e=>{let l=await t(a.id,e);l&&s(!1)};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(d.Z,{className:"address_actions",name:"edit",label:"Edit",onClick:e=>{e.stopPropagation(),s(!0)}}),(0,i.jsx)(o.Z,{open:l,onClose:()=>s(!1),onClick:e=>e.stopPropagation(),children:(0,i.jsxs)("div",{className:"modal modal--column-center modal--l",children:[(0,i.jsx)(d.Z,{name:"location",size:"m"}),(0,i.jsx)(n.Z,{weight:"bold",children:"Edit Alamat Pengiriman"}),(0,i.jsx)(g,{item:a,onSubmit:u,isSubmitLoading:c})]})})]})}S.propTypes={item:x().object};var E=l(8456);function T(e){let{title:a,selectedAddress:l,onAddressSelected:o}=e,{savedAddresses:t,getSavedAddresses:c,isGetSavedAddressesLoading:u}=A(),{user:v,setUser:m}=(0,N.aC)(),h=e=>(0,s.Z)("box box--250 box--white box--column address__box",{"address__box--active":l===e});(0,r.useEffect)(()=>{c()},[c]),(0,r.useEffect)(()=>{v&&!l&&o&&o(null==v?void 0:v.defaultAddress,!0)},[v,l]),(0,r.useEffect)(()=>{if(1===t.length&&!l){var e;m({...v,defaultAddress:null===(e=t[0])||void 0===e?void 0:e.id})}},[t,l,m,v]);let p=e=>{l!==e&&o&&o(e)},x=()=>t.map(e=>{var a;return(0,i.jsxs)("div",{className:h(e.id),onClick:()=>p(e.id),children:[(0,i.jsx)(d.Z,{className:"address__check",name:"check",color:"primary",size:"l"}),(0,i.jsx)(S,{item:e}),(0,i.jsx)(n.Z,{weight:"bold",children:e.name}),(0,i.jsxs)(n.Z,{size:"s",color:"light-gray",className:"address__description",children:[e.address,", ",null===(a=e.village)||void 0===a?void 0:a.name,", ",e.district.name,", ",e.regency.name,", ",e.postalCode]}),(0,i.jsx)(n.Z,{size:"s",color:"light-gray",children:e.phone})]},e.id)});return(0,i.jsxs)(i.Fragment,{children:[a&&(0,i.jsx)("div",{className:"box__title",children:a}),u?(0,i.jsx)(E.Z,{}):(0,i.jsxs)("div",{className:"box-list--row",children:[(0,i.jsx)(x,{}),(0,i.jsx)(k,{})]})]})}T.propTypes={title:x().string,selectedAddress:x().string,onAddressSelected:x().func};var I=function(e){return(0,i.jsx)(y,{children:(0,i.jsx)(T,{...e})})}}}]);
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.