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