import{o as n,es as c,u as S,R as C,g,w as N,h as o,i as d,j as e,e9 as E,bT as u,bE as R,F as T,a3 as y,bZ as A,aR as L,ck as l}from"./app-BgLa5dit.js";import{L as M}from"./nb6O6S6P.chunk.js";import{a as O,U as _}from"./m4aqaK_l.chunk.js";import{W as k}from"./BYVfdcaw.chunk.js";import{U as w}from"./ZKp_vc-v.chunk.js";import{U as D}from"./B0F5oh6I.chunk.js";const B=T.encloseNamespace("users.customerLessUser");function q(s){var f;const a=n(c.user(s.id)),m=n(L.currentUser()),p=n(c.userPlaylistsAll(s.id)),i=n(c.getCustomers(s.id)),[,v]=S(A.BULK_REMOVE_USERS);C.useEffect(()=>{var t,r;(r=(t=i.data)==null?void 0:t.data)!=null&&r.length&&g.trigger({application:d.CUSTOMERS,action:o.Customers.EDIT_USER,args:[N.first(i.data.data).id,s.id]},{replace:!0})},[i.hasCompleted]);function U(){var r,x,h,j,b;const t=[{label:"Add to customer",appLink:{application:d.CUSTOMERS,action:o.Customers.ADD_USER_TO_CUSTOMER,args:[null,s.id]},button:!1}];return((r=a.data)==null?void 0:r.status)!==l.Inactive&&t.push({label:((x=a.data)==null?void 0:x.status)===l.Active?"Deactivate account":"Reactivate account",appLink:{application:d.CUSTOMERS,action:o.Customers.TOGGLE_USER_STATUS,args:[null,s.id]},button:!1}),t.push({label:"Delete",onClick:()=>{v({users:[a.data],totalUsers:1,redirectToSearch:!0}),g.trigger({application:d.CUSTOMERS,action:o.Customers.BULK_REMOVE_USERS,args:[null],params:{userType:a.data.userType}})},button:!1,className:`btn btn-link text-danger ${((h=a.data)==null?void 0:h.status)===l.Active?"cursor-default disabled":""}`,tooltip:((j=a.data)==null?void 0:j.status)===l.Active?"Deactivate account before deleting":null,disabled:((b=a.data)==null?void 0:b.status)===l.Active}),t}return a.hasError?e.jsx("div",{children:"User could not be found."}):!a.data||!m.data||!i.hasCompleted?e.jsx("div",{className:"py-5",children:e.jsx(E,{})}):e.jsxs(w.Provider,{value:O.Curator,children:[e.jsx(k,{children:"This user is not associated with any customers, and therefore cannot be edited. In order to edit this user, please add to a customer."}),e.jsx("div",{className:"d-flex",children:e.jsx(_,{user:a.data,currentUser:m.data,className:"mb-2"})}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Email"}),e.jsx("input",{className:"form-control",disabled:!0,value:a.data.email})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"First name"}),e.jsx("input",{className:"form-control",disabled:!0,value:a.data.name})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Last name"}),e.jsx("input",{className:"form-control",disabled:!0,value:a.data.surname})]}),a.data.userType===u.Staff&&e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Display name"}),e.jsx("input",{className:"form-control",disabled:!0,value:a.data.displayName})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Username"}),e.jsx("input",{className:"form-control",disabled:!0,value:a.data.username})]}),a.data.userType===u.Learner&&e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Year level"}),e.jsx("input",{className:"form-control",disabled:!0,value:(f=a.data.masterYearGroup)==null?void 0:f.name})]}),e.jsxs("div",{className:"d-flex justify-content-between align-items-center",children:[a.data.userType===u.Staff?e.jsxs("div",{className:"d-flex align-items-center",children:[e.jsx(R,{onClick:null,on:!1,disabled:!0}),e.jsx("span",{className:"fw-semibold ms-2",children:B("admin")})]}):e.jsx("div",{children:" "}),e.jsx(y,{actions:U(),actionsDropdownClassName:"btn btn-outline-dark"})]}),e.jsx("hr",{}),e.jsx(M,{user:a.data}),!!p.data&&e.jsx(D,{playlists:p.data})]})}export{q as CustomerlessUserView};
//# sourceMappingURL=AFHDxdzl.chunk.js.map
