"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[22739],{22739:(e,r,t)=>{t.r(r),t.d(r,{default:()=>u});var a=t(95155),s=t(12115),c=t(73321),n=t(44507),o=t(62673),d=t(2581),i=t(38992),l=t(34426);function u({params:e}){let r=(0,c.useRouter)(),t=(0,s.use)(e),u=t?.id,[g,h]=(0,s.useState)(null),[m,x]=(0,s.useState)(!0),[p,y]=(0,s.useState)(!1);(0,s.useEffect)(()=>{u&&(async()=>{try{x(!0);let e=await o.$s(u);h(e)}catch(e){console.error("Error fetching category:",e),(0,d.Qg)(Object(e).message||"An error occurred"),r.push("/admin/categories")}finally{x(!1)}})()},[u,r]);let f=async e=>{try{y(!0),await o.st(u,e),(0,d.Te)("Category updated successfully!"),r.push("/admin/categories")}catch(e){console.error("Error updating category:",e),(0,d.Qg)(Object(e).message||"An error occurred")}finally{y(!1)}};return m?(0,a.jsx)(i.Z,{padding:"lg",children:(0,a.jsx)("div",{className:"text-center py-12",children:(0,a.jsx)("p",{className:"text-[var(--muted-foreground)]",children:"Loading category..."})})}):g?(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"mb-8",children:[(0,a.jsx)("h1",{className:"text-3xl font-bold text-[var(--foreground)]",children:"Edit Category"}),(0,a.jsx)("p",{className:"text-[var(--muted-foreground)] mt-2",children:"Update the category details below"})]}),(0,a.jsx)(n.H,{category:g,onSubmit:f,onCancel:()=>{r.push("/admin/categories")},isLoading:p})]}):(0,a.jsx)(i.Z,{padding:"lg",children:(0,a.jsxs)("div",{className:"text-center py-12",children:[(0,a.jsx)("p",{className:"text-[var(--muted-foreground)] mb-4",children:"Category not found"}),(0,a.jsx)(l.$,{onClick:()=>r.push("/admin/categories"),children:"Back to Categories"})]})})}}}]);