import{o as v,r as k,b as C,j as s,M as N,n as t}from"./index-7c7a558c.js";import{o as S}from"./ObjectToFormData-bf0af219.js";import{S as _}from"./Select-ab198925.js";import{G as M}from"./Group-801c960a.js";function $({buttonText:l,buttonTexting:d,className:c,mutationFn:m,refetchFn:b,studentId:g,status:x,leadersArr:f}){const[h,{open:p,close:r}]=v(!1),[n,w]=k.useState(null),{isLoading:j,mutate:y}=C(m,{onSuccess:()=>{r(),b(),t.dismiss(),t.success("Successfully status updated!")},onError:e=>{var a,o,u,i;t.dismiss(),(o=(a=e==null?void 0:e.response)==null?void 0:a.data)!=null&&o.error?t.error((i=(u=e==null?void 0:e.response)==null?void 0:u.data)==null?void 0:i.error):t.error("something went wrong. Please try again")}});return s.jsxs(s.Fragment,{children:[s.jsxs(N,{opened:h,onClose:r,title:"Confirmation",centered:!0,classNames:{content:"bg-gray-900 text-white",header:"bg-gray-900 text-white"},children:[s.jsx("p",{children:"Are you sure you want to approve this student?"}),s.jsx("div",{className:"my-10 text-white",children:s.jsx(_,{searchable:!0,data:f.map(e=>({value:`${e.id}`,label:`${e==null?void 0:e.name} ID: ( ${e==null?void 0:e.referral_code} )`})),value:n,onChange:e=>w(e),classNames:{input:"text-white bg-slate-500"},filter:(e,a)=>a.label.toLowerCase().includes(e.toLowerCase().trim()),dropdownPosition:"bottom",required:!0})}),s.jsxs("div",{className:"flex gap-4 my-4",children:[s.jsx("button",{type:"submit",className:"text-white bg-amber-400 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm w-full sm:w-auto px-5 py-2.5 text-center dark:bg-amber-400 dark:hover:bg-amber-400 dark:focus:ring-blue-800",onClick:()=>y({formdata:S({student_id:g,status:x,leader_id:n,approved:1})}),children:j?d:l}),s.jsx("button",{type:"submit",className:"text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm w-full sm:w-auto px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800",onClick:r,children:"Cancel"})]})]}),s.jsx(M,{position:"center",children:s.jsx("button",{onClick:p,className:c,children:l})})]})}export{$ as A};
