import{o as e}from"./rolldown-runtime-GyhWBpbT.js";import{F as t,I as n,L as r,O as i,s as a}from"./react-vendor-DoSylNpz.js";import{Bt as o,Et as s,Fr as c,Gr as l,Hr as u,In as d,Kr as f,Ln as p,Mn as m,Nr as h,Rn as g,T as _,Ur as v,hn as y,ii as b,ni as x,r as S,yr as C,zn as w,zr as T}from"./mui-vendor-1IGyn9nW.js";import"./state-vendor-bhJgZEQG.js";import{D as E,k as D,nt as O,w as k,y as A}from"./index-BD_w4_v3.js";import{n as j}from"./users.api-CmOex6ia.js";var M=e(b(),1),N=x(),P={fontWeight:600,bgcolor:`#f8f9fa`,width:`20%`,border:`1px solid #e0e0e0`},F={width:`30%`,border:`1px solid #e0e0e0`},I=()=>{let e=t(),{id:b}=n(),[x]=r(),I=x.get(`profile`)===`true`,L=i(e=>e.auth.user),{setBreadcrumbs:R}=E();k(`User View`);let{data:z,isLoading:B,error:V}=a({queryKey:[`user`,b],queryFn:()=>j.get(b),enabled:!!b});if((0,M.useEffect)(()=>(R([{label:`Home`,path:`/`,icon:(0,N.jsx)(s,{fontSize:`small`})},{label:`View`,icon:(0,N.jsx)(_,{fontSize:`small`})}]),()=>R([])),[R]),B)return(0,N.jsx)(c,{sx:{display:`flex`,justifyContent:`center`,alignItems:`center`,height:`100vh`},children:(0,N.jsx)(l,{})});if(V||!z)return(0,N.jsxs)(c,{sx:{p:4},children:[(0,N.jsx)(v,{severity:`error`,sx:{mb:2},children:V?.message||`Failed to load user`}),(0,N.jsx)(h,{variant:`contained`,startIcon:(0,N.jsx)(y,{}),onClick:()=>e(`/settings/users`),children:`Back to List`})]});let H=D(L,`change_user`);return(0,N.jsxs)(c,{sx:{display:`flex`,flexDirection:`column`,height:`100vh`,bgcolor:`#f5f5f5`},children:[(0,N.jsx)(c,{sx:A(),children:(0,N.jsx)(O,{title:`User - ${z.username}`,showBackButton:!0,onBack:()=>e(`/`),disableBox:!0,children:(0,N.jsx)(c,{sx:{display:`flex`,gap:1.5},children:H&&(0,N.jsx)(h,{variant:`outlined`,startIcon:(0,N.jsx)(o,{}),onClick:()=>e(`/settings/users/${b}${I?`?profile=true`:``}`),children:`Edit`})})})}),(0,N.jsx)(c,{sx:{flex:1,overflow:`auto`,p:3,display:`flex`,flexDirection:`column`},children:(0,N.jsxs)(f,{sx:{maxWidth:1200,mx:`auto`,p:4,width:`100%`,flex:1,display:`flex`,flexDirection:`column`},children:[(0,N.jsxs)(c,{sx:{mb:4},children:[(0,N.jsxs)(c,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`flex-start`,mb:3},children:[(0,N.jsxs)(c,{sx:{textAlign:`center`,flex:1},children:[(0,N.jsx)(u,{variant:`h4`,sx:{fontWeight:700,color:`#006766`,mb:1},children:z.fullname||`${z.first_name} ${z.last_name}`.trim()}),(0,N.jsxs)(u,{variant:`body1`,color:`text.secondary`,children:[`@`,z.username]})]}),(0,N.jsx)(T,{label:z.is_active?`Active`:`Inactive`,sx:{backgroundColor:z.is_active?`#d4edda`:`#e2e3e5`,color:z.is_active?`#155724`:`#383d41`,fontWeight:700,fontSize:`1rem`,height:40,px:2}})]}),(0,N.jsx)(C,{sx:{my:3}}),(0,N.jsx)(u,{variant:`h5`,sx:{fontWeight:600,color:`#006766`,textAlign:`center`,mb:3},children:`USER DETAILS`})]}),(0,N.jsxs)(c,{sx:{mb:4},children:[(0,N.jsx)(u,{variant:`h6`,sx:{fontWeight:600,color:`#006766`,mb:3},children:`Basic Information`}),(0,N.jsx)(d,{component:f,sx:{border:`1px solid #e0e0e0`},children:(0,N.jsx)(w,{size:`small`,children:(0,N.jsxs)(g,{children:[(0,N.jsxs)(m,{children:[(0,N.jsx)(p,{sx:P,children:`Full Name`}),(0,N.jsx)(p,{sx:F,children:z.fullname||`${z.first_name} ${z.last_name}`.trim()||`-`}),(0,N.jsx)(p,{sx:P,children:`Username`}),(0,N.jsx)(p,{sx:F,children:z.username||`-`})]}),(0,N.jsxs)(m,{children:[(0,N.jsx)(p,{sx:P,children:`Email`}),(0,N.jsx)(p,{sx:F,children:z.email||`-`}),(0,N.jsx)(p,{sx:P,children:`Phone`}),(0,N.jsx)(p,{sx:F,children:z.phone||`-`})]}),(0,N.jsxs)(m,{children:[(0,N.jsx)(p,{sx:P,children:`Gender`}),(0,N.jsx)(p,{sx:F,children:z.gender_name||`-`}),(0,N.jsx)(p,{sx:P,children:`Status`}),(0,N.jsx)(p,{sx:F,children:(0,N.jsx)(T,{label:z.is_active?`Active`:`Inactive`,color:z.is_active?`success`:`default`,size:`small`})})]})]})})})]}),(0,N.jsxs)(c,{sx:{mt:`auto`,pt:3,borderTop:`2px solid #e0e0e0`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,N.jsxs)(u,{variant:`caption`,sx:{color:`#666`},children:[`Generated on `,S(new Date,`dd-MM-yyyy, hh:mm a`)]}),(0,N.jsxs)(u,{variant:`caption`,sx:{color:`#666`},children:[`User: `,z.username,` - `,z.fullname||z.first_name]})]})]})})]})};export{I as default};