import{r as h,a as Q,c as R,j as e,v as $,I as q,i as D,n as H}from"./index-7c7a558c.js";import{B as J}from"./Breadcrumb-21e99ae5.js";import{D as K,T as O}from"./TrashIcon-29561c1e.js";import{d as P,p as V,g as W}from"./gmeetApi-2aebdc2b.js";import{A as X}from"./AddGmeetModal-4839e9a2.js";import"./Group-801c960a.js";import"./DateTimePicker-c2803477.js";import"./use-input-props-204952af.js";import"./Input-dba39f11.js";import"./Text-77f3b40c.js";import"./CheckboxIcon-894be226.js";const ne=()=>{var m,j,f,b,u,N,y,g,w,v,k,A,F,G,I,S,T,E,L,M;const[n,z]=h.useState(25),B=25,o=5,{data:t,isLoading:r,isError:U,isFetching:_,error:x,refetch:i}=Q("getAdminGmeet",()=>W({count:n}),{onError:s=>{var a,c,d,C;(c=(a=s==null?void 0:s.response)==null?void 0:a.data)!=null&&c.error&&H.error((C=(d=s==null?void 0:s.response)==null?void 0:d.data)==null?void 0:C.error)}}),p=R();h.useEffect(()=>{const s=localStorage.getItem("token"),a=localStorage.getItem("user");s&&a||p("/login")},[p]),h.useEffect(()=>{i()},[n,i]);let l=null;return r&&(l=e.jsx("tr",{className:"section-bg border-b dark:text-white",children:e.jsx("td",{colSpan:o,className:"text-center text-white",children:e.jsx("div",{className:"text-center flex justify-center items-center my-6",children:e.jsx(D,{color:"white",size:"lg",variant:"dots"})})})})),!r&&U&&(l=e.jsx("tr",{className:"section-bg border-b dark:text-white",children:e.jsx("td",{colSpan:o,className:"text-center text-white py-6",children:`${(j=(m=x==null?void 0:x.response)==null?void 0:m.data)==null?void 0:j.error}`})})),!r&&((u=(b=(f=t==null?void 0:t.data)==null?void 0:f.data)==null?void 0:b.meets)==null?void 0:u.length)===0&&(l=e.jsx("tr",{className:"section-bg border-b dark:text-white",children:e.jsx("td",{colSpan:o,className:"text-center text-white py-6",children:"No Gmeet Found!"})})),!r&&((g=(y=(N=t==null?void 0:t.data)==null?void 0:N.data)==null?void 0:y.meets)==null?void 0:g.length)>0&&(l=(k=(v=(w=t==null?void 0:t.data)==null?void 0:w.data)==null?void 0:v.meets)==null?void 0:k.map((s,a)=>{var c,d;return e.jsxs("tr",{className:"section-bg border-b dark:text-white",children:[e.jsx("td",{"data-label":"Serial",className:"px-6 py-4",children:a+1}),e.jsxs("td",{"data-label":"User",className:"px-6 py-4",children:[e.jsxs("p",{children:["Name: ",(c=s==null?void 0:s.user)==null?void 0:c.name]}),e.jsx("br",{}),e.jsxs("p",{children:["ID: ",(d=s==null?void 0:s.user)==null?void 0:d.referral_code]}),e.jsx("br",{})]}),e.jsx("td",{"data-label":"Time",className:"px-6 py-4",children:s==null?void 0:s.time}),e.jsx("td",{"data-label":"Meet Link",className:"px-6 py-4",children:s==null?void 0:s.meetlink}),e.jsx("td",{"data-label":"Created Time",className:"px-6 py-4",children:$(s==null?void 0:s.created_at)}),e.jsx("td",{"data-label":"Action",className:"px-6 py-4",children:e.jsx("div",{className:"flex items-center justify-end gap-2",children:e.jsx(K,{buttonText:e.jsx(O,{}),mutationFn:P,deleteId:s==null?void 0:s.id,refetchFn:i})})})]},a)})),e.jsxs(e.Fragment,{children:[e.jsx(J,{title:"Gmeet"}),e.jsxs("div",{className:"container mx-auto my-5 p-5",children:[!r&&e.jsx("div",{className:"my-4",children:e.jsx(X,{refetchFn:i,mutationFn:V})}),e.jsxs("div",{className:"relative overflow-x-auto p-2 table-wrapper bg-gradient-to-r from-main to-second shadow-md border-dashed border rounded-tr-xl rounded-bl-xl",children:[e.jsx(q,{dataLength:(G=(F=(A=t==null?void 0:t.data)==null?void 0:A.data)==null?void 0:F.meets)!=null&&G.length?(T=(S=(I=t==null?void 0:t.data)==null?void 0:I.data)==null?void 0:S.meets)==null?void 0:T.length:0,next:()=>{z(s=>s+B)},hasMore:((M=(L=(E=t==null?void 0:t.data)==null?void 0:E.data)==null?void 0:L.meets)==null?void 0:M.length)==n,children:e.jsxs("table",{className:"w-full text-sm text-left text-gray-500 dark:text-gray-400",children:[e.jsx("thead",{className:"text-xs text-gray-700 uppercase bg-white text-black",children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",className:"p-4",children:"Serial"}),e.jsx("th",{scope:"col",className:"p-4",children:"User"}),e.jsx("th",{scope:"col",className:"p-4",children:"Time"}),e.jsx("th",{scope:"col",className:"px-6 py-3",children:"Meet Link"}),e.jsx("th",{scope:"col",className:"px-6 py-3",children:"Created Time"}),e.jsx("th",{scope:"col",className:"px-6 py-3",children:"Action"})]})}),e.jsx("tbody",{children:l})]})}),_&&e.jsx("div",{className:"text-center flex justify-center items-center my-6",children:e.jsx(D,{color:"white",size:"lg",variant:"dots"})})]})]})]})};export{ne as default};
