import{C as e,D as t,Et as n,K as r,M as i,U as a,b as o,c as s,gt as c,j as l,kt as u,ot as d,r as f,w as p,wt as m}from"./dist-B4ulKgpj.js";import{n as h}from"./usetoast-BF8L6V7u.js";import{t as g}from"./toast-CIOCHy8g.js";import{i as _,r as v,t as y}from"./datatable-Bx25bkl1.js";import{r as b,t as x}from"./dialog-B_jPUd8Q.js";import{t as S}from"./button-DVjHqmFH.js";import{t as C}from"./CreateArticle-B5lkGwfi.js";import{t as w}from"./DeleteArticle-BwYJaMLO.js";import{t as T}from"./UpdateArticle-BADe79ze.js";var E={class:`flex h-full flex-1 flex-col gap-4 overflow-x-auto rounded-xl p-4`},D={class:`relative flex-1 rounded-xl border border-sidebar-border/70 p-3 md:min-h-min dark:border-sidebar-border`},O={class:`mx-auto mt-4 items-center p-1`},k={class:`mb-4 flex items-center justify-between`},A={class:`rounded-b-xl border-2 border-accent-foreground pb-2 shadow-xl dark:border-0`},j={class:`flex items-center gap-2`},M=i({layout:{breadcrumbs:[{title:`Articles Management`,href:`/article-management`}]},__name:`Index`,setup(i){let M=s().props,N=h(),P=e(()=>Array.isArray(M.articles)?M.articles:M.articles?.data??[]);a(()=>{M?.success&&N.add({severity:`success`,summary:`Success`,detail:M.success,life:2500})});let F=c({openCreateArticle:!1,openUpdateArticle:!1,openDeleteArticle:!1,selectedRecord:{}}),I=(e,t)=>{F.value.selectedRecord=e,t===`create`&&(F.value.openCreateArticle=!0),t===`update`&&(F.value.openUpdateArticle=!0),t===`delete`&&(F.value.openDeleteArticle=!0)};return(e,i)=>(r(),t(o,null,[l(m(f),{title:m(M).pageTitle},null,8,[`title`]),l(m(g)),p(`div`,E,[p(`div`,D,[p(`div`,O,[p(`div`,k,[i[4]||=p(`h2`,{class:`text-xl font-light`},`Articles list`,-1),l(m(S),{label:`Article`,icon:`pi pi-plus`,onClick:i[0]||=e=>I({},`create`)})]),p(`div`,A,[l(m(y),{value:P.value,stripedRows:``,paginator:``,rows:8,rowsPerPageOptions:[8,15,30,50]},{default:d(()=>[l(m(v),{field:`title`,header:`Title`}),l(m(v),{field:`subtitle`,header:`Subtitle`}),l(m(v),{header:`Status`},{body:d(({data:e})=>[p(`span`,{class:n([`rounded-full px-2 py-1 text-xs`,e.is_active?`bg-green-100 text-green-700`:`bg-gray-200 text-gray-700`])},u(e.is_active?`Active`:`Inactive`),3)]),_:1}),l(m(v),{field:`created_at`,header:`Created At`}),l(m(v),{header:`Action`},{body:d(({data:e})=>[p(`div`,j,[l(m(S),{severity:`warn`,rounded:``,outlined:``,onClick:t=>I(e,`update`)},{default:d(()=>[l(m(_),{size:15})]),_:1},8,[`onClick`]),l(m(S),{severity:`danger`,rounded:``,outlined:``,onClick:t=>I(e,`delete`)},{default:d(()=>[l(m(b),{size:15})]),_:1},8,[`onClick`])])]),_:1})]),_:1},8,[`value`])])])])]),l(m(x),{visible:F.value.openCreateArticle,"onUpdate:visible":i[1]||=e=>F.value.openCreateArticle=e,modal:``,style:{width:`60vw`},header:`Add article`},{default:d(()=>[l(C)]),_:1},8,[`visible`]),l(m(x),{visible:F.value.openUpdateArticle,"onUpdate:visible":i[2]||=e=>F.value.openUpdateArticle=e,modal:``,style:{width:`60vw`},header:`Update article`},{default:d(()=>[l(T,{"article-details":F.value.selectedRecord},null,8,[`article-details`])]),_:1},8,[`visible`]),l(m(x),{visible:F.value.openDeleteArticle,"onUpdate:visible":i[3]||=e=>F.value.openDeleteArticle=e,modal:``,style:{width:`40vw`},header:`Delete article`},{default:d(()=>[l(w,{"article-details":F.value.selectedRecord},null,8,[`article-details`])]),_:1},8,[`visible`])],64))}});export{M as default};