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-BD_NkAgt.js";import{Bn as o,Dt as s,Fr as c,Gr as l,Jr as u,Lr as d,Pn as f,Rn as p,T as m,Vn as h,Vr as g,Vt as _,Wr as v,_n as y,ii as b,oi as x,qr as S,r as C,xr as w,zn as T}from"./mui-vendor-DsoH2_ot.js";import"./state-vendor-Cw2RdylD.js";import{D as E,k as D,rt as O,w as k,y as A}from"./index-Bo9BrBsx.js";import{n as j}from"./users.api-Bg3r8tg4.js";var M=e(x(),1),N=b(),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)(m,{fontSize:`small`})}]),()=>R([])),[R]),B)return(0,N.jsx)(d,{sx:{display:`flex`,justifyContent:`center`,alignItems:`center`,height:`100vh`},children:(0,N.jsx)(S,{})});if(V||!z)return(0,N.jsxs)(d,{sx:{p:4},children:[(0,N.jsx)(l,{severity:`error`,sx:{mb:2},children:V?.message||`Failed to load user`}),(0,N.jsx)(c,{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)(d,{sx:{display:`flex`,flexDirection:`column`,height:`100vh`,bgcolor:`#f5f5f5`},children:[(0,N.jsx)(d,{sx:A(),children:(0,N.jsx)(O,{title:`User - ${z.username}`,showBackButton:!0,onBack:()=>e(`/`),disableBox:!0,children:(0,N.jsx)(d,{sx:{display:`flex`,gap:1.5},children:H&&(0,N.jsx)(c,{variant:`outlined`,startIcon:(0,N.jsx)(_,{}),onClick:()=>e(`/settings/users/${b}${I?`?profile=true`:``}`),children:`Edit`})})})}),(0,N.jsx)(d,{sx:{flex:1,overflow:`auto`,p:3,display:`flex`,flexDirection:`column`},children:(0,N.jsxs)(u,{sx:{maxWidth:1200,mx:`auto`,p:4,width:`100%`,flex:1,display:`flex`,flexDirection:`column`},children:[(0,N.jsxs)(d,{sx:{mb:4},children:[(0,N.jsxs)(d,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`flex-start`,mb:3},children:[(0,N.jsxs)(d,{sx:{textAlign:`center`,flex:1},children:[(0,N.jsx)(d,{sx:{width:100,height:100,borderRadius:`50%`,overflow:`hidden`,border:`3px solid #006766`,display:`flex`,alignItems:`center`,justifyContent:`center`,bgcolor:`#f0f0f0`,mx:`auto`,mb:2},children:z.profilepicture?(0,N.jsx)(d,{component:`img`,src:z.profilepicture,alt:z.fullname||z.first_name,sx:{width:`100%`,height:`100%`,objectFit:`cover`}}):(0,N.jsx)(v,{variant:`h3`,sx:{color:`#bdbdbd`},children:z.first_name?.[0]?.toUpperCase()||`?`})}),(0,N.jsx)(v,{variant:`h4`,sx:{fontWeight:700,color:`#006766`,mb:1},children:z.fullname||`${z.first_name} ${z.last_name}`.trim()}),(0,N.jsxs)(v,{variant:`body1`,color:`text.secondary`,children:[`@`,z.username]})]}),(0,N.jsx)(g,{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)(w,{sx:{my:3}}),(0,N.jsx)(v,{variant:`h5`,sx:{fontWeight:600,color:`#006766`,textAlign:`center`,mb:3},children:`USER DETAILS`})]}),(0,N.jsxs)(d,{sx:{mb:4},children:[(0,N.jsx)(v,{variant:`h6`,sx:{fontWeight:600,color:`#006766`,mb:3},children:`Basic Information`}),(0,N.jsx)(p,{component:u,sx:{border:`1px solid #e0e0e0`},children:(0,N.jsx)(h,{size:`small`,children:(0,N.jsxs)(o,{children:[(0,N.jsxs)(f,{children:[(0,N.jsx)(T,{sx:P,children:`Full Name`}),(0,N.jsx)(T,{sx:F,children:z.fullname||`${z.first_name} ${z.last_name}`.trim()||`-`}),(0,N.jsx)(T,{sx:P,children:`Username`}),(0,N.jsx)(T,{sx:F,children:z.username||`-`})]}),(0,N.jsxs)(f,{children:[(0,N.jsx)(T,{sx:P,children:`Email`}),(0,N.jsx)(T,{sx:F,children:z.email||`-`}),(0,N.jsx)(T,{sx:P,children:`Phone`}),(0,N.jsx)(T,{sx:F,children:z.phone||`-`})]}),(0,N.jsxs)(f,{children:[(0,N.jsx)(T,{sx:P,children:`Gender`}),(0,N.jsx)(T,{sx:F,children:z.gender_name||`-`}),(0,N.jsx)(T,{sx:P,children:`Status`}),(0,N.jsx)(T,{sx:F,children:(0,N.jsx)(g,{label:z.is_active?`Active`:`Inactive`,color:z.is_active?`success`:`default`,size:`small`})})]})]})})})]}),(0,N.jsxs)(d,{sx:{mt:`auto`,pt:3,borderTop:`2px solid #e0e0e0`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,N.jsxs)(v,{variant:`caption`,sx:{color:`#666`},children:[`Generated on `,C(new Date,`dd-MM-yyyy, hh:mm a`)]}),(0,N.jsxs)(v,{variant:`caption`,sx:{color:`#666`},children:[`User: `,z.username,` - `,z.fullname||z.first_name]})]})]})})]})};export{I as default};