module.exports=[9529,a=>{"use strict";var b=a.i(87924);function c(...a){return a.filter(Boolean).join(" ")}a.i(38246);let d={primary:"bg-brand-green text-white hover:bg-brand-green-deep focus-visible:ring-brand-green",secondary:"border border-be-border bg-be-surface text-be-text hover:bg-be-surface-2 focus-visible:ring-brand-green",ghost:"text-be-muted hover:text-be-text hover:bg-be-surface-2 focus-visible:ring-brand-green",danger:"bg-[color:var(--pill-danger-fg)] text-white hover:opacity-90 focus-visible:ring-[color:var(--pill-danger-fg)]"};a.s(["Card",0,function({className:a,children:d}){return(0,b.jsx)("div",{className:c("be-card p-5",a),children:d})},"buttonClass",0,function(a="primary",b){return c("inline-flex items-center justify-center gap-1.5 rounded-lg px-4 py-2 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-offset-be-bg disabled:opacity-50 disabled:pointer-events-none",d[a],b)}])},6566,a=>{"use strict";var b=a.i(87924),c=a.i(72131),d=a.i(50944),e=a.i(95445),f=a.i(9529);function g({label:a,hint:c,children:d}){return(0,b.jsxs)("div",{children:[(0,b.jsxs)("label",{className:"block text-sm font-medium mb-1 text-be-text",children:[a," ",c&&(0,b.jsxs)("span",{className:"font-normal text-be-muted",children:["— ",c]})]}),d]})}a.s(["default",0,function(){let a=(0,d.useRouter)(),h=(0,e.createClient)(),[i,j]=(0,c.useState)({code:"",name:"",commissionPercent:"10"}),[k,l]=(0,c.useState)(null),[m,n]=(0,c.useState)(!1);async function o(b){b.preventDefault(),n(!0),l(null);let{data:c}=await h.auth.getUser();if(!c.user){l("Not signed in"),n(!1);return}let d=Number(i.commissionPercent);if(!d||d<=0||d>100){l("Enter a commission between 1 and 100"),n(!1);return}let{error:e}=await h.from("affiliates").insert({organizer_id:c.user.id,code:i.code.trim().toUpperCase(),name:i.name.trim()||null,commission_percent:d});if(e){l("23505"===e.code?"You already have an affiliate with this code.":e.message),n(!1);return}a.push("/dashboard/affiliates"),a.refresh()}return(0,b.jsxs)("form",{onSubmit:o,className:"space-y-4",children:[(0,b.jsx)(g,{label:"Code",children:(0,b.jsx)("input",{required:!0,value:i.code,onChange:a=>j({...i,code:a.target.value}),placeholder:"e.g. JOHN10",className:"input font-mono uppercase"})}),(0,b.jsx)(g,{label:"Promoter name",hint:"Optional",children:(0,b.jsx)("input",{value:i.name,onChange:a=>j({...i,name:a.target.value}),placeholder:"e.g. John Doe",className:"input"})}),(0,b.jsx)(g,{label:"Commission (%)",hint:"Share of the order total credited on each attributed sale",children:(0,b.jsx)("input",{required:!0,type:"number",min:"1",max:"100",value:i.commissionPercent,onChange:a=>j({...i,commissionPercent:a.target.value}),className:"input"})}),k&&(0,b.jsx)("p",{className:"text-sm text-red-600",children:k}),(0,b.jsx)("button",{type:"submit",disabled:m,className:(0,f.buttonClass)("primary"),children:m?"Creating…":"Create affiliate"})]})}])}];

//# sourceMappingURL=src_0wk9qsl._.js.map