1import{r as l,c as j,e as f,j as e,F as U,B as w,T as d,A as P,k as T,a4 as $,a5 as L,a6 as R,a3 as k,aj as m,a as W,i as G,ab as c,H as I,C as _}from"./index-DWQbq_Uo.js";import{C as z}from"./Card-Bc6ZyAVD.js";import{C as H}from"./CardContent-8KEVlnWT.js";import{F as N}from"./FormGroup-DSbbM_ZR.js";import{F as C}from"./FormControlLabel-CtMMxhjV.js";import{C as y}from"./Checkbox-BtmEmZTJ.js";import{C as D}from"./CircularProgress-DfffzK2t.js";function M(){const[u,x]=l.useState(""),[a,A]=l.useState("block"),[r,i]=l.useState([]),[h,b]=l.useState(!1),[n,v]=l.useState([]),[S,p]=l.useState(!0),g=l.useCallback(async()=>{try{p(!0);const s=await j(`${f.admin.apps}?section=admin`,"GET");if(s&&s.status==="success"&&s.data){const t=s.data.filter(o=>o.block_account_url).map(o=>({id:o.app_id,name:o.name}));v(t)}}catch(s){console.error("Error fetching apps:",s)}finally{p(!1)}},[]);l.useEffect(()=>{g()},[g]);const F=s=>{i(t=>t.includes(s)?t.filter(o=>o!==s):[...t,s])},B=()=>{r.length===n.length?i([]):i(n.map(s=>s.id))},E=async s=>{if(s.preventDefault(),!u){c.error("Please enter an email address");return}if(r.length===0){c.error("Please select at least one application");return}try{b(!0);const t=await j(f.admin.blockEmail,"PUT",{email:u,action:a,apps:r});t&&t.status==="success"?(c.success(`Customer ${a}ed successfully in selected applications`),x(""),i([])):c.error((t==null?void 0:t.message)||`Failed to ${a} customer`)}catch(t){console.error(`Error ${a}ing customer:`,t),c.error(`Failed to ${a} customer`)}finally{b(!1)}};return e.jsxs(U,{maxWidth:"sm",children:[e.jsxs(w,{sx:{mb:5},children:[e.jsx(d,{variant:"h4",sx:{mb:1},children:"Block/Unblock Customer"}),e.jsx(d,{variant:"body2",color:"text.secondary",children:"Block or unblock customer access at application level"})]}),e.jsx(z,{children:e.jsxs(H,{children:[e.jsxs(P,{severity:"warning",sx:{mb:3},children:["This action will ",a," the customer's access to the selected applications."]}),e.jsxs("form",{onSubmit:E,children:[e.jsx(T,{fullWidth:!0,label:"Customer Email",type:"email",value:u,onChange:s=>x(s.target.value),placeholder:"Enter customer email address",sx:{mb:3}}),e.jsxs($,{fullWidth:!0,sx:{mb:3},children:[e.jsx(L,{children:"Action"}),e.jsxs(R,{value:a,label:"Action",onChange:s=>A(s.target.value),children:[e.jsx(k,{value:"block",children:"Block"}),e.jsx(k,{value:"unblock",children:"Unblock"})]})]}),e.jsx(d,{variant:"subtitle2",sx:{mb:1},children:"Select Applications"}),e.jsx(N,{sx:{mb:3},children:S?e.jsxs(e.Fragment,{children:[e.jsx(m,{variant:"rectangular",height:32,sx:{mb:1,borderRadius:1}}),e.jsx(m,{variant:"rectangular",height:32,sx:{mb:1,ml:2,borderRadius:1}}),e.jsx(m,{variant:"rectangular",height:32,sx:{mb:1,ml:2,borderRadius:1}}),e.jsx(m,{variant:"rectangular",height:32,sx:{ml:2,borderRadius:1}})]}):n.length===0?e.jsx(d,{variant:"body2",color:"text.secondary",children:"No applications with block functionality configured"}):e.jsxs(e.Fragment,{children:[e.jsx(C,{control:e.jsx(y,{checked:r.length===n.length&&n.length>0,indeterminate:r.length>0&&r.length<n.length,onChange:B}),label:"Select All"}),n.map(s=>e.jsx(C,{control:e.jsx(y,{checked:r.includes(s.id),onChange:()=>F(s.id)}),label:s.name,sx:{ml:2}},s.id))]})}),e.jsx(W,{fullWidth:!0,size:"large",type:"submit",variant:"contained",color:a==="block"?"error":"success",disabled:h,startIcon:h?e.jsx(D,{size:20,color:"inherit"}):e.jsx(G,{icon:a==="block"?"mdi:block-helper":"mdi:check-circle"}),children:h?"Processing...":a==="block"?"Block Customer":"Unblock Customer"})]})]})})]})}function Y(){return e.jsxs(e.Fragment,{children:[e.jsx(I,{children:e.jsx("title",{children:`Admin - Block/Unblock - ${_.site.name}`})}),e.jsx(M,{})]})}export{Y as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.