1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[420],{97087:function(e,t,n){"use strict";var r,i=n(67294);function s(){return s=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},s.apply(null,arguments)}t.Z=function(e){return i.createElement("svg",s({xmlns:"http://www.w3.org/2000/svg",width:8.323,height:8.323},e),r||(r=i.createElement("path",{d:"M1.334 4.97L3.322 7.05l3.629-3.8",fill:"none",stroke:"#fff",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8})))}},81226:function(e,t,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/CustomerAddressesEdit",function(){return n(2028)}])},68819:function(e,t,n){"use strict";n.d(t,{k:function(){return f}});var r=n(26042),i=n(99534),s=n(85893),a=n(93967),o=n.n(a),c=n(57398),d=n.n(c),u=n(97087),l=function(e){return(0,s.jsxs)("div",{className:d().checkbox,children:[(0,s.jsx)("input",{checked:e.checked,onChange:function(t){return e.onChange(t.target.checked)},type:"checkbox"}),(0,s.jsx)("span",{className:d().checkbox__checkmark,children:(0,s.jsx)(u.Z,{})})]})},h=n(68897),p=n.n(h),f=function(e){var t=e.label,n=e.className,a=(0,i.Z)(e,["label","className"]);return(0,s.jsx)("div",{className:o()(p()["checkbox-label"],n),children:(0,s.jsxs)("label",{className:p()["checkbox-label__label"],children:[(0,s.jsx)(l,(0,r.Z)({},a)),(0,s.jsx)("span",{children:t})]})})}},18431:function(e,t,n){"use strict";n.d(t,{Z:function(){return h}});var r=n(14924),i=n(26042),s=n(69396),a=n(99534),o=n(85893),c=n(93967),d=n.n(c),u=(n(67294),n(56494)),l=n.n(u),h=function(e){var t,n=e.title,c=e.link,u=e.underlined,h=(0,a.Z)(e,["title","link","underlined"]);return(0,o.jsx)("a",(0,s.Z)((0,i.Z)({href:c,target:"_blank",className:d()(l()["right-content-text"],(t={},(0,r.Z)(t,l()["right-content-text--link"],!!c),(0,r.Z)(t,l()["right-content-text--underlined"],!!u),t))},h),{children:n}))}},2028:function(e,t,n){"use strict";n.r(t),n.d(t,{__N_SSP:function(){return I},default:function(){return T}});var r=n(26042),i=n(69396),s=n(85893),a=n(40925),o=n(81001),c=n(36858),d=n(47568),u=n(40872),l=n(34051),h=n.n(l),p=n(30803),f=n(88862),m=n(44458),_=n(93967),v=n.n(_),b=n(11163),x=n(67294),g=n(57653),k=n(30251),C=n(2053),Z=n(42681),w=n(40771),j=n(96440),N=n(73402),E=n(63401),y=n(68819),P=n(94862),A=n(18431),S=n(3662),q=n(59493),z=n.n(q);function L(e){var t,n,o=(0,u.Z)({},e),c=(0,b.useRouter)(),l=(0,g.d)().confirm,_=null!==(n=(0,m.useSiteContext)().site.configs.checkout.enableDeliveryRecipient)&&void 0!==n&&n,q=(0,C.t)().formActions,L=(0,k.n)().alertActions,O=(0,f.y)(),R=O.mutateAsync,$=O.isLoading,I=(0,a.useGetCustomer)(),T=I.data,D=I.isLoading,F=(0,p.A)(),V=F.mutateAsync,B=F.isLoading,J=(0,x.useState)(!0),M=J[0],U=J[1],G=(0,x.useState)(!1),X=G[0],Q=G[1],W=(0,x.useState)(!1),Y=W[0],H=W[1],K=(0,x.useState)({id:void 0,zipCode:"",street:"",number:"",complement:"",district:"",city:"",state:"",label:"",recipientName:"",recipientPhone:""}),ee=K[0],te=K[1],ne=(0,x.useState)({id:void 0,zipCode:"",street:"",number:"",complement:"",district:"",city:"",state:"",label:"",recipientName:"",recipientPhone:""}),re=ne[0],ie=ne[1],se=(0,x.useCallback)((function(){l(N.c,{title:"Cancelar edi\xe7\xe3o de dados",message:"Voc\xea tem certeza que deseja cancelar suas altera\xe7\xf5es?",onConfirm:function(){return c.push("/customer/addresses")},buttonMessage:{confirm:"Sim",cancel:"N\xe3o"}})}),[]),ae=function(){var e=(0,d.Z)(h().mark((function e(){var t,n;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!q.validate([{id:"zipCode",value:ee.zipCode,validate:function(e){if(!e)throw new Error("CEP obrigat\xf3rio");if(!(0,Z.V)("cep").validate(e))throw new Error("CEP inv\xe1lido")}},{id:"street",value:ee.street,validate:function(e){if(!e)throw new Error("Cidade obrigat\xf3ria")}},{id:"number",value:ee.number,validate:function(e){if(!e&&!Y)throw new Error("N\xfamero obrigat\xf3ria")}},{id:"district",value:ee.district,validate:function(e){if(!e)throw new Error("Bairro obrigat\xf3rio")}},{id:"city",value:ee.city,validate:function(e){if(!e)throw new Error("Cidade obrigat\xf3ria")}},{id:"state",value:ee.state,validate:function(e){if(!e)throw new Error("Estado obrigat\xf3rio");if(2!==e.length)throw new Error("Informe uma sigla v\xe1lida (ex: RS, SP)")}},{id:"label",value:ee.label,validate:function(e){if(!e)throw new Error("Identifica\xe7\xe3o obrigat\xf3ria")}},{id:"recipientName",value:ee.recipientName||"",validate:function(e){if(_&&!e)throw new Error("Nome do destinat\xe1rio obrigat\xf3rio")}},{id:"recipientPhone",value:ee.recipientPhone||"",validate:function(e){if(_&&e.length<10)throw new Error("Telefone do destinat\xe1rio obrigat\xf3rio")}}])){e.next=13;break}return n=(null===T||void 0===T?void 0:T.addresses)||[],(n=(null===(t=o.address)||void 0===t?void 0:t.id)?n.filter((function(e){return Boolean(e.id)}
1)).filter((function(e){var t;return e.id!==(null===(t=o.address)||void 0===t?void 0:t.id)})):n).push(ee),n=Array.from(new Set(n)),e.prev=6,e.next=9,V(n,{onSuccess:function(){var e,t=(null===(e=o.address)||void 0===e?void 0:e.id)?"Endere\xe7o atualizado com sucesso.":"Novo endere\xe7o cadastrado com sucesso.";L.createOrUpdateOne(t,"success"),c.push("/customer/addresses")},onError:function(e){e.response.data.details.filter((function(e){return e.id.includes("state")})).length?q.setFieldError({id:"state",errorMessage:"Informe uma sigla v\xe1lida (ex: RS, SP)"}):L.createOrUpdateOne("Ops! Infelizmente, algo deu errado. Tente novamente mais tarde.","error")}});case 9:e.next=13;break;case 11:e.prev=11,e.t0=e.catch(6);case 13:case"end":return e.stop()}}),e,null,[[6,11]])})));return function(){return e.apply(this,arguments)}}();(0,x.useEffect)((function(){if(o.address){var e=o.address,t=e.id,n=e.zipCode,r=e.street,i=e.number,s=e.complement,a=e.district,c=e.city,d=e.state,u=e.label,l=e.recipientName,h=e.recipientPhone,p={id:t,zipCode:n,street:r,number:i,complement:s,district:a,city:c,state:d,label:u,recipientName:null!==l&&void 0!==l?l:"",recipientPhone:null!==h&&void 0!==h?h:""};te(p),ie(p),Q(!1),U(!1)}}),[o.address]);var oe=function(){var e=(0,d.Z)(h().mark((function e(t){var n;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!q.validate([{id:"zipCode",value:t,validate:function(e){if(!(0,Z.V)("cep").validate(e))throw new Error("CEP inv\xe1lido")}}])){e.next=15;break}return e.prev=1,e.next=4,R(t);case 4:n=e.sent,te((function(e){return(0,i.Z)((0,r.Z)({},e),{street:n.street,district:n.district,city:n.city,state:n.state,number:"",complement:""})})),Q(!0),e.next=12;break;case 9:e.prev=9,e.t0=e.catch(1),te((function(e){return(0,i.Z)((0,r.Z)({},e),{street:"",number:"",complement:"",district:"",city:"",state:""})}));case 12:return e.prev=12,U(!1),e.finish(12);case 15:case"end":return e.stop()}}),e,null,[[1,9,12,15]])})));return function(t){return e.apply(this,arguments)}}(),ce=(0,x.useCallback)((function(){!o.address&&Object.keys(ee).filter((function(e){var t;return!!(null===(t=ee[e])||void 0===t?void 0:t.length)})).length||o.address&&Object.keys(ee).some((function(e){return o.address[e]!==ee[e]}))?se():c.push("/customer/addresses")}),[o.address,ee,c]);return(0,s.jsxs)("div",{className:z()["customer-addresses-inputs"],children:[(0,s.jsx)(E.k,{title:(null===(t=o.address)||void 0===t?void 0:t.id)?"Editar endere\xe7o":"Adicionar endere\xe7o"}),(0,s.jsx)(S.v,{bordered:!0,isLoading:B||D,buttons:(0,s.jsxs)(x.Fragment,{children:[(0,s.jsx)(j.Y,{onClick:ce,children:"Cancelar"}),(0,s.jsx)(w.J,{onClick:ae,children:"Salvar"})]}),children:(0,s.jsxs)("div",{className:z()["customer-addresses-inputs__container"],children:[(0,s.jsx)(P.q,{id:"zipCode",mask:"99999-999",type:"tel",placeholder:"CEP",isLoading:$,value:ee.zipCode,onChange:function(e){return function(e){te((function(t){return(0,i.Z)((0,r.Z)({},t),{zipCode:e})})),8===e.length&&(oe(e),Q(!1),U(!0))}(e)},rightContent:(0,s.jsx)(A.Z,{title:"N\xe3o sei meu CEP",link:"https://buscacepinter.correios.com.br/",underlined:!0})}),!M&&(0,s.jsxs)(x.Fragment,{children:[(0,s.jsx)(P.q,{id:"street",value:ee.street,onChange:function(e){return te((function(t){return(0,i.Z)((0,r.Z)({},t),{street:e})}))},placeholder:"Endere\xe7o (Avenida, rua, estrada, etc)"}),(0,s.jsxs)("div",{className:z()["customer-addresses-inputs__divided"],children:[(0,s.jsx)(P.q,{id:"number",value:ee.number,onChange:function(e){return te((function(t){return(0,i.Z)((0,r.Z)({},t),{number:e})}))},placeholder:"N\xfamero",disabled:Y}),(0,s.jsx)("div",{className:z()["customer-addresses-inputs__checkbox"],children:(0,s.jsx)(y.k,{checked:Y,onChange:function(e){H(e),te((function(t){return(0,i.Z)((0,r.Z)({},t),{number:e?"S/N":""})}))},label:"N\xe3o possui n\xfamero"})})]}),(0,s.jsx)(P.q,{id:"complement",value:ee.complement||"",onChange:function(e){return te((function(t){return(0,i.Z)((0,r.Z)({},t),{complement:e})}))},placeholder:"Complemento"}),(0,s.jsx)(P.q,{id:"district",value:ee.district,onChange:function(e){return te((function(t){return(0,i.Z)((0,r.Z)({},t),{district:e})}))},placeholder:"Bairro"}),(0,s.jsxs)("div",{className:v()(z()["customer-addresses-inputs__divided"],z()["customer-addresses-inputs__divided-mobile"]),children:[(0,s.jsx)(P.q,{id:"city",value:ee.city,onChange:function(e){return te((function(t){return(0,i.Z)((0,r.Z)({},t),{city:e})}))},placeholder:"Cidade",disabled:X}),(0,s.jsx)(P.q,{id:"state",value:ee.state,onChange:function(e){var t=e.replace(/[^A-Za-z]/g,"").toUpperCase().slice(0,2);te((function(e){return(0,i.Z)((0,r.Z)({},e),{state:t})}))}
1,placeholder:"Estado (UF)",disabled:X,maxLength:2,showValid:2===ee.state.length&&ee.state!==re.state})]}),(0,s.jsx)(P.q,{id:"label",value:ee.label,onChange:function(e){return te((function(t){return(0,i.Z)((0,r.Z)({},t),{label:e})}))},placeholder:"Identifica\xe7\xe3o do endere\xe7o (Casa, trabalho, apto)"}),_&&(0,s.jsxs)(x.Fragment,{children:[(0,s.jsx)(P.q,{id:"recipientName",value:ee.recipientName||"",onChange:function(e){return te((function(t){return(0,i.Z)((0,r.Z)({},t),{recipientName:e})}))},placeholder:"Nome do destinat\xe1rio"}),(0,s.jsx)(P.q,{id:"recipientPhone",value:ee.recipientPhone||"",onChange:function(e){return te((function(t){return(0,i.Z)((0,r.Z)({},t),{recipientPhone:e})}))},placeholder:"Telefone do destinat\xe1rio",mask:"(99) 99999-9999",type:"tel"})]})]})]})})]})}var O=n(31799),R=n(3840),$=n.n(R),I=!0,T=function(e){var t=(0,b.useRouter)(),n=(0,a.useGetCustomer)().data,d=t.query.id,u=(0,x.useMemo)((function(){return null===n||void 0===n?void 0:n.addresses.find((function(e){return e.id===d}))}),[null===n||void 0===n?void 0:n.addresses]);return(0,s.jsxs)(o.ZP,(0,i.Z)((0,r.Z)({},e),{children:[(0,s.jsx)(O.Z,{title:"Endere\xe7o"}),(0,s.jsx)(c.R,{comeback:{message:"Voltar para lista de endere\xe7os",callback:function(){return t.back()}},children:(0,s.jsx)("div",{className:$()["customer-addresses"],children:(0,s.jsx)(L,{address:u})})})]}))}},42681:function(e,t,n){"use strict";n.d(t,{V:function(){return r}});var r=function(e){switch(e){case"cep":return{transform:function(e){return e.replace(/\D+/g,"").replace(/^(\d{5})(\d{1,3})/,"$1-$2")},validate:function(e){return!!e.match(/^\d{5}-?\d{3}$/g)}};case"cpf":return{transform:function(e){return e.replace(/\D+/g,"").replace(/^(\d{3})(\d{1,3})(\d{0,3})(\d{0,2})/,(function(e,t,n,r,i){return t+"."+n+(r&&"."+r||"")+(i&&"-"+i||"")}))},validate:function(e){return!!e.match(/^\d{3}\.?\d{3}\.?\d{3}-?\d{2}$/g)}};case"cnpj":return{transform:function(e){return e.replace(/\D+/g,"").replace(/^(\d{2})(\d{1,3})(\d{0,3})(\d{0,4})(\d{0,2})/,(function(e,t,n,r,i,s){return t+"."+n+(r&&"."+r||"")+(i&&"/"+i||"")+(s&&"-"+s||"")}))},validate:function(e){return!!e.match(/^\d{2}.?\d{3}.?\d{3}\/?\d{4}-?\d{2}$/g)}};case"phone":return{transform:function(e){return 11===e.length?e.replace(/^(\d\d)(\d{5})(\d{4}).*/,"($1) $2-$3"):e.replace(/^(\d\d)(\d{4})(\d{4}).*/,"($1) $2-$3")},validate:function(e){return!!e.match(/^(\d{2}|\(\d{2}\))\s*(\d{9}|(\d{4}|\d{5})-?\d{4})$/g)}};case"email":return{validate:function(e){return!!e.match(/^([^.\s](\.[^.\s]+)*)+@[^.\s]+\.\S+$/g)}}}}},57398:function(e){e.exports={checkbox:"Checkbox_checkbox__xRftJ",checkbox__checkmark:"Checkbox_checkbox__checkmark__ztl1c",pulse:"Checkbox_pulse__LKg_J","image-pulse":"Checkbox_image-pulse__GkvTn",shine:"Checkbox_shine__5Yutl"}},68897:function(e){e.exports={"checkbox-label":"CheckboxLabel_checkbox-label__ywE28","checkbox-label__label":"CheckboxLabel_checkbox-label__label__JhD3P",pulse:"CheckboxLabel_pulse__Lgv4W","image-pulse":"CheckboxLabel_image-pulse__sBez2",shine:"CheckboxLabel_shine__HXAM0"}},56494:function(e){e.exports={"right-content-text":"RightContentText_right-content-text__QAZRw","right-content-text--link":"RightContentText_right-content-text--link__tqwor","right-content-text--underlined":"RightContentText_right-content-text--underlined__CW8S3",pulse:"RightContentText_pulse__BcbJm","image-pulse":"RightContentText_image-pulse__PCbQl",shine:"RightContentText_shine__qOxOr"}},59493:function(e){e.exports={"customer-addresses-inputs__container":"CustomerAddressesInputs_customer-addresses-inputs__container__7OtDX","customer-addresses-inputs__divided":"CustomerAddressesInputs_customer-addresses-inputs__divided__4OFQh","customer-addresses-inputs__checkbox":"CustomerAddressesInputs_customer-addresses-inputs__checkbox__LDCS_","customer-addresses-inputs__divided-mobile":"CustomerAddressesInputs_customer-addresses-inputs__divided-mobile__2lqch",pulse:"CustomerAddressesInputs_pulse__pzaAq","image-pulse":"CustomerAddressesInputs_image-pulse__bGZ9R",shine:"CustomerAddressesInputs_shine__U_qgk"}},3840:function(){}},function(e){e.O(0,[714,800,178,960,766,243,242,774,888,179],(function(){return t=81226,e(e.s=t);var t}));var t=e.O();_N_E=t}]);
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.