(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8548],{1416:function(e,t,s){Promise.resolve().then(s.t.bind(s,231,23)),Promise.resolve().then(s.bind(s,67865))},60291:function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"RouterContext",{enumerable:!0,get:function(){return r}});let r=s(99920)._(s(2265)).default.createContext(null)},95826:function(e,t,s){"use strict";var r=s(57437);t.Z=e=>{let{label:t,type:s="text",register:i,name:a,defaultValue:l,error:n,hidden:o,inputProps:c}=e;return(0,r.jsxs)("div",{className:o?"hidden":"flex flex-col gap-2 w-full md:w-1/4",children:[(0,r.jsx)("label",{className:"text-xs text-medium-gray font-body",children:t}),(0,r.jsx)("input",{type:s,...i(a),className:"ring-[1.5px] ring-light-gray p-2 rounded-md text-sm w-full focus:ring-professional-green font-body",...c,defaultValue:l}),(null==n?void 0:n.message)&&(0,r.jsx)("p",{className:"text-xs text-red-400 font-body",children:n.message.toString()})]})}},67865:function(e,t,s){"use strict";var r=s(57437),i=s(31014),a=s(39343),l=s(95826),n=s(45238),o=s(16463),c=s(2265),d=s(95956);t.default=e=>{var t;let{type:s="create",data:u,redirectPath:m="/admin/school-life/clubs"}=e,{register:x,handleSubmit:f,formState:{errors:g}}=(0,a.cI)({resolver:(0,i.F)(n.i),defaultValues:u}),[p,b]=(0,c.useState)(!1),h=(0,o.useRouter)(),y=async e=>{b(!0);try{let t="create"===s?"/api/school-life/clubs":"/api/school-life/clubs/".concat(u.id);if(!(await fetch(t,{method:"create"===s?"POST":"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok)throw Error("Failed to save club");d.Am.success("Club ".concat("create"===s?"created":"updated"," successfully!")),h.push(m),h.refresh()}catch(e){console.error(e),d.Am.error("Something went wrong!")}finally{b(!1)}};return(0,r.jsxs)("form",{className:"flex flex-col gap-6 bg-white p-8 rounded-xl shadow-sm border border-gray-100 max-w-2xl mx-auto",onSubmit:f(y),children:[(0,r.jsx)("h1",{className:"text-xl font-semibold text-gray-800",children:"create"===s?"Create New Club":"Update Club"}),(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsx)(l.Z,{label:"Club Name",name:"name",register:x,error:g.name}),(0,r.jsxs)("div",{className:"flex flex-col gap-2 w-full md:w-1/4",children:[(0,r.jsx)("label",{className:"text-xs text-gray-500",children:"Description"}),(0,r.jsx)("textarea",{...x("description"),className:"ring-[1.5px] ring-gray-300 p-2 rounded-md text-sm w-full",rows:4}),(null===(t=g.description)||void 0===t?void 0:t.message)&&(0,r.jsx)("p",{className:"text-xs text-red-400",children:g.description.message})]})]}),(0,r.jsx)("button",{disabled:p,className:"bg-vibrant-gold hover:bg-opacity-90 text-white p-3 rounded-md transition-all font-medium disabled:opacity-50",children:p?"Saving...":"create"===s?"Create Club":"Update Club"})]})}},45238:function(e,t,s){"use strict";s.d(t,{L:function(){return i},i:function(){return a}});var r=s(59772);let i=r.z.object({title:r.z.string().min(1,{message:"Title is required"}),description:r.z.string().optional(),date:r.z.coerce.date({message:"Date is required"}),time:r.z.string().optional(),location:r.z.string().optional(),visibility:r.z.enum(["PUBLIC","CLASS_ONLY","CLUB_ONLY"],{message:"Visibility is required"})}),a=r.z.object({name:r.z.string().min(1,{message:"Club Name is required"}),description:r.z.string().optional()})}},function(e){e.O(0,[5945,231,9772,1014,2971,7023,1744],function(){return e(e.s=1416)}),_N_E=e.O()}]);