1import{c as j,r as p,Z as h,_ as E,j as e,S as F,t as w,L as z,C as I,q as P,$ as T,a0 as U,a1 as f,a2 as B,a3 as O,a4 as q}from"./index-C9ahAzu-.js";import{P as k}from"./package-BDA9X3BG.js";import{E as M}from"./external-link-CjzJnI1E.js";import{M as L}from"./map-pin-DNEyDnFK.js";import{P as V}from"./pencil-DArnpvMs.js";import{T as R}from"./trash-2-D816s959.js";/** 2 * @license lucide-react v0.462.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const _=j("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);/** 7 * @license lucide-react v0.462.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const $=j("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/** 12 * @license lucide-react v0.462.0 - ISC 13 * 14 * This source code is licensed under the ISC license. 15 * See the LICENSE file in the root directory of this source tree. 16 */const y=j("Star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]),ee=()=>{const[r,o]=p.useState("overview"),l=h(n=>n.customer),m=h(n=>n.accessToken),x=h(n=>n.isLoading),t=h(n=>n.isLoggedIn),d=h(n=>n.logout),g=h(n=>n.refreshCustomer),u=E();p.useEffect(()=>{if(!t()){u("/account/inloggen");return}g()},[]);const i=async()=>{await d(),u("/")};if(!t())return null;const c=[{key:"overview",label:"Overzicht",icon:e.jsx(T,{className:"w-4 h-4"})},{key:"orders",label:"Bestellingen",icon:e.jsx(k,{className:"w-4 h-4"})},{key:"addresses",label:"Adressen",icon:e.jsx(L,{className:"w-4 h-4"})}];return e.jsxs(e.Fragment,{children:[e.jsx(F,{title:"Mijn account â VillaMeubels",description:"Beheer je account, bestellingen en adressen."}),e.jsxs("div",{className:"container-villa py-10 lg:py-16",children:[e.jsxs("div",{className:"flex items-center justify-between mb-8",children:[e.jsx("h1",{className:"font-display text-2xl lg:text-3xl font-semibold text-foreground",children:"Mijn account"}),e.jsxs("button",{onClick:i,className:"flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx($,{className:"w-4 h-4"})," Uitloggen"]})]}),e.jsx("div",{className:"flex gap-1 mb-8 border-b border-border overflow-x-auto no-scrollbar",children:c.map(n=>e.jsxs("button",{onClick:()=>o(n.key),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium whitespace-nowrap border-b-2 transition-colors ${r===n.key?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[n.icon," ",n.label]},n.key))}),x&&!l?e.jsx("div",{className:"flex justify-center py-20",children:e.jsx(w,{className:"w-6 h-6 animate-spin text-primary"})}):e.jsxs(e.Fragment,{children:[r==="overview"&&e.jsx(J,{customer:l}),r==="orders"&&e.jsx(Y,{customer:l}),r==="addresses"&&e.jsx(G,{customer:l,accessToken:m,onRefresh:g})]})]})]})},J=({customer:r})=>{if(!r)return null;const o=r.orders.edges.length,l=r.addresses.edges.length;return e.jsxs("div",{className:"grid gap-6 md:grid-cols-2 lg:grid-cols-3",children:[e.jsxs("div",{className:"bg-card border border-border rounded-sm p-6",children:[e.jsx("h3",{className:"font-display text-lg font-semibold text-foreground mb-3",children:"Persoonlijke gegevens"}),e.jsxs("div",{className:"space-y-1.5 text-sm text-muted-foreground",children:[e.jsxs("p",{className:"text-foreground font-medium",children:[r.firstName," ",r.lastName]}),e.jsx("p",{children:r.email}),r.phone&&e.jsx("p",{children:r.phone})]})]}),e.jsxs("div",{className:"bg-card border border-border rounded-sm p-6",children:[e.jsx("h3",{className:"font-display text-lg font-semibold text-foreground mb-3",children:"Bestellingen"}),e.jsx("p",{className:"text-3xl font-semibold text-foreground",children:o}),e.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[o===1?"bestelling":"bestellingen"," geplaatst"]})]}),e.jsxs("div",{className:"bg-card border border-border rounded-sm p-6",children:[e.jsx("h3",{className:"font-display text-lg font-semibold text-foreground mb-3",children:"Adressen"}),e.jsx("p",{className:"text-3xl font-semibold text-foreground",children:l}),e.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:["opgeslagen ",l===1?"adres":"adressen"]})]}),r.defaultAddress&&e.jsxs("div",{className:"bg-card border border-border rounded-sm p-6 md:col-span-2 lg:col-span-3",children:[e.jsx("h3",{className:"font-display text-lg font-semibold text-foreground mb-3",children:"Standaard adres"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[r.defaultAddress.firstName," ",r.defaultAddress.lastName,e.jsx("br",{}),r.defaultAddress.address1,r.defaultAddress.address2?`, ${r.defaultAddress.address2}`:"",e.jsx("br",{}),r.defaultAddress.zip," ",r.defaultAddress.city,e.jsx("br",{}),r.defaultAddress.country]})]})]})},Y=({customer:r})=>
16{const[o,l]=p.useState(null);if(!r)return null;const m=r.orders.edges;if(m.length===0)return e.jsxs("div",{className:"text-center py-20",children:[e.jsx(k,{className:"w-12 h-12 text-muted-foreground/30 mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"Je hebt nog geen bestellingen geplaatst."}),e.jsx(z,{to:"/",className:"text-sm text-primary font-medium hover:underline mt-2 inline-block",children:"Bekijk onze collectie"})]});const x=t=>({PAID:"Betaald",PENDING:"In afwachting",REFUNDED:"Terugbetaald",PARTIALLY_REFUNDED:"Deels terugbetaald",FULFILLED:"Verzonden",UNFULFILLED:"In behandeling",PARTIALLY_FULFILLED:"Deels verzonden"})[t]||t;return e.jsx("div",{className:"space-y-4",children:m.map(({node:t})=>e.jsxs("div",{className:"bg-card border border-border rounded-sm overflow-hidden",children:[e.jsxs("button",{onClick:()=>l(o===t.id?null:t.id),className:"w-full flex items-center justify-between p-5 text-left hover:bg-muted/30 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-6 flex-wrap",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Bestelling"}),e.jsxs("p",{className:"text-sm font-semibold text-foreground",children:["#",t.orderNumber]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Datum"}),e.jsx("p",{className:"text-sm text-foreground",children:new Date(t.processedAt).toLocaleDateString("nl-NL")})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Status"}),e.jsx("p",{className:"text-sm text-foreground",children:x(t.fulfillmentStatus)})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Totaal"}),e.jsxs("p",{className:"text-sm font-semibold text-foreground",children:["â¬",parseFloat(t.totalPrice.amount).toLocaleString("nl-NL",{minimumFractionDigits:2})]})]})]}),o===t.id?e.jsx(_,{className:"w-4 h-4 text-muted-foreground"}):e.jsx(I,{className:"w-4 h-4 text-muted-foreground"})]}),o===t.id&&e.jsxs("div",{className:"border-t border-border p-5",children:[e.jsx("div",{className:"space-y-3 mb-4",children:t.lineItems.edges.map(({node:d},g)=>{var u;return e.jsxs("div",{className:"flex gap-3 items-center",children:[((u=d.variant)==null?void 0:u.image)&&e.jsx("img",{src:d.variant.image.url,alt:d.title,className:"w-12 h-12 rounded-sm object-cover flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-foreground truncate",children:d.title}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Aantal: ",d.quantity]})]}),d.variant&&e.jsxs("span",{className:"text-sm font-medium text-foreground",children:["â¬",(parseFloat(d.variant.price.amount)*d.quantity).toLocaleString("nl-NL",{minimumFractionDigits:2})]})]},g)})}),e.jsxs("a",{href:t.statusUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 text-sm text-primary font-medium hover:underline",children:["Bestelling volgen ",e.jsx(M,{className:"w-3.5 h-3.5"})]})]})]},t.id))})},G=({customer:r,accessToken:o,onRefresh:l})=>{var v;const[m,x]=p.useState(!1),[t,d]=p.useState(null),[g,u]=p.useState(!1),[i,c]=p.useState({firstName:"",lastName:"",address1:"",address2:"",city:"",province:"",zip:"",country:"Netherlands",phone:""});if(!r||!o)return null;const n=r.addresses.edges,N=(v=r.defaultAddress)==null?void 0:v.id,b=()=>{c({firstName:"",lastName:"",address1:"",address2:"",city:"",province:"",zip:"",country:"Netherlands",phone:""}),d(null),x(!1)},A=s=>{c({firstName:s.firstName,lastName:s.lastName,address1:s.address1,address2:s.address2||"",city:s.city,province:s.province,zip:s.zip,country:s.country,phone:s.phone||""}),d(s.id),x(!0)},C=async s=>{s.preventDefault(),u(!0);try{t?(await U(o,t,i),f.success("Adres bijgewerkt")):(await B(o,i),f.success("Adres toegevoegd")),await l(),b()}catch(a){f.error(a instanceof Error?a.message:"Er is iets misgegaan")}finally{u(!1)}},S=async s=>{if(confirm("Weet je zeker dat je dit adres wilt verwijderen?"))try{await O(o,s),f.success("Adres verwijderd"),await l()}catch(a){f.error(a instanceof Error?a.message:"Verwijderen mislukt")}},D=async s=>{try{await q(o,s),f.success("Standaard adres bijgewerkt"),await l()}catch(a){f.error(a instanceof Error?a.message:"Bijwerken mislukt")}};return e.jsxs("div",{children:[!m&&e.jsxs("button",{onClick:()=>{b(),x(!0)},className:"flex items-center gap-2 text-sm text-primary font-medium hover:underline mb-6",children:[e.jsx(P,{className:"w-4 h-4"})," Nieuw adres toevoegen"]}),m&&e.jsxs("form",{onSubmit:C,className:"bg-card border border-border rounded-sm p-6 mb-6",children:[e.jsx("h3",{className:"font-display text-lg font-semibold text-foreground mb-4",children:t?"Adres bewerken":"Nieuw adres"}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx("input",{placeholder:"Voornaam",required:!0,value:i.firstName,onChange:s=>c(a=>({...a,firstName:s.target.value})),className:"h-11 px-4 border border-border rounded-sm bg-background text-foreground text-sm focus:outline-none focus:ring-2 focus:ring-primary/30 focus:border-primary"}),e.jsx("input",{placeholder:"Achternaam",required:!0,value:i.lastName,onChange:s=>c(a=>({...a,lastName:s.target.value})),className:"h-11 px-4 border border-border rounded-sm bg-background text-foreground text-sm focus:outline-none focus:ring-2 focus:ring-primary/30 focus:border-primary"}),e.jsx("input",{placeholder:"Adres",required:!0,value:i.address1,onChange:s=>c(a=>({...a,address1:s.target.value})),className:"h-11 px-4 border border-border rounded-sm bg-background text-foreground text-sm focus:outline-none focus:ring-2 focus:ring-primary/30 focus:border-primary sm:col-span-2"}),e.jsx("input",{placeholder:"Toevoeging (optioneel)",value:i.address2,onChange:s=>c(a=>({...a,address2:s.target.value})),className:"h-11 px-4 border border-border rounded-sm bg-background text-foreground text-sm focus:outline-none focus:ring-2 focus:ring-primary/30 focus:border-primary sm:col-span-2"}),e.jsx("input",{placeholder:"Postcode",required:!0,value:i.zip,onChange:s=>c(a=>({...a,zip:s.target.value})),className:"h-11 px-4 border border-border rounded-sm bg-background text-foreground text-sm focus:outline-none focus:ring-2 focus:ring-primary/30 focus:border-primary"}),e.jsx("input",{placeholder:"Plaats",required:!0,value:i.city,onChange:s=>c(a=>({...a,city:s.target.value})),className:"h-11 px-4 border border-border rounded-sm bg-background text-foreground text-sm focus:outline-none focus:ring-2 focus:ring-primary/30 focus:border-primary"}),e.jsx("input",{placeholder:"Telefoonnummer (optioneel)",value:i.phone,onChange:s=>c(a=>({...a,phone:s.target.value})),className:"h-11 px-4 border border-border rounded-sm bg-background text-foreground text-sm focus:outline-none focus:ring-2 focus:ring-primary/30 focus:border-primary sm:col-span-2"})]}),e.jsxs("div",{className:"flex gap-3 mt-4",children:[e.jsxs("button",{type:"submit",disabled:g,className:"h-10 px-6 bg-primary text-primary-foreground rounded-sm text-sm font-medium hover:bg-primary/90 transition-colors disabled:opacity-50 flex items-center gap-2",children:[g?e.jsx(w,{className:"w-4 h-4 animate-spin"}):null,t?"Opslaan":"Toevoegen"]}),e.jsx("button",{type:"button",onClick:b,className:"h-10 px-6 border border-border rounded-sm text-sm text-muted-foreground hover:text-foreground transition-colors",children:"Annuleren"})]})]}),n.length===0&&!m?e.jsxs("div",{className:"text-center py-20",children:[e.jsx(L,{className:"w-12 h-12 text-muted-foreground
16/30 mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"Je hebt nog geen adressen opgeslagen."})]}):e.jsx("div",{className:"grid gap-4 sm:grid-cols-2",children:n.map(({node:s})=>e.jsxs("div",{className:"bg-card border border-border rounded-sm p-5 relative",children:[N===s.id&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-medium text-primary mb-2",children:[e.jsx(y,{className:"w-3 h-3 fill-primary"})," Standaard"]}),e.jsxs("p",{className:"text-sm text-foreground font-medium",children:[s.firstName," ",s.lastName]}),e.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[s.address1,s.address2?`, ${s.address2}`:"",e.jsx("br",{}),s.zip," ",s.city,e.jsx("br",{}),s.country]}),s.phone&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:s.phone}),e.jsxs("div",{className:"flex gap-3 mt-4",children:[e.jsxs("button",{onClick:()=>A(s),className:"text-xs text-muted-foreground hover:text-foreground flex items-center gap-1",children:[e.jsx(V,{className:"w-3 h-3"})," Bewerken"]}),N!==s.id&&e.jsxs("button",{onClick:()=>D(s.id),className:"text-xs text-muted-foreground hover:text-foreground flex items-center gap-1",children:[e.jsx(y,{className:"w-3 h-3"})," Standaard maken"]}),e.jsxs("button",{onClick:()=>S(s.id),className:"text-xs text-destructive hover:text-destructive/80 flex items-center gap-1",children:[e.jsx(R,{className:"w-3 h-3"})," Verwijderen"]})]})]},s.id))})]})};export{ee 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.