(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1164],{72909:function(e,t,o){Promise.resolve().then(o.t.bind(o,231,23)),Promise.resolve().then(o.bind(o,55043))},60291:function(e,t,o){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"RouterContext",{enumerable:!0,get:function(){return n}});let n=o(99920)._(o(2265)).default.createContext(null)},55043:function(e,t,o){"use strict";var n=o(57437),r=o(2265),i=o(95956),l=o(16463);t.default=e=>{let{clubId:t,userId:o,membershipStatus:s}=e,[c,u]=(0,r.useState)(!1),a=(0,l.useRouter)(),d=async()=>{u(!0);try{if(!(await fetch("/api/school-life/club-membership/join",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({clubId:t})})).ok)throw Error("Failed to join");i.Am.success("Request sent!"),a.refresh()}catch(e){i.Am.error("Error joining club")}finally{u(!1)}},b=async()=>{if(confirm("Are you sure you want to leave this club?")){u(!0);try{if(!(await fetch("/api/school-life/club-membership/leave",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({clubId:t})})).ok)throw Error("Failed to leave");i.Am.success("Left club successfully"),a.refresh()}catch(e){i.Am.error("Error leaving club")}finally{u(!1)}}};return"APPROVED"===s?(0,n.jsx)("button",{onClick:b,disabled:c,className:"px-6 py-2 bg-red-100 text-red-700 rounded-lg hover:bg-red-200 transition-colors font-medium",children:c?"Processing...":"Leave Club"}):"PENDING"===s?(0,n.jsx)("button",{disabled:!0,className:"px-6 py-2 bg-yellow-100 text-yellow-700 rounded-lg font-medium opacity-70 cursor-not-allowed",children:"Request Pending"}):(0,n.jsx)("button",{onClick:d,disabled:c,className:"px-6 py-2 bg-vibrant-gold text-white rounded-lg hover:bg-opacity-90 transition-colors font-medium",children:c?"Joining...":"Join Club"})}}},function(e){e.O(0,[5945,231,2971,7023,1744],function(){return e(e.s=72909)}),_N_E=e.O()}]);