Your IP : 216.73.216.93


Current Path : /home/users/unlimited/www/admin.medimeet.codeskitter.site/assets/
Upload File :
Current File : /home/users/unlimited/www/admin.medimeet.codeskitter.site/assets/LoginScreen-JxMtYaz3.js

import{r as h,w as L,j as e,B as u,T as A,N as B,O as M,x as f,P as G,y as E,D as q,R as Q,F as O,J as H}from"./index-C50MwByD.js";import{e as J}from"./index-DRh_GsH6.js";import{u as V}from"./SettingData-DaA8YzRn.js";import{u as W}from"./UseSearchFilter-CFZNsdXS.js";import{u as _}from"./HasPermission-BP0YFq1v.js";import{V as U,A as Y,a as K,N as X,S as y,D as Z}from"./Dashboard-BGHL639E.js";import{F as $}from"./index-DHZdk_rm.js";import{a as ee,u as k,I as v}from"./index-Ntz7vSIm.js";import{h as se,u as z,M as re,b as I,a as ne,c as N,g as te,d as w,e as R,f as x}from"./index.esm-BgKkBPdO.js";import{D as F}from"./use-clickable-BAx6nmpu.js";import{I as T,F as b}from"./input-BS5AKlHW.js";import"./image-Bvdr-O-Y.js";import"./tr-DxO73Jya.js";import"./visually-hidden.style-C5P7rhbc.js";function oe({isOpen:a,onClose:r}){const[l,n]=h.useState(),[t,c]=h.useState(null),d=h.useRef(),{handleSubmit:m,reset:g}=se(),j=L(),o=z(),p=i=>{i.preventDefault();const s=i.dataTransfer.files[0];c(s)},C=i=>{i.preventDefault()},D=i=>{const s=i.target.files[0];c(s)},S=async()=>{let i={image:t};try{n(!0);const s=await G(E.token,"add_login_screen_image",i);n(!1),s.response===200?(x(o,"success","Added!"),j.invalidateQueries(["login-screen"]),g(),r()):x(o,"error",s.message)}catch(s){n(!1),x(o,"error",JSON.stringify(s))}};return e.jsxs(re,{isOpen:a,onClose:r,isCentered:!0,size:"lg",children:[e.jsx(I,{}),e.jsxs(ne,{as:"form",onSubmit:m(S),children:[e.jsx(N,{fontSize:18,py:2,children:"Add Login Screen Image"}),e.jsx(te,{}),e.jsx(F,{}),e.jsx(w,{children:e.jsx(u,{pb:3,children:e.jsx(u,{mt:5,p:4,border:"2px dashed",borderColor:"gray.300",borderRadius:"md",onDrop:p,onDragOver:C,onClick:()=>{d.current&&d.current.click()},cursor:"pointer",children:t?e.jsxs(u,{position:"relative",children:[e.jsxs(A,{children:["Selected File: ",t.name]}),e.jsx(B,{position:"absolute",right:-2,top:-2,size:"sm",onClick:()=>{c(null)}})]}):e.jsxs(u,{children:[e.jsxs(U,{children:[" ",e.jsx(T,{ref:d,type:"file",onChange:D,accept:".jpeg, .svg, .png , .jpg",mb:4})]}),e.jsxs(M,{children:[" ",e.jsx(ee,{fontSize:32})]}),e.jsxs(A,{textAlign:"center",mt:3,children:[e.jsx("b",{children:"Choose a file"})," or Drag it here."]})]})})})}),e.jsx(F,{}),e.jsxs(R,{py:3,children:[e.jsx(f,{colorScheme:"gray",mr:3,onClick:r,size:"sm",children:"Close"}),e.jsx(f,{variant:"solid",size:"sm",colorScheme:"blue",type:"submit",isLoading:l,children:"Add Login Image"})]})]})]})}function ie({isOpen:a,onClose:r,data:l}){const n=z(),t=h.useRef(),c=L(),[d,m]=h.useState(),g=async()=>{let j={id:l.id};try{m(!0);const o=await q(E.token,"delete_login_screen_image",j);m(!1),o.response===200?(x(n,"success","Deleted!"),c.invalidateQueries(["login-screen"]),r()):x(n,"error",o.message)}catch(o){m(!1),x(n,"error",JSON.stringify(o))}};return e.jsx(Y,{isOpen:a,onClose:r,leastDestructiveRef:t,isCentered:!0,children:e.jsx(I,{children:e.jsxs(K,{children:[e.jsx(N,{fontSize:"lg",fontWeight:"semi-bold",children:"Delete Login Page Image"}),e.jsx(w,{children:"Are you sure? You can not undo this action afterwards."}),e.jsxs(R,{children:[e.jsx(f,{ref:t,onClick:r,colorScheme:"gray",size:"sm",children:"Cancel"}),e.jsx(f,{colorScheme:"red",onClick:g,ml:3,size:"sm",isLoading:d,children:"Delete"})]})]})})})}function ye(){const[a,r]=h.useState(),{isOpen:l,onOpen:n,onClose:t}=k(),{hasPermission:c}=_(),{isOpen:d,onOpen:m,onClose:g}=k(),j=s=>{r(s)},o=async()=>(await H(E.token,"get_login_screen_images")).data,{data:p,isLoading:C,error:D}=V({queryKey:["login-screen"],queryFn:o}),{handleSearchChange:S,filteredData:i}=W(p);return D?e.jsx(Q,{errorCode:D.name}):c("LOGINSCREEN_VIEW")?e.jsxs(u,{children:[C||!p?e.jsxs(u,{children:[e.jsxs(b,{mb:5,justify:"space-between",children:[e.jsx(y,{w:400,h:8}),e.jsx(y,{w:200,h:8})]}),[...Array(10)].map((s,P)=>e.jsx(y,{h:10,w:"100%",mt:2},P))]}):e.jsxs(u,{children:[e.jsxs(b,{mb:5,justify:"space-between",align:"center",children:[e.jsx(T,{size:"md",placeholder:"Search",w:400,maxW:"50vw",onChange:s=>S(s.target.value)}),e.jsx(u,{children:e.jsx(f,{isDisabled:!c("LOGINSCREEN_ADD"),size:"sm",colorScheme:"blue",onClick:()=>{n()},children:"Add New"})})]}),e.jsx(Z,{minPad:"8px 8px",data:i,onActionClick:e.jsx(ae,{onClick:j,DeleteonOpen:m})})]}),l&&e.jsx(oe,{isOpen:l,onClose:t}),d&&e.jsx(ie,{isOpen:d,onClose:g,data:a})]}):e.jsx(X,{})}const ae=({onClick:a,rowData:r,DeleteonOpen:l,EditonOpen:n})=>{const{hasPermission:t}=_();return e.jsxs(b,{justify:"center",children:[t("LOGINSCREEN_UPDATE")&&e.jsx(v,{size:"sm",variant:"ghost",_hover:{background:"none"},onClick:()=>{a(r),n()},icon:e.jsx(J,{fontSize:18,color:O.colors.blue[500]}),isDisabled:!0}),e.jsx(v,{isDisabled:!t("LOGINSCREEN_DELETE"),size:"sm",variant:"ghost",_hover:{background:"none"},onClick:()=>{a(r),l()},icon:e.jsx($,{fontSize:18,color:O.colors.red[500]})})]})};export{ye as default};