import{r as t,j as e,L as w,S as m}from"./app-Ba0W75t8.js";import{B as o}from"./createLucideIcon-B8lpabTL.js";import{D as y,a as N,b as k,c as S,d as C}from"./dialog-DT3e4Gqi.js";import{A}from"./app-layout-CQ3rupMj.js";import"./index-KiD9fq9D.js";import"./index-avNvMDmS.js";import"./app-logo-icon-Ew5bYuZS.js";import"./index-CZsJ6L7B.js";function E({title:i,titleId:a,...n},r){return t.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":a},n),i?t.createElement("title",{id:a},i):null,t.createElement("path",{d:"m2.695 14.762-1.262 3.155a.5.5 0 0 0 .65.65l3.155-1.262a4 4 0 0 0 1.343-.886L17.5 5.501a2.121 2.121 0 0 0-3-3L3.58 13.419a4 4 0 0 0-.885 1.343Z"}))}const D=t.forwardRef(E);function _({title:i,titleId:a,...n},r){return t.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":a},n),i?t.createElement("title",{id:a},i):null,t.createElement("path",{fillRule:"evenodd",d:"M8.75 1A2.75 2.75 0 0 0 6 3.75v.443c-.795.077-1.584.176-2.365.298a.75.75 0 1 0 .23 1.482l.149-.022.841 10.518A2.75 2.75 0 0 0 7.596 19h4.807a2.75 2.75 0 0 0 2.742-2.53l.841-10.52.149.023a.75.75 0 0 0 .23-1.482A41.03 41.03 0 0 0 14 4.193V3.75A2.75 2.75 0 0 0 11.25 1h-2.5ZM10 4c.84 0 1.673.025 2.5.075V3.75c0-.69-.56-1.25-1.25-1.25h-2.5c-.69 0-1.25.56-1.25 1.25v.325C8.327 4.025 9.16 4 10 4ZM8.58 7.72a.75.75 0 0 0-1.5.06l.3 7.5a.75.75 0 1 0 1.5-.06l-.3-7.5Zm4.34.06a.75.75 0 1 0-1.5-.06l-.3 7.5a.75.75 0 1 0 1.5.06l.3-7.5Z",clipRule:"evenodd"}))}const T=t.forwardRef(_),R=({value:i,onChange:a,placeholder:n})=>e.jsx("textarea",{value:i,onChange:a,placeholder:n,className:"border p-2 w-full"});function F({questionnaires:i}){const[a,n]=t.useState(i),[r,h]=t.useState(null),[c,d]=t.useState(""),[u,x]=t.useState(!0),[f,l]=t.useState(!1),j=()=>{r?m.put(`/questionnaires/${r.id}`,{question_text:c,is_active:u},{onSuccess:s=>{n(s.props.questionnaires),p(),l(!1)}}):m.post("/questionnaires",{question_text:c,is_active:u},{onSuccess:s=>{n(s.props.questionnaires),p(),l(!1)}})},g=s=>{confirm("Yakin ingin menghapus kuisioner ini?")&&m.delete(`/questionnaires/${s}`,{onSuccess:v=>{n(v.props.questionnaires)}})},b=s=>{h(s),d(s.question_text),x(s.is_active),l(!0)},p=()=>{h(null),d(""),x(!0)};return e.jsxs(A,{breadcrumbs:[{title:"Kuisioner",href:"/questionnaires"}],children:[e.jsx(w,{title:"Daftar Kuisioner"}),e.jsxs("div",{className:"flex items-center justify-between p-4",children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Daftar Kuisioner"}),e.jsxs(y,{open:f,onOpenChange:l,children:[e.jsx(N,{asChild:!0,children:e.jsx(o,{onClick:()=>l(!0),children:"+ Tambah Kuisioner"})}),e.jsxs(k,{children:[e.jsx(S,{children:e.jsx(C,{children:r?"Edit Kuisioner":"Tambah Kuisioner"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(R,{placeholder:"Tulis pertanyaan kuisioner di sini...",value:c,onChange:s=>d(s.target.value)}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:u,onChange:s=>x(s.target.checked)}),"Aktif"]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(o,{variant:"secondary",onClick:()=>l(!1),children:"Batal"}),e.jsx(o,{onClick:j,children:r?"Update":"Simpan"})]})]})]})]})]}),e.jsx("div",{className:"p-4",children:e.jsxs("table",{className:"mt-6 min-w-full table-auto border-collapse overflow-hidden rounded-lg bg-white shadow-md",children:[e.jsx("thead",{className:"bg-blue-600 text-white",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-6 py-3 text-left text-sm font-semibold",children:"Pertanyaan"}),e.jsx("th",{className:"px-6 py-3 text-left text-sm font-semibold",children:"Status"}),e.jsx("th",{className:"px-6 py-3 text-left text-sm font-semibold",children:"Aksi"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-200",children:a.length>0?a.map(s=>e.jsxs("tr",{className:"transition-colors duration-200 ease-in-out hover:bg-gray-50",children:[e.jsx("td",{className:"px-6 py-4 text-sm font-medium text-gray-700",children:s.question_text}),e.jsx("td",{className:"px-6 py-4 text-center text-sm",children:e.jsx("span",{className:`inline-block rounded-full px-2 py-1 ${s.is_active?"bg-green-500":"bg-red-500"} text-white`,children:s.is_active?"Aktif":"Nonaktif"})}),e.jsxs("td",{className:"flex justify-center space-x-2 px-6 py-4 text-center text-sm",children:[e.jsx(o,{size:"sm",onClick:()=>b(s),variant:"outline",className:"p-2 text-blue-600 hover:bg-blue-100",children:e.jsx(D,{className:"h-5 w-5"})}),e.jsx(o,{size:"sm",onClick:()=>g(s.id),variant:"destructive",className:"text-dark-600 bg-red-500 p-2",children:e.jsx(T,{className:"h-5 w-5"})})]})]},s.id)):e.jsx("tr",{children:e.jsx("td",{colSpan:3,className:"py-4 text-center text-gray-500",children:"Tidak ada kuisioner yang tersedia"})})})]})})]})}export{F as default};
