vendor: 3,296 bytes, line 1
1import{i as G,u as I,j as e,k as R,l as P,m as J,n as Z,o as ee,p as A,q as se,r as re,s as ae,I as oe}from"./radix-ui-PvJvHBAw.js";import{r as l,L as C}from"./react-vendor-CxIpLpsw.js";import{S}from"./ShopLayout-CKXAxnxF.js";import{c as L,d as te,B as k,I as b,f as y,s as ie,t as ne}from"./index-O3POAvR-.js";import{L as j}from"./label-BJXZPA92.js";import{T as de}from"./textarea-BHtptXSt.js";import{w as le,e as _,L as ce}from"./icons-D2nnRMUb.js";import"./query-BDn3T966.js";import"./supabase-Bn8gZks7.js";var E="Radio",[ue,D]=G(E),[pe,me]=ue(E),M=l.forwardRef((t,n)=>{const{__scopeRadio:a,name:u,checked:i=!1,required:s,disabled:p,value:d="on",onCheck:m,form:v,...h}=t,[f,r]=l.useState(null),o=I(n,g=>r(g)),c=l.useRef(!1),x=f?v||!!f.closest("form"):!0;return e.jsxs(pe,{scope:a,checked:i,disabled:p,children:[e.jsx(R.button,{type:"button",role:"radio","aria-checked":i,"data-state":B(i),"data-disabled":p?"":void 0,disabled:p,value:d,...h,ref:o,onClick:P(t.onClick,g=>{i||m==null||m(),x&&(c.current=g.isPropagationStopped(),c.current||g.stopPropagation())})}),x&&e.jsx(z,{control:f,bubbles:!c.current,name:u,value:d,checked:i,required:s,disabled:p,form:v,style:{transform:"translateX(-100%)"}})]})});M.displayName=E;var T="RadioIndicator",V=l.forwardRef((t,n)=>{const{__scopeRadio:a,forceMount:u,...i}=t,s=me(T,a);return e.jsx(J,{present:u||s.checked,children:e.jsx(R.span,{"data-state":B(s.checked),"data-disabled":s.disabled?"":void 0,...i,ref:n})})});V.displayName=T;var he="RadioBubbleInput",z=l.forwardRef(({__scopeRadio:t,control:n,checked:a,bubbles:u=!0,...i},s)=>{const p=l.useRef(null),d=I(p,s),m=Z(a),v=ee(n);return l.useEffect(()=>{const h=p.current;if(!h)return;const f=window.HTMLInputElement.prototype,o=Object.getOwnPropertyDescriptor(f,"checked").set;if(m!==a&&o){const c=new Event("click",{bubbles:u});o.call(h,a),h.dispatchEvent(c)}},[m,a,u]),e.jsx(R.input,{type:"radio","aria-hidden":!0,defaultChecked:a,...i,tabIndex:-1,ref:d,style:{...i.style,...v,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});z.displayName=he;function B(t){return t?"checked":"unchecked"}var xe=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],w="RadioGroup",[fe,ke]=G(w,[A,D]),O=A(),U=D(),[ve,je]=fe(w),K=l.forwardRef((t,n)=>{const{__scopeRadioGroup:a,name:u,defaultValue:i,value:s,required:p=!1,disabled:d=!1,orientation:m,dir:v,loop:h=!0,onValueChange:f,...r}=t,o=O(a),c=se(v),[x,g]=re({prop:s,defaultProp:i??null,onChange:f,caller:w});return e.jsx(ve,{scope:a,name:u,required:p,disabled:d,value:x,onValueChange:g,children:e.jsx(ae,{asChild:!0,...o,orientation:m,dir:c,loop:h,children:e.jsx(R.div,{role:"radiogroup","aria-required":p,"aria-orientation":m,"data-disabled":d?"":void 0,dir:c,...r,ref:n})})})});K.displayName=w;var H="RadioGroupItem",W=l.forwardRef((t,n)=>{const{__scopeRadioGroup:a,disabled:u,...i}=t,s=je(H,a),p=s.disabled||u,d=O(a),m=U(a),v=l.useRef(null),h=I(n,v),f=s.value===i.value,r=l.useRef(!1);return l.useEffect(()=>{const o=x=>{xe.includes(x.key)&&(r.current=!0)},c=()=>r.current=!1;return document.addEventListener("keydown",o),document.addEventListener("keyup",c),()=>{document.removeEventListener("keydown",o),document.removeEventListener("keyup",c)}},[]),e.jsx(oe,{asChild:!0,...d,focusable:!p,active:f,children:e.jsx(M,{disabled:p,required:s.required,
1checked:f,...m,...i,name:s.name,ref:h,onCheck:()=>s.onValueChange(i.value),onKeyDown:P(o=>{o.key==="Enter"&&o.preventDefault()}),onFocus:P(i.onFocus,()=>{var o;r.current&&((o=v.current)==null||o.click())})})})});W.displayName=H;var ge="RadioGroupIndicator",X=l.forwardRef((t,n)=>{const{__scopeRadioGroup:a,...u}=t,i=U(a);return e.jsx(V,{...i,...u,ref:n})});X.displayName=ge;var $=K,Q=W,be=X;const Y=l.forwardRef(({className:t,...n},a)=>e.jsx($,{className:L("grid gap-2",t),...n,ref:a}));Y.displayName=$.displayName;const N=l.forwardRef(({className:t,...n},a)=>e.jsx(Q,{ref:a,className:L("aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),...n,children:e.jsx(be,{className:"flex items-center justify-center",children:e.jsx(le,{className:"h-2.5 w-2.5 fill-current text-current"})})}));N.displayName=Q.displayName;const q=7.9,F=9.9,_e=()=>{const{items:t,totalPrice:n,totalItems:a}=te(),[u,i]=l.useState(!1),[s,p]=l.useState({name:"",email:"",phone:"",delivery:"pickup",address:"",city:"",zip:"",notes:""}),d=(r,o)=>p(c=>({...c,[r]:o})),m=s.delivery==="shipping"?q:s.delivery==="express"?F:0,v=n+m,h=s.delivery==="shipping"||s.delivery==="express",f=async r=>{if(r.preventDefault(),t.length!==0){i(!0);try{const{data:o,error:c}=await ie.functions.invoke("create-checkout-session",{body:{items:t.map(x=>({productId:x.productId,sku:x.sku,name:x.name,unitPrice:x.unitPrice,quantity:x.quantity,imageUrl:x.imageUrl??null})),customer:{name:s.name,email:s.email,phone:s.phone||null},delivery:{method:s.delivery,address:h?s.address:null,city:h?s.city:null,zip:h?s.zip:null},notes:s.notes||null,origin:window.location.origin}});if(c)throw c;if(!(o!=null&&o.url))throw new Error("URL Stripe manquante");window.location.href=o.url}catch(o){console.error(o),ne({title:"Impossible de lancer le paiement",description:"Merci de réessayer ou de nous contacter sur WhatsApp.",variant:"destructive"}),i(!1)}}};return t.length===0?e.jsx(S,{children:e.jsxs("section",{className:"container py-16 text-center",children:[e.jsx("h1",{className:"mb-4 font-heading text-2xl font-bold",children:"Votre panier est vide"}),e.jsx(k,{asChild:!0,children:e.jsx(C,{to:"/boutique",children:"Aller à la boutique"})})]})}):e.jsx(S,{children:e.jsxs("section",{className:"container py-10",children:[e.jsxs("nav",{className:"mb-4 flex items-center gap-1 text-sm text-muted-foreground",children:[e.jsx(C,{to:"/boutique",className:"hover:text-primary",children:"Boutique"}),e.jsx(_,{className:"h-3 w-3"}),e.jsx(C,{to:"/panier",className:"hover:text-primary",children:"Panier"}),e.jsx(_,{className:"h-3 w-3"}),e.jsx("span",{className:"text-foreground",children:"Commande"})]}),e.jsx("h1",{className:"mb-8 font-heading text-2xl font-bold text-foreground md:text-3xl",children:"Finaliser ma commande"}),e.jsxs("form",{onSubmit:f,className:"grid gap-8 lg:grid-cols-[1fr_360px]",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"rounded-xl border border-border bg-card p-6",children:[e.jsx("h2",{className:"mb-4 font-heading text-lg font-semibold",children:"Vos coordonnées"}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"sm:col-span-2",children:[e.jsx(j,{htmlFor:"name",children:"Nom complet *"}),e.jsx(b,{id:"name",required:!0,value:s.name,onChange:r=>d("name",r.target.value)})]}),e.jsxs("div",{children:[e.jsx(j,{htmlFor:"email",children:"Email *"}),e.jsx(b,{id:"email",type:"email",required:!0,value:s.email,onChange:r=>d("email",r.target.value)})]}),e.jsxs("div",{children:[e.jsx(j,{htmlFor:"phone",children:"Téléphone"}),e.jsx(b,{id:"phone",type:"tel",value:s.phone,onChange:r=>d("phone",r.target.value)})]})]})]}),e.jsxs("div",{className:"rounded-xl border border-border bg-card p-6",children:[e.jsx("h2",{className:"mb-4 font-heading text-lg font-semibold",children:"Mode de réception"}),e.jsxs(Y,{value:s.delivery,onValueChange:r=>d("delivery",r),className:"space-y-3",children:[e.jsxs("label",{htmlFor:"d-pickup",className:"flex cursor-pointer items-start gap-3 rounded-lg border border-border p-4 hover:bg-secondary/30",children:[e.jsx(N,{value:"pickup",id:"d-pickup"}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium",children:["Retrait en boutique ",e.jsx("span",{className:"text-primary",children:"â gratuit"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"RVI 88 â 3 rue des Maquisards, 88510 Ãloyes"})]})]}),e.jsxs("label",{htmlFor:"d-shipping",className:"flex cursor-pointer items-start gap-3 rounded-lg border border-border p-4 hover:bg-secondary/30",children:[e.jsx(N,{value:"shipping",id:"d-shipping"}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium",children:["Expédition standard Colissimo"," ",e.jsxs("span",{className:"whitespace-nowrap text-primary",children:["â ",y(q)]})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Livraison sous 3-5 jours ouvrés."})]})]}),e.jsxs("label",{htmlFor:"d-express",className:"flex cursor-pointer items-start gap-3 rounded-lg border border-border p-4 hover:bg-secondary/30",children:[e.jsx(N,{value:"express",id:"d-express"}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium",children:["Livraison express 24/48h"," ",e.jsxs("span",{className:"whitespace-nowrap text-primary",children:["â ",y(F)]})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Colissimo Expert / Chronopost â livraison sous 24 à 48h ouvrées."})]})]})]}),h&&e.jsxs("div",{className:"mt-4 grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"sm:col-span-2",children:[e.jsx(j,{htmlFor:"address",children:"Adresse *"}),e.jsx(b,{id:"address",required:!0,value:s.address,onChange:r=>d("address",r.target.value)})]}),e.jsxs("div",{children:[e.jsx(j,{htmlFor:"zip",children:"Code postal *"}),e.jsx(b,{id:"zip",required:!0,value:s.zip,onChange:r=>d("zip",r.target.value)})]}),e.jsxs("div",{children:[e.jsx(j,{htmlFor:"city",children:"Ville *"}),e.jsx(b,{id:"city",required:!0,value:s.city,onChange:r=>d("city",r.target.value)})]})]})]}),e.jsxs("div",{className:"rounded-xl border border-border bg-card p-6",children:[e.jsx(j,{htmlFor:"notes",children:"Précisions (optionnel)"}),e.jsx(de,{id:"notes",rows:3,value:s.notes,onChange:r=>d("notes",r.target.value),placeholder:"Question, contraintes, compatibilitéâ¦"})]})]}),e.jsxs("aside",{className:"h-fit space-y-4 rounded-xl border border-border bg-card p-6",children:[e.jsx("h2",{className:"font-heading text-lg font-semibold",children:"Votre commande"}),e.jsx("ul",{className:"space-y-2 text-sm",children:t.map(r=>e.jsxs("li",{className:"flex justify-between gap-2",children:[e.jsxs("span",{className:"line-clamp-1 text-muted-foreground",children:[r.quantity,"à ",r.name]}),e.jsx("span",{className:"whitespace-nowrap font-medium",children:y(r.unitPrice*r.quantity)})]},r.productId))}),e.jsxs("div",{className:"space-y-1 border-t border-border pt-3 text-sm",children:[e.jsxs("div",{className:"flex justify-between text-muted-foreground",children:[e.jsxs("span",{children:["Sous-total (",a," article",a>1?"s":"",")"]}),e.jsx("span",{className:"whitespace-nowrap",children:y(n)})]}),e.jsxs("div",{className:"flex justify-between text-muted-foreground",children:[e.jsx("span",{children:h?"Frais d'expédition":"Retrait boutique"}),e.jsx("span",{className:"whitespace-nowrap",children:m>0?y(m):"Gratuit"})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2 text-base font-semibold",children:[e.jsx("span",{children:"Total"}),e.jsx("span",{className:"whitespace-nowrap text-primary",children:y(v)})]})]}),e.jsx(k,{type:"submit",disabled:u,className:"w-full",size:"lg",children:u?e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"mr-2 h-4 w-4 animate-spin"}),"Redirection vers le paiementâ¦"]}):"Payer en ligne"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Paiement 100 % sécurisé par Stripe (CB, Apple Pay, Google Pay)."})]})]})]})})};export{_e 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.