import{r as w,o as p,b as y,j as t,M as k,n as s}from"./index-7c7a558c.js";import{k as j}from"./studentApi-784cfec0.js";import{o as v}from"./ObjectToFormData-bf0af219.js";import{G as N}from"./Group-801c960a.js";function q({userId:d,buttonText:c,refetchFn:g}){const[i,m]=w.useState(""),[b,{open:f,close:r}]=p(!1),{isLoading:l,mutate:x}=y(j,{onSuccess:e=>{var n,o;(n=e==null?void 0:e.data)!=null&&n.success&&(s.success((o=e==null?void 0:e.data)==null?void 0:o.success),g(),r())},onError:e=>{var n,o,u,h;(o=(n=e==null?void 0:e.response)==null?void 0:n.data)!=null&&o.error?s.error((h=(u=e==null?void 0:e.response)==null?void 0:u.data)==null?void 0:h.error):s.error("something went wrong")}}),a=e=>{if(e.preventDefault(),s.dismiss(),!i)return s.error("Text field is required"),!1;l||x({formdata:{id:d,text:i}})};return t.jsxs(t.Fragment,{children:[t.jsx(k,{opened:b,onClose:r,title:"Send Request To Admin",centered:!0,classNames:{content:"bg-gray-900 text-white",header:"bg-gray-900 text-white"},children:t.jsxs("div",{className:"my-10",children:[t.jsx("div",{className:"relative z-0 w-full mb-6 group",children:t.jsx("textarea",{name:"floating_text",id:"floating_text",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500",onChange:e=>m(e.target.value),placeholder:"Type your message...",required:!0})}),t.jsx("div",{className:"flex gap-4 my-4",children:t.jsx("button",{className:"text-white bg-amber-500 hover:bg-amber-600 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:focus:ring-blue-800",onClick:e=>a(e),children:l?"Sending...":"Send"})})]})}),t.jsx("button",{onClick:f,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 px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800",children:c})]})}function A({buttonText:d,className:c,mutationFn:g,refetchFn:i,studentId:m}){const[b,{open:f,close:r}]=p(!1),{isLoading:l,mutate:x}=y(g,{onSuccess:()=>{r(),i(),s.dismiss(),s.success("Successfully status updated!")},onError:a=>{var e,n,o,u;s.dismiss(),(n=(e=a==null?void 0:a.response)==null?void 0:e.data)!=null&&n.error?s.error((u=(o=a==null?void 0:a.response)==null?void 0:o.data)==null?void 0:u.error):s.error("something went wrong. Please try again")}});return t.jsxs(t.Fragment,{children:[t.jsxs(k,{opened:b,onClose:r,title:"Confirmation",centered:!0,classNames:{content:"bg-gray-900 text-white",header:"bg-gray-900 text-white"},children:[t.jsx("p",{children:"Are you sure?"}),t.jsxs("div",{className:"flex gap-4 my-4",children:[t.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:()=>x({formdata:v({id:m,status:1})}),children:l?"Updating...":"Update"}),t.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"})]})]}),t.jsx(N,{position:"center",children:t.jsx("button",{onClick:f,className:c,children:d})})]})}export{A as M,q as S};
