"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[26546],{26546:(e,s,t)=>{t.r(s),t.d(s,{default:()=>m});var a=t(95155),n=t(12115),r=t(73321),i=t(8267),l=t(2962),c=t(74016),u=t(74937),d=t(34426),o=t(78480),f=t(16099),h=t(2581);function m({params:e}){let s=(0,r.useRouter)(),t=(0,n.use)(e),m=t?.id,[v,p]=(0,n.useState)(null),[w,N]=(0,n.useState)(!0),[b,y]=(0,n.useState)(!1);(0,n.useEffect)(()=>{m&&(async()=>{try{N(!0);let e=await (0,o.Z8)(m);p(e)}catch(e){(0,h.Qg)(e instanceof Error?e.message:"Event not found"),s.push(`${f.bw.ADMIN}/events`)}finally{N(!1)}})()},[m,s]);let j=async e=>{if(m)try{y(!0),await (0,o.qM)(m,e),(0,h.Te)("Event updated successfully"),s.push(`${f.bw.ADMIN}/events`)}catch(e){throw(0,h.Qg)(e instanceof Error?e.message:"Failed to update event"),e}finally{y(!1)}};return w?(0,a.jsx)("div",{className:"flex min-h-[40vh] items-center justify-center",children:(0,a.jsx)("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-slate-300 border-t-primary-600"})}):v?(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsx)(l.u,{href:`${f.bw.ADMIN}/events`,children:(0,a.jsxs)(d.$,{variant:"outline",size:"sm",className:"w-fit",children:[(0,a.jsx)(i.AqJ,{className:"mr-2 h-4 w-4"}),"Back to events"]})}),(0,a.jsx)(c.wc,{title:"Edit event",description:v.title}),(0,a.jsx)(u.B,{initialData:v,onSubmit:j,onCancel:()=>s.push(`${f.bw.ADMIN}/events`),isLoading:b})]}):null}}}]);