admin/dist/assets/ProductOptionsListPage-9794...

2 lines
9.7 KiB
JavaScript

import{j as e}from"./vendor-query-a3e439f2.js";import{u as a,r}from"./vendor-react-ac1483bd.js";import{u as s,a as t}from"./_hooks-8b9f7cf5.js";import{B as d}from"./index-590deac5.js";import{M as i}from"./Modal-8110908d.js";import{b as x,m as l,N as c,x as n,y as m}from"./vendor-ui-8a3c5c7d.js";import"./_requests-35c9d4c3.js";import"./vendor-toast-598db4db.js";const g=()=>e.jsx("div",{className:"bg-white dark:bg-gray-800 shadow-sm border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden",children:e.jsx("div",{className:"hidden md:block",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"min-w-full divide-y divide-gray-200 dark:divide-gray-700",children:[e.jsx("thead",{className:"bg-gray-50 dark:bg-gray-700",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-6 py-3 text-right text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider",children:"نام گزینه"}),e.jsx("th",{className:"px-6 py-3 text-right text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider",children:"مقادیر"}),e.jsx("th",{className:"px-6 py-3 text-right text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider",children:"تاریخ ایجاد"}),e.jsx("th",{className:"px-6 py-3 text-right text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider",children:"عملیات"})]})}),e.jsx("tbody",{className:"bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700",children:[...Array(5)].map((a,r)=>e.jsxs("tr",{children:[e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsx("div",{className:"h-4 bg-gray-200 dark:bg-gray-600 rounded animate-pulse"})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsx("div",{className:"h-4 bg-gray-200 dark:bg-gray-600 rounded animate-pulse"})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsx("div",{className:"h-4 bg-gray-200 dark:bg-gray-600 rounded animate-pulse"})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx("div",{className:"h-8 w-8 bg-gray-200 dark:bg-gray-600 rounded animate-pulse"}),e.jsx("div",{className:"h-8 w-8 bg-gray-200 dark:bg-gray-600 rounded animate-pulse"})]})})]},r))})]})})})}),o=()=>{const o=a(),[h,p]=r.useState(null),[y,j]=r.useState({search:""}),{data:N,isLoading:u,error:k}=s(y),{mutate:b,isPending:v}=t(),w=()=>{o("/product-options/create")},f=e=>{o(`/product-options/${e}/edit`)};return k?e.jsx("div",{className:"p-6",children:e.jsx("div",{className:"text-center py-12",children:e.jsx("p",{className:"text-red-600 dark:text-red-400",children:"خطا در بارگذاری گزینه‌های محصول"})})}):e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{className:"flex flex-col space-y-3 sm:flex-row sm:items-center sm:justify-between sm:space-y-0",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold text-gray-900 dark:text-gray-100 flex items-center gap-2",children:[e.jsx(x,{className:"h-6 w-6"}),"مدیریت گزینه‌های محصول"]}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:"تنظیمات گزینه‌های قابل انتخاب برای محصولات"})]}),e.jsx("button",{onClick:w,className:"flex items-center justify-center w-12 h-12 bg-primary-600 hover:bg-primary-700 rounded-full transition-colors duration-200 text-white shadow-lg hover:shadow-xl",title:"گزینه محصول جدید",children:e.jsx(l,{className:"h-5 w-5"})})]}),e.jsx("div",{className:"bg-white dark:bg-gray-800 shadow-sm border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"جستجو"}),e.jsx("input",{type:"text",placeholder:"جستجو در نام گزینه...",value:y.search,onChange:e=>{j(a=>({...a,search:e.target.value}))},className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-1 focus:ring-primary-500 dark:bg-gray-700 dark:text-gray-100"})]})})}),u?e.jsx(g,{}):e.jsxs("div",{className:"bg-white dark:bg-gray-800 shadow-sm border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden",children:[e.jsx("div",{className:"hidden md:block",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"min-w-full divide-y divide-gray-200 dark:divide-gray-700",children:[e.jsx("thead",{className:"bg-gray-50 dark:bg-gray-700",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-6 py-3 text-right text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider",children:"نام گزینه"}),e.jsx("th",{className:"px-6 py-3 text-right text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider",children:"مقادیر"}),e.jsx("th",{className:"px-6 py-3 text-right text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider",children:"تاریخ ایجاد"}),e.jsx("th",{className:"px-6 py-3 text-right text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider",children:"عملیات"})]})}),e.jsx("tbody",{className:"bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700",children:(N||[]).map(a=>e.jsxs("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-700",children:[e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900 dark:text-gray-100",children:a.title}),e.jsx("td",{className:"px-6 py-4 text-sm text-gray-900 dark:text-gray-100",children:e.jsxs("div",{className:"flex flex-wrap gap-1 max-w-xs",children:[(a.options||[]).slice(0,3).map((a,r)=>e.jsxs("span",{className:"inline-flex items-center px-2 py-1 rounded-md text-xs bg-gray-100 dark:bg-gray-600 text-gray-800 dark:text-gray-200",children:[e.jsx(c,{className:"h-3 w-3 mr-1"}),a.title]},r)),(a.options||[]).length>3&&e.jsxs("span",{className:"inline-flex items-center px-2 py-1 rounded-md text-xs bg-primary-100 dark:bg-primary-900 text-primary-800 dark:text-primary-200",children:["+",(a.options||[]).length-3," بیشتر"]})]})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-900 dark:text-gray-100",children:new Date(a.created_at).toLocaleDateString("fa-IR")}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>f(a.id),className:"text-indigo-600 hover:text-indigo-900 dark:text-indigo-400 dark:hover:text-indigo-300",title:"ویرایش",children:e.jsx(n,{className:"h-4 w-4"})}),e.jsx("button",{onClick:()=>p(a.id.toString()),className:"text-red-600 hover:text-red-900 dark:text-red-400 dark:hover:text-red-300",title:"حذف",children:e.jsx(m,{className:"h-4 w-4"})})]})})]},a.id))})]})})}),e.jsx("div",{className:"md:hidden p-4 space-y-4",children:(N||[]).map(a=>e.jsxs("div",{className:"border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:[e.jsx("div",{className:"flex justify-between items-start mb-3",children:e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:a.title}),e.jsxs("div",{className:"flex flex-wrap gap-1 mt-2",children:[(a.options||[]).slice(0,3).map((a,r)=>e.jsxs("span",{className:"inline-flex items-center px-2 py-1 rounded-md text-xs bg-gray-100 dark:bg-gray-600 text-gray-800 dark:text-gray-200",children:[e.jsx(c,{className:"h-3 w-3 mr-1"}),a.title]},r)),(a.options||[]).length>3&&e.jsxs("span",{className:"inline-flex items-center px-2 py-1 rounded-md text-xs bg-primary-100 dark:bg-primary-900 text-primary-800 dark:text-primary-200",children:["+",(a.options||[]).length-3," بیشتر"]})]})]})}),e.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-3",children:["تاریخ ایجاد: ",new Date(a.created_at).toLocaleDateString("fa-IR")]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>f(a.id),className:"flex items-center gap-1 px-2 py-1 text-xs text-indigo-600 hover:text-indigo-900 dark:text-indigo-400 dark:hover:text-indigo-300",children:[e.jsx(n,{className:"h-3 w-3"}),"ویرایش"]}),e.jsxs("button",{onClick:()=>p(a.id.toString()),className:"flex items-center gap-1 px-2 py-1 text-xs text-red-600 hover:text-red-900 dark:text-red-400 dark:hover:text-red-300",children:[e.jsx(m,{className:"h-3 w-3"}),"حذف"]})]})]},a.id))}),(!N||0===N.length)&&!u&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx(x,{className:"mx-auto h-12 w-12 text-gray-400"}),e.jsx("h3",{className:"mt-2 text-sm font-medium text-gray-900 dark:text-gray-100",children:"گزینه‌ای موجود نیست"}),e.jsx("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:"برای شروع، اولین گزینه محصول خود را ایجاد کنید."}),e.jsx("div",{className:"mt-6",children:e.jsxs(d,{onClick:w,className:"flex items-center gap-2 mx-auto",children:[e.jsx(l,{className:"h-4 w-4"}),"ایجاد گزینه جدید"]})})]})]}),e.jsx(i,{isOpen:!!h,onClose:()=>p(null),title:"حذف گزینه محصول",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"آیا از حذف این گزینه محصول اطمینان دارید؟ این عمل قابل بازگشت نیست و ممکن است بر محصولاتی که از این گزینه استفاده می‌کنند تأثیر بگذارد."}),e.jsxs("div",{className:"flex justify-end space-x-2 space-x-reverse",children:[e.jsx(d,{variant:"secondary",onClick:()=>p(null),disabled:v,children:"انصراف"}),e.jsx(d,{variant:"danger",onClick:()=>{h&&b(h,{onSuccess:()=>{p(null)}})},loading:v,children:"حذف"})]})]})})]})};export{o as default};