import{c as u,j as t,a as i,D as z,b as D,u as O,d as v,s as M,r,e as I,g,T as B,A as P,U as w,S as E,h as k}from"./main-DCe66WO2.js";import{C as N}from"./index-B11DWR9S.js";const S=u(t.jsx("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zM4 12c0-4.42 3.58-8 8-8 1.85 0 3.55.63 4.9 1.69L5.69 16.9C4.63 15.55 4 13.85 4 12zm8 8c-1.85 0-3.55-.63-4.9-1.69L18.31 7.1C19.37 8.45 20 10.15 20 12c0 4.42-3.58 8-8 8z"}),"BlockOutlined"),T=u([t.jsx("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"},"0"),t.jsx("path",{d:"M15.97 11.03C14.87 9.79 13.28 9 11.5 9c-2.82 0-5.18 1.95-5.82 4.56l.96.32C7.15 11.66 9.13 10 11.5 10c1.51 0 2.85.68 3.76 1.74L13 14h5V9l-2.03 2.03z"},"1")],"NextPlanOutlined"),y=u(t.jsx("path",{d:"M13 8c0-2.21-1.79-4-4-4S5 5.79 5 8s1.79 4 4 4 4-1.79 4-4zm-2 0c0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2 2 .9 2 2zM1 18v2h16v-2c0-2.66-5.33-4-8-4s-8 1.34-8 4zm2 0c.2-.71 3.3-2 6-2 2.69 0 5.78 1.28 6 2H3zm17-3v-3h3v-2h-3V7h-2v3h-3v2h3v3h2z"}),"PersonAddAlt"),s={add:{name:"add",icon:t.jsx(y,{}),static:!0},edit:{name:"edit",icon:t.jsx(z,{}),label:"Редактировать"},block:{name:"block",icon:t.jsx(S,{}),label:"Забанить"},unblock:{name:"unblock",icon:t.jsx(T,{}),label:"Разбанить"},delete:{name:"delete",icon:t.jsx(D,{}),label:"Удалить"}},F=e=>{const n=e.length>1,a=!e.length||e.some(d=>d.Status!==i.Ban)?s.block:s.unblock;return{contextMenuOptions:n?[a,s.delete]:[s.edit,a,s.delete],toolbarActions:n?[{...s.add,static:!0},a,s.delete]:[{...s.add,static:!0},s.edit,a,s.delete]}};function V(){const e=O(),n=v(M),[a,d]=r.useState([]),{t:j}=I(),[f,h]=r.useState(!1),[m,p]=r.useState(null),{contextMenuOptions:x,toolbarActions:A}=F(a),C=async l=>{const o=Array.isArray(l)?l:[l],b=o.filter(c=>c.Status!==i.Ban);await Promise.all(b.length?b.map(c=>e(k({userId:c.Id,status:i.Ban})).unwrap()):o.map(c=>e(k({userId:c.Id,status:i.Active})).unwrap())),e(g())},U=({name:l,payload:o})=>{switch(l){case"add":h(!0);break;case"edit":p({user:o});break;case"block":case"unblock":C(o);break}};return r.useEffect(()=>{e(g())},[e]),r.useEffect(()=>{d([])},[n]),t.jsxs(t.Fragment,{children:[t.jsx(N,{withDropZone:!1,columns:L,rows:n,selection:a,contextMenuOptions:x,onSelectionChange:d,onActionClick:U,HeaderProps:{actionOptions:A,contextMenuOptions:x,heading:t.jsx(B,{sx:{fontSize:"1.125rem"},children:j("userMenu.users")})}}),f&&t.jsx(P,{onClose:()=>h(!1)}),!!m&&t.jsx(w,{...m,onClose:()=>p(null)})]})}const L=[{title:"Номер",locale:"number",render:({row:e})=>t.jsxs(E,{direction:"row",alignItems:"center",spacing:1,children:[t.jsx("span",{children:e.Id}),e.Status===i.Ban&&t.jsx(S,{sx:{color:"text.secondary",fontSize:20}})]})},{title:"Телефон",locale:"phone",render:({row:e})=>e.PhoneNumber},{title:"E-mail",locale:"email",render:({row:e})=>e.Email},{title:"Имя",locale:"firstName",render:({row:e})=>e.FirstName},{title:"Фамилия",locale:"surName",render:({row:e})=>e.Surname}];export{V as default};
