1import{K as g,r as v,t as f,j as e,X as y,v as l,q as u}from"./index-42OYDF60.js";import{u as h}from"./useMutation-TEeOEsok.js";import{B as n}from"./button-EfpS49lo.js";import{I as m}from"./input-D0IjS33j.js";import{T as N}from"./textarea-D06DcQsJ.js";import{L as d}from"./label-BNvpn1fK.js";import{S as w}from"./switch-CrYu0Slx.js";import{P as q}from"./plus-UlO-Lz9K.js";import{S as _}from"./save-D7r0WXgf.js";import{L as C}from"./loader-circle-C9c4MVet.js";import{P as b}from"./pencil-DccT4vhR.js";import{T as k}from"./trash-2-B3_ksNI2.js";import"./index-CXOUwLiy.js";const H=()=>{const c=g(),[a,i]=v.useState(null),{data:o=[],isLoading:p}=f({queryKey:["admin_faqs"],queryFn:async()=>{const{data:s,error:r}=await l.from("faqs").select("*").order("display_order");if(r)throw r;return s}}),x=h({mutationFn:async s=>{const r={...s,display_order:Number(s.display_order)||0};if(delete r.created_at,delete r.updated_at,s.id){const{error:t}=await l.from("faqs").update(r).eq("id",s.id);if(t)throw t}else{delete r.id;const{error:t}=await l.from("faqs").insert(r);if(t)throw t}},onSuccess:()=>{u.success("সà¦à¦°à¦à§à¦·à¦¿à¦¤"),c.invalidateQueries({queryKey:["admin_faqs"]}),c.invalidateQueries({queryKey:["public_faqs"]}),i(null)}}),j=h({mutationFn:async s=>{const{error:r}=await l.from("faqs").delete().eq("id",s);if(r)throw r},onSuccess:()=>{u.success("মà§à¦à§ ফà§à¦²à¦¾ হয়à§à¦à§"),c.invalidateQueries({queryKey:["admin_faqs"]})}});return e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-extrabold tracking-tight",children:"FAQ মà§à¦¯à¦¾à¦¨à§à¦à¦¾à¦°"}),e.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[o.length,"à¦à¦¿ পà§à¦°à¦¶à§à¦¨"]})]}),e.jsxs(n,{onClick:()=>i({question:"",answer:"",category:"General",display_order:o.length+1,is_active:!0}),className:"gradient-primary text-primary-foreground",children:[e.jsx(q,{className:"h-4 w-4"})," নতà§à¦¨ FAQ"]})]}),a&&e.jsxs("div",{className:"rounded-2xl glass-card p-4 space-y-3",children:[e.jsxs("div",{className:"grid gap-1.5",children:[e.jsx(d,{children:"পà§à¦°à¦¶à§à¦¨"}),e.jsx(m,{value:a.question,onChange:s=>i({...a,question:s.target.value})})]}),e.jsxs("div",{className:"grid gap-1.5",children:[e.jsx(d,{children:"à¦à¦¤à§à¦¤à¦°"}),e.jsx(N,{rows:3,value:a.answer,onChange:s=>i({...a,answer:s.target.value})})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"grid gap-1.5",children:[e.jsx(d,{children:"à¦à§à¦¯à¦¾à¦à¦¾à¦à¦°à¦¿"}),e.jsx(m,{value:a.category??"",onChange:s=>i({...a,category:s.target.value})})]}),e.jsxs("div",{className:"grid gap-1.5",children:[e.jsx(d,{children:"à¦à§à¦°à¦®"}),e.jsx(m,{type:"number",value:a.display_order??0,onChange:s=>i({...a,display_order:s.target.value})})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg bg-secondary/30 px-3",children:[e.jsx(d,{children:"সà¦à§à¦°à¦¿à¦¯à¦¼"}),e.jsx(w,{checked:!!a.is_active,onCheckedChange:s=>i({...a,is_active:s})})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(n,{onClick:()=>x.mutate(a),disabled:x.isPending,className:"gradient-primary text-primary-foreground",children:[e.jsx(_,{className:"h-4 w-4"})," সà¦à¦°à¦à§à¦·à¦£"]}),e.jsxs(n,{variant:"outline",onClick:()=>i(null),children:[e.jsx(y,{className:"h-4 w-4"})," বাতিল"]})]})]}),p?e.jsx("div",{className:"flex h-64 items-center justify-center",children:e.jsx(C,{className:"h-8 w-8 animate-spin text-primary"})}):e.jsx("div",{className:"grid gap-2",children:o.map(s=>e.jsx("div",{className:"rounded-2xl glass-card p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-bold",children:s.question}),e.jsx("div",{className:"text-sm text-muted-foreground mt-1 whitespace-pre-wrap",children:s.answer}),e.jsxs("div",{className:"text-xs mt-2 text-muted-foreground",children:["#",s.display_order," ⢠",s.category," ",!s.is_active&&e.jsx("span",{className:"text-warning",children:"⢠Hidden"})]})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(n,{size:"sm",variant:"outline",onClick:()=>i({...s}),children:e.jsx(b,{className:"h-3.5 w-3.5"})}),e.jsx(n,{size:"sm",variant:"outline",onClick:()=>{confirm("মà§à¦à¦¬à§à¦¨?")&&j.mutate(s.id)},children:e.jsx(k,{className:"h-3.5 w-3.5"})})]})]})},s.id))})]})};export{H as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.