import{D as e,E as t,K as n,M as r,U as i,b as a,c as o,gt as s,j as c,ot as l,r as u,w as d,wt as f}from"./dist-B4ulKgpj.js";import{n as p}from"./usetoast-BF8L6V7u.js";import{t as m}from"./toast-CIOCHy8g.js";import{i as h,r as g,t as _}from"./datatable-Bx25bkl1.js";import{r as v,t as y}from"./dialog-B_jPUd8Q.js";import{t as b}from"./button-DVjHqmFH.js";import{t as x}from"./CreateUser-CZav0HBU.js";import{t as S}from"./DeleteUser-BDUgYghH.js";import{t as C}from"./UpdateUser-Cc2yJ0Q6.js";var w={class:`flex h-full flex-1 flex-col gap-4 overflow-x-auto rounded-xl p-4`},T={class:`relative flex-1 rounded-xl border border-sidebar-border/70 p-3 md:min-h-min dark:border-sidebar-border`},E={class:`mx-auto mt-4 items-center p-1`},D={class:`mb-4 flex items-center justify-between`},O={class:`create-btn`},k={class:`rounded-b-xl border-2 border-accent-foreground pb-2 shadow-xl dark:border-0`},A={key:0,class:`grid items-center gap-2`},j={class:`flex items-center gap-2`},M=r({layout:{breadcrumbs:[{title:`User Management`,href:`/user-management`}]},__name:`Index`,setup(r){let M=o().props,N=p(),P=(e,t)=>{let n=[`success`,`error`,`info`].includes(e)?e:`info`;N.add({severity:n,summary:{success:`Success`,error:`Error`,info:`Notice`}[n],detail:t,life:3e3})};i(e=>{e?.props?.success&&P(e.props.success)});let F=s({openCreateUser:!1,openUpdateUser:!1,openDeleteUser:!1,selectedRecord:{}}),I=(e,t)=>{F.value.selectedRecord=e,t===`update user`?F.value.openUpdateUser=!0:t===`create user`?F.value.openCreateUser=!0:t===`delete user`&&(F.value.openDeleteUser=!0)};return(r,i)=>(n(),e(a,null,[c(f(u),{title:f(M).pageTitle},null,8,[`title`]),c(f(m)),d(`div`,w,[d(`div`,T,[d(`div`,E,[d(`div`,D,[i[4]||=d(`h2`,{class:`text-xl font-light`},`System users list`,-1),d(`div`,O,[c(f(b),{label:`User`,icon:`pi pi-plus`,onClick:i[0]||=e=>I({},`create user`)})])]),d(`div`,k,[c(f(_),{value:f(M).users.data,stripedRows:``,paginator:``,rows:5,rowsPerPageOptions:[5,10,20,50]},{default:l(()=>[c(f(g),{field:`first_name`,header:`First name`}),c(f(g),{field:`middle_name`,header:`Middle name`}),c(f(g),{field:`last_name`,header:`Last name`}),c(f(g),{field:`email`,header:`User Email`}),c(f(g),{field:`user_role`,header:`User Role`}),c(f(g),{header:`Action`},{body:l(({data:r})=>[r.user_role===`Super Admin`?t(``,!0):(n(),e(`div`,A,[d(`div`,j,[c(f(b),{as:`a`,severity:`warn`,href:`#`,rounded:``,outlined:``,onClick:e=>I(r,`update user`)},{default:l(()=>[c(f(h),{size:15})]),_:1},8,[`onClick`]),c(f(b),{as:`a`,severity:`danger`,href:`#`,rounded:``,outlined:``,onClick:e=>I(r,`delete user`)},{default:l(()=>[c(f(v),{size:15})]),_:1},8,[`onClick`])])]))]),_:1})]),_:1},8,[`value`])])])])]),c(f(y),{visible:F.value.openCreateUser,"onUpdate:visible":i[1]||=e=>F.value.openCreateUser=e,modal:``,style:{width:`60vw`},header:`Add new user`},{default:l(()=>[c(x)]),_:1},8,[`visible`]),c(f(y),{visible:F.value.openUpdateUser,"onUpdate:visible":i[2]||=e=>F.value.openUpdateUser=e,modal:``,style:{width:`60vw`},header:`Update user details`},{default:l(()=>[c(C,{"user-details":F.value.selectedRecord},null,8,[`user-details`])]),_:1},8,[`visible`]),c(f(y),{visible:F.value.openDeleteUser,"onUpdate:visible":i[3]||=e=>F.value.openDeleteUser=e,modal:``,style:{width:`60vw`},header:`Delete user details`},{default:l(()=>[c(S,{"user-details":F.value.selectedRecord},null,8,[`user-details`])]),_:1},8,[`visible`])],64))}});export{M as default};