"use strict";exports.id=88954,exports.ids=[88954],exports.modules={20403:(a,b,c)=>{c.d(b,{J:()=>o});var d=c(48249);c(67484);var e=c(52099),f=c(7154),g=c(62828),h=c(41090),i=c(20524),j=c(3430),k=c(93744),l=c(33670),m=c(66740);let n=g.Ikc({question:g.YjP().min(1,"Question is required").max(500,"Question must be less than 500 characters"),answer:g.YjP().min(1,"Answer is required"),category:g.k5n([m.SE.GENERAL,m.SE.COURSES,m.SE.PAYMENTS,m.SE.ENROLLMENT,m.SE.TECHNICAL,m.SE.OTHER]).optional(),order:g.aig().int().min(0).optional(),isActive:g.zMY().optional()}),o=({initialData:a,onSubmit:b,onCancel:c,isLoading:g=!1})=>{let{register:o,handleSubmit:p,setValue:q,watch:r,formState:{errors:s}}=(0,e.mN)({resolver:(0,f.u)(n),defaultValues:a?{question:a.question,answer:a.answer,category:a.category||m.SE.GENERAL,order:a.order||0,isActive:!1!==a.isActive}:{question:"",answer:"",category:m.SE.GENERAL,order:0,isActive:!0}}),t=r("category"),u=r("isActive"),v=async a=>{await b({question:a.question,answer:a.answer,category:a.category||m.SE.GENERAL,order:a.order||0,isActive:!1!==a.isActive})};return(0,d.jsx)(h.Z,{className:"p-6",children:(0,d.jsxs)("form",{onSubmit:p(v),className:"space-y-6",children:[(0,d.jsxs)("div",{children:[(0,d.jsxs)("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:["Question ",(0,d.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,d.jsx)(j.p,{...o("question"),placeholder:"Enter the question...",error:s.question?.message,maxLength:500}),(0,d.jsxs)("p",{className:"text-xs text-gray-500 mt-1",children:[r("question")?.length||0," / 500 characters"]})]}),(0,d.jsxs)("div",{children:[(0,d.jsxs)("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:["Answer ",(0,d.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,d.jsx)(l.T,{...o("answer"),placeholder:"Enter the answer...",error:s.answer?.message,rows:6})]}),(0,d.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Category"}),(0,d.jsx)(k.l,{value:t||m.SE.GENERAL,onChange:a=>q("category",a.target.value),options:(0,m.vr)()})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Display Order"}),(0,d.jsx)(j.p,{type:"number",...o("order",{valueAsNumber:!0}),placeholder:"0",error:s.order?.message,min:0}),(0,d.jsx)("p",{className:"text-xs text-gray-500 mt-1",children:"Lower numbers appear first"})]})]}),(0,d.jsx)("div",{children:(0,d.jsxs)("label",{className:"flex items-center space-x-2",children:[(0,d.jsx)("input",{type:"checkbox",checked:!1!==u,onChange:a=>q("isActive",a.target.checked),className:"w-4 h-4 text-primary-600 border-gray-300 rounded focus:ring-primary-500"}),(0,d.jsx)("span",{className:"text-sm font-medium text-gray-700",children:"Active (visible on website)"})]})}),(0,d.jsxs)("div",{className:"flex items-center justify-end space-x-4 pt-4 border-t",children:[c&&(0,d.jsx)(i.$,{type:"button",variant:"ghost",onClick:c,disabled:g,children:"Cancel"}),(0,d.jsx)(i.$,{type:"submit",isLoading:g,children:a?"Update FAQ":"Create FAQ"})]})]})})}},88954:(a,b,c)=>{c.r(b),c.d(b,{default:()=>j});var d=c(48249),e=c(67484),f=c(19099),g=c(20403),h=c(64837),i=c(91115);function j({params:a}){let b=(0,f.useRouter)(),c=(0,e.use)(a).id,[j,k]=(0,e.useState)(null),[l,m]=(0,e.useState)(!0),n=async a=>{try{await h._(c,a),(0,i.Te)("FAQ updated successfully!"),b.push("/admin/faqs")}catch(a){throw console.error("Error updating FAQ:",a),(0,i.Qg)(Object(a).message||"Failed to update FAQ"),a}};return l?(0,d.jsx)("div",{className:"flex justify-center items-center py-12",children:(0,d.jsx)("div",{className:"w-8 h-8 border-2 border-primary-600 border-t-transparent rounded-full animate-spin"})}):j?(0,d.jsxs)("div",{children:[(0,d.jsxs)("div",{className:"mb-8",children:[(0,d.jsx)("h1",{className:"text-3xl font-bold text-[var(--foreground)]",children:"Edit FAQ"}),(0,d.jsx)("p",{className:"text-[var(--muted-foreground)] mt-2",children:"Update the frequently asked question"})]}),(0,d.jsx)(g.J,{initialData:j,onSubmit:n,onCancel:()=>{b.push("/admin/faqs")}})]}):(0,d.jsx)("div",{className:"text-center py-12",children:(0,d.jsx)("p",{className:"text-gray-500",children:"FAQ not found"})})}}};