import{q as T,v as k,R as A,j as e,$ as C}from"./app-BGey7YPf.js";import{h as d,A as U}from"./app-layout-mnJEmZ7X.js";import{H as M}from"./header-D0w47C-P.js";import{D as P,a as S,b as H,c as w,d as B,e as E}from"./dialog-OAe1w9Cd.js";import{T as F,a as R,b as I,c as L,d as u,e as n,f as _,g as O,h as l}from"./table-C3FnqSRz.js";import{L as c}from"./label-BbSRpehS.js";import{I as h}from"./input-CGSIKYsG.js";import{C as $,A as q,M as z,P as G}from"./page-pagination-D1u9TBBY.js";import{u as J}from"./use-toast-DGElh_6W.js";import{T as K}from"./textarea-B31u9E-S.js";import{B as Q}from"./button-submit-end-BkQSWpq2.js";import"./button-D5r5edT8.js";import"./chevron-right-CE_1krjA.js";import"./separator-Di-l93J0.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"./select-BqSuhmAT.js";import"./index-BuSoVzfP.js";import"./chevron-down-DOZGaFlM.js";import"./trash-Blc6Iqr5.js";import"./chevron-left-7ssMp1N3.js";import"./save-Bm3_KHjE.js";function V(){J();const{applications:r,currentPage:g,perPage:j}=T().props,{data:s,setData:i,post:m,processing:f,errors:o,reset:p,transform:b}=k({id:"",name:"",slug:"",description:"",open:!1,isUpdate:!1}),[D,x]=A.useState(!1);b(a=>({...a,_method:a.isUpdate?"put":"post"}));const N=a=>{i(t=>({...t,id:a.id??"",name:a.name??"",slug:a.slug??"",description:a.description??"",open:!0,isUpdate:!0}))},v=a=>{x(!0),i(t=>({...t,id:a.id}))},y=async a=>{a.preventDefault(),s.isUpdate?m(route("apps.applications.update",s.id),{onSuccess:()=>{p(),i(t=>({...t,open:!1,isUpdate:!1}))}}):m(route("apps.applications.store"),{onSuccess:()=>{p(),i(t=>({...t,open:!1,isUpdate:!1}))}})};return e.jsxs(e.Fragment,{children:[e.jsx(C,{title:"Data Application"}),e.jsx(M,{title:"Data Application",subtitle:"Halaman ini digunakan untuk mengelola data application pengguna",children:e.jsxs(P,{open:s.open,onOpenChange:a=>i({...s,open:a,name:"",id:"",isUpdate:!1}),children:[d(["applications-create"])&&e.jsxs(S,{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($,{className:"size-4"})," ",e.jsx("span",{className:"hidden sm:inline-flex",children:"Tambah Data Application"})]}),e.jsxs(H,{className:"p-0",children:[e.jsxs(w,{className:"p-4 border-b",children:[e.jsxs(B,{children:[s.isUpdate?"Ubah":"Tambah"," Data Application"]}),e.jsxs(E,{className:"text-sm",children:["Form ini digunakan untuk ",s.isUpdate?"mengubah data application":"menambahkan data application"]})]}),e.jsx("form",{onSubmit:y,children:e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx(c,{children:"Nama Application"}),e.jsx(h,{type:"text",name:"name",value:s.name,onChange:a=>i("name",a.target.value),placeholder:"Masukkan nama application"}),e.jsx("p",{className:"text-red-500 text-xs",children:o.name})]}),e.jsxs("div",{children:[e.jsx(c,{children:"Slug"}),e.jsx(h,{type:"text",name:"slug",value:s.slug,onChange:a=>i("slug",a.target.value),placeholder:"Masukkan Slug"}),e.jsx("p",{className:"text-red-500 text-xs",children:o.slug})]}),e.jsxs("div",{children:[e.jsx(c,{children:"Deskripsi"}),e.jsx(K,{name:"description",value:s.description,onChange:a=>i("description",a.target.value)}),e.jsx("p",{className:"text-red-500 text-xs",children:o.description})]}),e.jsx(Q,{reset:p,processing:f})]})})]})]})}),e.jsxs("div",{className:"p-6",children:[e.jsx("div",{className:"mb-5",children:e.jsx(F,{withFilterPage:!0,currentPage:g,perPage:j,url:route("apps.applications.index"),placeholder:"Cari data application berdasarkan nama application"})}),e.jsx(R,{children:e.jsxs(I,{children:[e.jsx(L,{children:e.jsxs(u,{children:[e.jsx(n,{className:"w-[10px] text-center",children:"No"}),e.jsx(n,{children:"Nama"}),e.jsx(n,{children:"Slug"}),e.jsx(n,{children:"Description"}),e.jsx(n,{className:"w-[10px] text-center",children:"Aksi"})]})}),e.jsx(_,{children:r.data.length===0?e.jsx(O,{colSpan:3,message:"data application"}):r.data.map((a,t)=>e.jsxs(u,{children:[e.jsx(l,{className:"text-center",children:++t+(r.current_page-1)*r.per_page}),e.jsx(l,{children:a.name}),e.jsx(l,{children:a.slug}),e.jsx(l,{children:a.description}),e.jsx(l,{children:e.jsx("div",{className:"flex items-center justify-center",children:(d(["applications-update"])||d(["applications-delete"]))&&e.jsx(q,{permissionPrefix:"applications",isModal:!0,actionEdit:()=>N(a),actionDelete:()=>v(a)})})})]},t))})]})}),e.jsx(z,{open:D,onOpenChange:x,url:route("apps.applications.destroy",s.id)}),e.jsx(G,{data:r})]})]})}V.layout=r=>e.jsx(U,{children:r});export{V as default};
