import{q as N,v as T,R as v,j as e,$ as A}from"./app-BGey7YPf.js";import{h as n,A as P}from"./app-layout-mnJEmZ7X.js";import{H as U}from"./header-D0w47C-P.js";import{D as C,a as L,b as M,c as H,d as w,e as F}from"./dialog-OAe1w9Cd.js";import{T as R,a as $,b as E,c as S,d as x,e as o,f as B,g as O,h as d}from"./table-C3FnqSRz.js";import{C as q,A as z,M as I,P as G}from"./page-pagination-D1u9TBBY.js";import J from"./link-form-CuKAN7se.js";import"./button-D5r5edT8.js";import"./chevron-right-CE_1krjA.js";import"./separator-Di-l93J0.js";import"./input-CGSIKYsG.js";import"./icons-hx7HvmR4.js";import"./index-BFyaOBDQ.js";import"./x-C4WIHhXm.js";import"./index-Q2wK6uZI.js";import"./index-CwO5dfCw.js";import"./theme-provider-NKMbg-kV.js";import"./use-toast-DGElh_6W.js";import"./select-BqSuhmAT.js";import"./index-BuSoVzfP.js";import"./chevron-down-DOZGaFlM.js";import"./trash-Blc6Iqr5.js";import"./chevron-left-7ssMp1N3.js";import"./label-BbSRpehS.js";import"./input-select-DHdS_tES.js";import"./search-CA9JuCC9.js";import"./button-submit-end-BkQSWpq2.js";import"./save-Bm3_KHjE.js";function K(){const{links:t,linkProfile:i,lembagas:h,currentPage:p,perPage:m}=N().props,{data:a,setData:r,post:u,processing:g,errors:k,reset:c,transform:_}=T({id:"",link_npsn:i.link_profile_npsn,title:"",url:"",link_profile_id:i.id,icon:"",is_cbt_offline:!1,is_active:!1,is_safemode:!1,order:"",bg_color:"",open:!1,isUpdate:!1}),[b,f]=v.useState(!1);_(s=>({...s,_method:s.isUpdate?"put":"post"}));const j=s=>{r({...a,id:s.id,link_profile_id:i.id,link_npsn:i.link_profile_npsn,title:s.title,url:s.url,icon:s.icon,is_cbt_offline:s.is_cbt_offline||!1,is_active:s.is_active||!1,is_safemode:s.is_safemode||!1,order:s.order,bg_color:s.bg_color,open:!0,isUpdate:!0})},D=s=>{f(!0),r({...a,id:s.id,link_profile_id:i.id})},y=async s=>{s.preventDefault();const l=a.isUpdate?route("apps.links.update",a.id):route("apps.links.store");u(l,{onSuccess:()=>{c(),r({...a,open:!1,isUpdate:!1})}})};return e.jsxs(e.Fragment,{children:[e.jsx(A,{title:`Link Akses ${i.lembaga.name}`}),e.jsx(U,{title:`Link Akses ${i.lembaga.name}`,subtitle:"Halaman ini digunakan untuk mengelola data link akses pengguna",children:e.jsxs(C,{open:a.open,onOpenChange:s=>r({...a,open:s,id:"",link_npsn:i.link_profile_npsn,title:"",url:"",link_profile_id:i.id,icon:"",is_cbt_offline:!1,is_active:!1,is_safemode:!1,order:"",bg_color:"",isUpdate:!1}),children:[n(["links-create"])&&e.jsxs(L,{className:"px-4 py-2 flex items-center gap-2 rounded-lg text-sm font-semibold text-gray-700 border hover:bg-gray-100 dark:text-gray-200 dark:hover:bg-gray-900 dark:border-gray-800 focus:outline-none",children:[e.jsx(q,{className:"size-4"}),e.jsx("span",{className:"hidden sm:inline-flex",children:"Tambah Link Akses"})]}),e.jsxs(M,{className:"p-0",children:[e.jsxs(H,{className:"p-4 border-b",children:[e.jsxs(w,{children:[a.isUpdate?"Ubah":"Tambah"," Link Akses"]}),e.jsxs(F,{className:"text-sm",children:["Form ini digunakan untuk ",a.isUpdate?"mengubah":"menambahkan"," data link akses"]})]}),e.jsx(J,{data:a,errors:k,processing:g,setData:r,storeData:y,reset:c,link_profile_id:i.id,lembagasData:h})]})]})}),e.jsxs("div",{className:"p-6",children:[e.jsx("div",{className:"mb-5",children:e.jsx(R,{withFilterPage:!0,currentPage:p,perPage:m,url:route("apps.links.show-by-id",{id:1}),placeholder:"Cari data link akses berdasarkan nama link akses"})}),e.jsx($,{children:e.jsxs(E,{children:[e.jsx(S,{children:e.jsxs(x,{children:[e.jsx(o,{className:"w-[10px] text-center",children:"No"}),e.jsx(o,{children:"Nama Link Akses"}),e.jsx(o,{className:"w-[10px] text-center",children:"Aksi"})]})}),e.jsx(B,{children:t.data.length===0?e.jsx(O,{colSpan:3,message:"data link akses"}):t.data.map((s,l)=>e.jsxs(x,{children:[e.jsx(d,{className:"text-center",children:++l+(p-1)*m}),e.jsx(d,{children:s.title}),e.jsx(d,{children:e.jsx("div",{className:"flex items-center justify-center",children:(n(["links-update"])||n(["links-delete"]))&&e.jsx(z,{permissionPrefix:"links",isModal:!0,actionEdit:()=>j(s),actionDelete:()=>D(s)})})})]},l))})]})}),e.jsx(I,{open:b,onOpenChange:f,url:route("apps.links.destroy",a.id)}),e.jsx(G,{data:t.meta})]})]})}K.layout=t=>e.jsx(P,{children:t});export{K as default};
