PageSourceSearch

https://sendunlimitedemail.com/sue/mod-D1FD3F8P.js

js sendunlimitedemail.com collected 2026-10-05 06:24:46 UTC 5,541 bytes, 1 lines download raw bytes

1import{r as i,t as c,j as e,B as l}from"./edge-BOITG1XR.js";import{c as h,t as f}from"./mod-C8LxKJmi.js";import{I as o}from"./mod-BUsEZZHX.js";import{L as d}from"./mod-kvo2LsX8.js";import{C as D,a as k,b as L,c as P}from"./mod-DgQ0OFXm.js";import{T as B,a as H,b as x,c as b,d as R,e as m}from"./mod-Du2hqDxx.js";import{P as z}from"./mod-BHbsKpbp.js";import{S as q}from"./mod-C9xhOiHj.js";import{P as U}from"./mod-BVSlmYWv.js";import{T as G}from"./mod-BuHkwEt_.js";const $=()=>{const[v,S]=i.useState([]),[T,N]=i.useState(!0),[u,y]=i.useState(!1),[C,p]=i.useState(!1),[g,_]=i.useState(null),[s,r]=i.useState({name:"",description:"",image:"",arabic_name:"",arabic_description:""});i.useEffect(()=>{j()},[]);const j=async()=>{try{N(!0);const a=await h.getCategories();S(a)}catch(a){console.error("Error fetching categories:",a),c.error("Failed to load categories")}finally{N(!1)}},E=async a=>{p(!0),_(a),r({name:a.name||"",description:a.description||"",image:a.image||"",arabic_name:"",arabic_description:""});try{const n=(await f.getEntityTranslations("category",a.id))?.ar||{};r(A=>({...A,arabic_name:n.name||"",arabic_description:n.description||""}))}catch{r(t=>({...t,arabic_name:"",arabic_description:""}))}},F=async a=>{if(window.confirm("Are you sure you want to delete this category?"))try{await h.deleteC
1ategory(a),c.success("Category deleted successfully"),j()}catch(t){console.error("Error deleting category:",t),c.error("Failed to delete category")}},I=async a=>{if(a.preventDefault(),!u){y(!0);try{if(g)await h.updateCategory(g.id,s),await f.saveTranslations("category",g.id,{ar:{name:s.arabic_name,description:s.arabic_description}}),c.success("Category updated successfully");else{const t=await h.createCategory(s),n=t?.id||t?.data?.id;n&&await f.saveTranslations("category",n,{ar:{name:s.arabic_name,description:s.arabic_description}}),c.success("Category created successfully")}w(),j()}catch(t){console.error("Error saving category:",t),c.error("Failed to save category")}finally{y(!1)}}},w=()=>{p(!1),_(null),r({name:"",description:"",image:"",arabic_name:"",arabic_description:""})};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"Categories"}),!C&&e.jsxs(l,{onClick:()=>p(!0),children:[e.jsx(z,{className:"mr-2 h-4 w-4"})," Add Category"]})]}),C&&e.jsxs(D,{children:[e.jsx(k,{children:e.jsx(L,{children:g?"Edit Category":"Add New Category"})}),e.jsx(P,{children:e.jsxs("form",{onSubmit:I,className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[e.jsx(d,{htmlFor:"name",className:"text-right",children:"Name"}),e.jsx(o,{id:"name",value:s.name,onChange:a=>r({...s,name:a.target.value}),className:"col-span-3",required:!0})]}),e.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[e.jsx(d,{htmlFor:"image",className:"text-right",children:"Image URL"}),e.jsx(o,{id:"image",value:s.image,onChange:a=>r({...s,image:a.target.value}),className:"col-span-3",placeholder:"https://example.com/image.jpg"})]}),e.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[e.jsx(d,{htmlFor:"description",className:"text-right",children:"Description"}),e.jsx(o,{id:"description",value:s.description,onChange:a=>r({...s,description:a.target.value}),className:"col-span-3"})]}),e.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[e.jsx(d,{htmlFor:"arabic_name",className:"text-right",children:"Arabic Name"}),e.jsx(o,{id:"arabic_name",value:s.arabic_name,onChange:a=>r({...s,arabic_name:a.target.value}),className:"col-span-3",dir:"rtl"})]}),e.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[e.jsx(d,{htmlFor:"arabic_description",className:"text-right",children:"Arabic Description"}),e.jsx(o,{id:"arabic_description",value:s.arabic_description,onChange:a=>r({...s,arabic_description:a.target.value}),className:"col-span-3",dir:"rtl"})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(l,{type:"button",variant:"outline",onClick:w,children:"Cancel"}),e.jsxs(l,{type:"submit",disabled:u,children:[e.jsx(q,{className:"mr-2 h-4 w-4"})," ",u?"Saving…":"Save"]})]})]})})]}),e.jsx("div",{className:"border rounded-md",children:e.jsxs(B,{children:[e.jsx(H,{children:e.jsxs(x,{children:[e.jsx(b,{children:"Image"}),e.jsx(b,{children:"Name"}),e.jsx(b,{className:"text-right",children:"Actions"})]})}),e.jsx(R,{children:T?e.jsx(x,{children:e.jsx(m,{colSpan:3,className:"text-center h-24",children:"Loading..."})}):v.length===0?e.jsx(x,{children:e.jsx(m,{colSpan:3,className:"text-center h-24",children:"No categories found."})}):v.map(a=>e.jsxs(x,{children:[e.jsx(m,{children:e.jsx("div",{className:"h-10 w-10 rounded-md overflow-hidden bg-gray-100",children:a.image?e.jsx("img",{src:a.image,alt:a.name,className:"h-full w-full object-cover"}):e.jsx("div",{className:"h-full w-full flex items-center justify-center text-gray-400 text-xs",children:"No Img"})})}),e.jsx(m,{className:"font-medium",children:a.name}),e.jsx(m,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(l,{variant:"ghost",size:"icon",onClick:()=>E(a),children:e.jsx(U,{className:"h-4 w-4"})}),e.jsx(l,{variant:"ghost",size:"icon",className:"text-red-500 hover:text-red-600 hover:bg-red-50",onClick:()=>F(a.id),children:e.jsx(G,{className:"h-4 w-4"})})]})})]},a.id))})]})})]})};export{$ 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.