(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[974],{3321:(e,t,s)=>{"use strict";var r=s(4645);s.o(r,"useRouter")&&s.d(t,{useRouter:function(){return r.useRouter}}),s.o(r,"useSearchParams")&&s.d(t,{useSearchParams:function(){return r.useSearchParams}})},6125:(e,t,s)=>{Promise.resolve().then(s.bind(s,6687))},6687:(e,t,s)=>{"use strict";s.d(t,{default:()=>c});var r=s(5155),n=s(3321),i=s(2115);function c(){let e=(0,n.useRouter)(),[t,s]=(0,i.useState)("My invite project"),[c,a]=(0,i.useState)(!1),[l,o]=(0,i.useState)(null),[d,u]=(0,i.useState)([]),x=async()=>{let e=await fetch("/api/projects");e.ok&&u((await e.json()).projects??[])};return(0,i.useEffect)(()=>{x()},[]),(0,r.jsx)("div",{className:"min-h-screen bg-zinc-950 text-zinc-50",children:(0,r.jsxs)("div",{className:"mx-auto max-w-3xl px-6 py-12",children:[(0,r.jsxs)("div",{className:"mt-8 rounded-xl border border-zinc-800 bg-zinc-950",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between border-b border-zinc-900 px-4 py-3",children:[(0,r.jsx)("div",{className:"text-xs uppercase tracking-wide text-zinc-500",children:"Projects"}),(0,r.jsx)("button",{onClick:x,className:"rounded-md border border-zinc-800 bg-zinc-950 px-2 py-1 text-xs text-zinc-300 hover:bg-zinc-900",children:"Refresh"})]}),(0,r.jsx)("div",{className:"max-h-[360px] overflow-auto p-2",children:0===d.length?(0,r.jsx)("div",{className:"p-3 text-sm text-zinc-500",children:"No projects yet."}):d.map(t=>(0,r.jsxs)("button",{onClick:()=>e.push(`/projects/${t.id}`),className:"flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left hover:bg-zinc-900",children:[(0,r.jsx)("div",{className:"h-12 w-12 shrink-0 overflow-hidden rounded-lg border border-white/10 bg-zinc-900",children:(0,r.jsx)("img",{src:`/files/projects/${t.id}/preview`,alt:"",className:"h-full w-full object-cover",onError:e=>{e.currentTarget.style.display="none"}})}),(0,r.jsx)("div",{className:"min-w-0",children:(0,r.jsx)("div",{className:"text-sm text-zinc-200",children:t.name})})]},t.id))})]}),(0,r.jsxs)("div",{className:"mt-8 rounded-xl border border-zinc-800 bg-zinc-900 p-4",children:[(0,r.jsx)("input",{value:t,onChange:e=>s(e.target.value),className:"w-full rounded-lg border border-zinc-800 bg-zinc-950 px-3 py-2 text-sm outline-none focus:border-zinc-600",placeholder:"Project name"}),l?(0,r.jsx)("div",{className:"mt-2 text-sm text-red-400",children:l}):null,(0,r.jsx)("button",{disabled:c,onClick:async()=>{a(!0),o(null);try{let s=await fetch("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t})});if(!s.ok)throw Error("Failed to create project");let r=await s.json();await x(),e.push(`/projects/${r.project.id}`)}catch(e){o(e.message)}finally{a(!1)}},className:"mt-4 inline-flex items-center justify-center rounded-lg bg-zinc-50 px-4 py-2 text-sm font-medium text-zinc-950 disabled:opacity-60",children:c?"Creating…":"Create project"})]})]})})}}},e=>{e.O(0,[441,794,358],()=>e(e.s=6125)),_N_E=e.O()}]);