module.exports=[48964,a=>{"use strict";var b=a.i(87924),c=a.i(72131),d=a.i(95445);a.s(["default",0,function({value:a,onChange:e,folder:f="misc",label:g="Image"}){let h=(0,d.createClient)(),i=(0,c.useRef)(null),[j,k]=(0,c.useState)(!1),[l,m]=(0,c.useState)(null);async function n(a){let b=a.target.files?.[0];if(!b)return;k(!0),m(null);let c=(b.name.split(".").pop()||"jpg").toLowerCase(),d=`${f}/${Date.now()}-${Math.random().toString(36).slice(2,8)}.${c}`,{error:g}=await h.storage.from("media").upload(d,b,{cacheControl:"3600",upsert:!1});if(g){m(g.message),k(!1);return}let{data:i}=h.storage.from("media").getPublicUrl(d);e(i.publicUrl),k(!1)}return(0,b.jsxs)("div",{children:[(0,b.jsx)("label",{className:"block text-sm font-medium mb-1",children:g}),(0,b.jsxs)("div",{className:"flex items-start gap-3",children:[(0,b.jsx)("div",{className:"h-20 w-20 shrink-0 overflow-hidden rounded-md border border-neutral-200 bg-neutral-100",children:a?(0,b.jsx)("img",{src:a,alt:"",className:"h-full w-full object-cover"}):(0,b.jsx)("div",{className:"flex h-full w-full items-center justify-center text-[11px] text-neutral-400",children:"No image"})}),(0,b.jsxs)("div",{className:"flex-1 space-y-2",children:[(0,b.jsxs)("div",{className:"flex gap-2",children:[(0,b.jsx)("button",{type:"button",onClick:()=>i.current?.click(),disabled:j,className:"rounded-md bg-neutral-900 px-3 py-1.5 text-sm font-medium text-white hover:bg-neutral-700 disabled:opacity-50",children:j?"Uploading…":"Upload"}),a&&(0,b.jsx)("button",{type:"button",onClick:()=>e(""),className:"rounded-md border border-neutral-200 px-3 py-1.5 text-sm text-neutral-600 hover:bg-neutral-50",children:"Remove"})]}),(0,b.jsx)("input",{ref:i,type:"file",accept:"image/*",onChange:n,className:"hidden"}),(0,b.jsx)("input",{value:a,onChange:a=>e(a.target.value),placeholder:"…or paste an image URL",className:"input"}),l&&(0,b.jsx)("p",{className:"text-sm text-red-600",children:l})]})]})]})}])},46642,a=>{"use strict";var b=a.i(87924),c=a.i(72131),d=a.i(50944),e=a.i(95445),f=a.i(48964);function g({label:a,children:c}){return(0,b.jsxs)("div",{children:[(0,b.jsx)("label",{className:"block text-sm font-medium mb-1",children:a}),c]})}a.s(["default",0,function({categories:a}){let h=(0,d.useRouter)(),i=(0,e.createClient)(),[j,k]=(0,c.useState)({title:"",description:"",venue:"",starts_at:"",ends_at:"",cover_image_url:"",category_id:""}),[l,m]=(0,c.useState)(null),[n,o]=(0,c.useState)(!1);async function p(a){a.preventDefault(),o(!0),m(null);let{data:b}=await i.auth.getUser();if(!b.user){m("Not signed in"),o(!1);return}let{data:c,error:d}=await i.from("events").insert({organizer_id:b.user.id,title:j.title,description:j.description||null,venue:j.venue||null,starts_at:new Date(j.starts_at).toISOString(),ends_at:j.ends_at?new Date(j.ends_at).toISOString():null,cover_image_url:j.cover_image_url||null,category_id:j.category_id||null,status:"draft"}).select().single();if(d){m(d.message),o(!1);return}h.push(`/dashboard/events/${c.id}`)}return(0,b.jsxs)("form",{onSubmit:p,className:"space-y-4",children:[(0,b.jsx)(g,{label:"Title",children:(0,b.jsx)("input",{required:!0,value:j.title,onChange:a=>k({...j,title:a.target.value}),className:"input"})}),(0,b.jsx)(g,{label:"Description",children:(0,b.jsx)("textarea",{value:j.description,onChange:a=>k({...j,description:a.target.value}),className:"input",rows:3})}),(0,b.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,b.jsx)(g,{label:"Venue",children:(0,b.jsx)("input",{value:j.venue,onChange:a=>k({...j,venue:a.target.value}),className:"input"})}),(0,b.jsx)(g,{label:"Category",children:(0,b.jsxs)("select",{value:j.category_id,onChange:a=>k({...j,category_id:a.target.value}),className:"input",children:[(0,b.jsx)("option",{value:"",children:"— None —"}),a.map(a=>(0,b.jsx)("option",{value:a.id,children:a.name},a.id))]})})]}),(0,b.jsx)(f.default,{value:j.cover_image_url,onChange:a=>k({...j,cover_image_url:a}),folder:"events",label:"Cover image"}),(0,b.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,b.jsx)(g,{label:"Starts at",children:(0,b.jsx)("input",{required:!0,type:"datetime-local",value:j.starts_at,onChange:a=>k({...j,starts_at:a.target.value}),className:"input"})}),(0,b.jsx)(g,{label:"Ends at",children:(0,b.jsx)("input",{type:"datetime-local",value:j.ends_at,onChange:a=>k({...j,ends_at:a.target.value}),className:"input"})})]}),l&&(0,b.jsx)("p",{className:"text-sm text-red-600",children:l}),(0,b.jsx)("button",{type:"submit",disabled:n,className:"rounded-md bg-brand-green text-white px-4 py-2 text-sm font-medium hover:bg-brand-green-deep disabled:opacity-50",children:n?"Creating…":"Create event"})]})}])}];

//# sourceMappingURL=src_0-pu7nn._.js.map