1import{t as C,a8 as g,bc as x,ag as u,b7 as m,bd as A,be as j,B as v,J as E,r as d,j as i,n,h as l}from"./index-CHRcH5og.js";import{P as q}from"./PageHeaderMeta.DmGxthvs.js";import{A as N}from"./AddressForm.BGKnbXoR.js";import{P}from"./index.Bx0Gc69S.js";import{v as S,g as B}from"./helper.CAOjaNAH.js";import"./utils.Ba_cVios.js";import"./memoize-one.esm.B7n7JzPm.js";import"./extends.CF3RwP-h.js";import"./useRegionsByCountry.DJoy0LVE.js";import"./Breadcrumb.B59o6JfF.js";import"./home-breadcrumb-icon.aoDjGNuc.js";import"./ProfileNavigation.CYd1Cu18.js";import"./useProfile.BMSXi8UY.js";import"./truck-icon.u9JQiWNb.js";const D=r=>C({queryKey:["address",r],queryFn:()=>x(r).then(a=>a).catch(()=>{}),placeholderData:{},enabled:g.isAuthenticated()&&!!r}),F=()=>{const r=u();return m({mutationFn:s=>A(s),onSuccess:()=>{r.invalidateQueries({queryKey:["addresses"]})}})},k=()=>{const r=u();return m({mutationFn:s=>j(s),onSuccess:()=>{r.invalidateQueries({queryKey:["address"]}),r.invalidateQueries({queryKey:["addresses"]})}})},G=()=>{const{id:r}=v(),a=E(),{data:s}=D(r),p=k(),f=F(),[y,b]=d.useState({}),[e,c]=d.useState({});d.useEffect(()=>{s.id&&c({id:s.id,cid:s.cid,cnid:s.cnid,crid:s.cnid===1?s.crid:null,tl:s.tl,adl:s.adl,ct:s.ct,ar:s.ar??"",pc:s.pc,mob:s.mob,tel:s.tel??"",bel:s.bel??"",ncm:s.ncm??""})},[s]);const h=()=>{const t={};if(e.tl||(t.title="ΠαÏακαλοÏμε δÏÏÏε Îναν ΤίÏλο"),e.cnid||(t.country="ΠαÏακαλοÏμε ÏÏ
μÏληÏÏÏÏε Ïη ÏÏÏα"),e.cnid===1&&!e.crid&&(t.regionId="ΠαÏακαλοÏμε ÏÏ
μÏληÏÏÏÏε ÎομÏ"),(!e.ct||e.ct.trim()==="")&&(t.city="ΠαÏακαλοÏμε ÏÏ
μÏληÏÏÏÏε Ïην ÏÏλη"),(!e.adl||e.adl.trim()==="")&&(t.address="ΠαÏακαλοÏμε ÏÏ
μÏληÏÏÏÏε Ïη διεÏθÏ
νÏή ÏαÏ"),e.cnid){const o=S(e.pc,e.cnid);o.isValid||(t.postalCode=o.error)}else(!e.pc||e.pc.trim().length===0)&&(t.postalCode="ΠαÏακαλοÏμε ÏÏ
μÏληÏÏÏÏε Ïον Τ.Î.");if(e.tel&&e.tel.trim().length!==0&&e.tel.trim().length!==10&&(t.telephone="ΠαÏιθμÏÏ (ÏÏαθεÏÏ) δεν είναι ÎγκÏ
ÏοÏ"),e.cnid){const o=B(e.mob,e.cnid);o.isValid||(t.mobile=o.error)}else(!e.mob||e.mob.trim().length===0)&&(t.mobile="ΠαÏακαλοÏμε ÏÏ
μÏληÏÏÏÏε Ïον αÏÎ¹Î¸Î¼Ï ÎºÎ¹Î½Î·ÏοÏ");if(Object.keys(t).length!==0){b(t),n("ΠαÏÎ±ÎºÎ±Î»Ï ÎµÎ»ÎγξÏε Ïα Ïεδία ÏÎ·Ï ÏÏÏμαÏ");return}p.mutate(e,{onSuccess:()=>{l("ΠδιεÏθÏ
νÏη αÏοθηκεÏÏηκε",{autoClose:2e3}),a("/profile/addresses")},onError:()=>n("ÎÏεÏε ήδη μία διεÏθÏ
Ïη με αÏ
ÏÏν Ïον ÏίÏλο",{autoClose:2e3})})};return i.jsxs(i.Fragment,{children:[i.jsx(q,{page_title:"Addresses"}),i.jsx(P,{code:"addresses",children:i.jsxs("div",{id:"address-create",children:[i.jsx("h3",{className:"subtitle",children:"ÎÏεξεÏγαÏία ÎιεÏθÏ
νÏηÏ"}),i.jsx(N,{addressData:e,setAddressData:c,inputErrors:y}),i.jsxs("div",{className:"actions",children:[i.jsx("button",{className:"back",onClick:()=>a("/profile/addresses"),children:"ÎκÏÏÏÏη"}),i.jsx("button",{className:"delete",onClick:()=>f.mutate(r,{onSuccess:()=>{l("ΠδιεÏθÏ
νÏη διαγÏάÏθηκε",{autoClose:2e3}),a("/profile/addresses")},onError:()=>n("Î ÏοÎκÏ
Ïε κάÏοιο ÏÏÏβλημα",{autoClose:2e3})}),children:"ÎιαγÏαÏή"}),i.jsx("button",{className:"create",onClick:h,children:"ÎÏοθήκεÏ
Ïη"})]})]})})]})};export{G as default};
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.