2 lines
9.4 KiB
JavaScript
2 lines
9.4 KiB
JavaScript
import{j as e}from"./vendor-query-a3e439f2.js";import{L as s,B as a}from"./index-590deac5.js";import{b as r}from"./_hooks-05707864.js";import{P as t}from"./_models-0008c1da.js";import{u as d,f as l}from"./vendor-react-ac1483bd.js";import{z as i,G as c,j as x,D as n,P as m,Q as g,N as o,I as h,t as j}from"./vendor-ui-8a3c5c7d.js";import"./vendor-toast-598db4db.js";import"./_requests-35c9d4c3.js";const y=()=>{const y=d(),{id:b=""}=l(),{data:p,isLoading:N,error:k}=r(b);return N?e.jsx(s,{}):k?e.jsx("div",{className:"text-red-600",children:"خطا در بارگذاری اطلاعات محصول"}):p?e.jsxs("div",{className:"p-6",children:[e.jsx("div",{className:"mb-6",children:e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(a,{variant:"secondary",onClick:()=>y("/products"),className:"flex items-center gap-2",children:[e.jsx(i,{className:"h-4 w-4"}),"بازگشت"]}),e.jsx("h1",{className:"text-2xl font-bold text-gray-900 dark:text-gray-100",children:"جزئیات محصول"})]}),e.jsx("div",{className:"flex gap-3",children:e.jsxs(a,{variant:"secondary",onClick:()=>y(`/products/${b}/edit`),className:"flex items-center gap-2",children:[e.jsx(c,{className:"h-4 w-4"}),"ویرایش"]})})]})}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"lg:col-span-2",children:[e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-md p-6 mb-6",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 mb-6",children:"اطلاعات محصول"}),e.jsxs("div",{className:"space-y-6",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("div",{className:"p-3 bg-gray-50 dark:bg-gray-700 rounded-lg",children:e.jsx("p",{className:"text-gray-900 dark:text-gray-100 font-medium",children:p.name})})]}),p.description&&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("div",{className:"p-3 bg-gray-50 dark:bg-gray-700 rounded-lg",children:e.jsx("p",{className:"text-gray-900 dark:text-gray-100",children:p.description})})]}),p.design_style&&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("div",{className:"p-3 bg-gray-50 dark:bg-gray-700 rounded-lg",children:e.jsx("p",{className:"text-gray-900 dark:text-gray-100",children:p.design_style})})]}),e.jsxs("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("div",{className:"p-3 bg-gray-50 dark:bg-gray-700 rounded-lg",children:e.jsx("p",{className:"text-gray-900 dark:text-gray-100",children:t[p.type]||"نامشخص"})})]}),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("div",{className:"p-3 bg-gray-50 dark:bg-gray-700 rounded-lg",children:e.jsx("span",{className:"inline-flex px-2 py-1 text-xs font-semibold rounded-full "+(p.enabled?"bg-green-100 text-green-800 dark:bg-green-800 dark:text-green-100":"bg-red-100 text-red-800 dark:bg-red-800 dark:text-red-100"),children:p.enabled?"فعال":"غیرفعال"})})]})]})]})]}),p.images&&p.images.length>0&&e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-md p-6 mb-6",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4",children:"تصاویر محصول"}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4",children:p.images.map((s,a)=>e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:s.url,alt:s.alt||`تصویر ${a+1}`,className:"w-full h-32 object-cover rounded-lg border border-gray-200 dark:border-gray-600"}),e.jsx("div",{className:"absolute inset-0 bg-black bg-opacity-50 opacity-0 group-hover:opacity-100 transition-opacity rounded-lg flex items-center justify-center",children:e.jsx(x,{className:"h-6 w-6 text-white"})})]},s.id||a))})]}),p.variants&&p.variants.length>0&&e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-md p-6",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4",children:"نسخههای محصول"}),e.jsx("div",{className:"space-y-4",children:p.variants.map((s,a)=>e.jsx("div",{className:"p-4 border border-gray-200 dark:border-gray-600 rounded-lg",children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:"وضعیت:"}),e.jsx("span",{className:"ml-2 px-2 py-1 text-xs rounded-full "+(s.enabled?"bg-green-100 text-green-800 dark:bg-green-800 dark:text-green-100":"bg-red-100 text-red-800 dark:bg-red-800 dark:text-red-100"),children:s.enabled?"فعال":"غیرفعال"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:"موجودی:"}),e.jsx("span",{className:"ml-2 font-medium text-gray-900 dark:text-gray-100",children:s.stock_number})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:"وزن:"}),e.jsxs("span",{className:"ml-2 font-medium text-gray-900 dark:text-gray-100",children:[s.weight," گرم"]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:"درصد سود:"}),e.jsxs("span",{className:"ml-2 font-medium text-gray-900 dark:text-gray-100",children:[s.profit_percentage,"%"]})]})]})},s.id||a))})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-md p-6",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4",children:"آمار"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(n,{className:"h-4 w-4 text-green-500"}),e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:"تعداد فروش"})]}),e.jsx("span",{className:"font-semibold text-gray-900 dark:text-gray-100",children:p.total_sold||0})]}),p.variants&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(m,{className:"h-4 w-4 text-blue-500"}),e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:"تعداد نسخهها"})]}),e.jsx("span",{className:"font-semibold text-gray-900 dark:text-gray-100",children:p.variants.length})]}),p.images&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(g,{className:"h-4 w-4 text-purple-500"}),e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:"تعداد تصاویر"})]}),e.jsx("span",{className:"font-semibold text-gray-900 dark:text-gray-100",children:p.images.length})]})]})]}),p.categories&&p.categories.length>0&&e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-md p-6",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4",children:"دستهبندیها"}),e.jsx("div",{className:"space-y-2",children:p.categories.map(s=>e.jsxs("div",{className:"flex items-center gap-2 p-2 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg",children:[e.jsx(o,{className:"h-4 w-4 text-blue-500"}),e.jsx("span",{className:"text-blue-900 dark:text-blue-100 font-medium",children:s.name})]},s.id))})]}),p.product_option&&e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-md p-6",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4",children:"گزینه محصول"}),e.jsxs("div",{className:"p-3 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[e.jsx("p",{className:"text-gray-900 dark:text-gray-100 font-medium",children:p.product_option.name}),p.product_option.description&&e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mt-1",children:p.product_option.description})]})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-md p-6",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4",children:"اطلاعات زمانی"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(h,{className:"h-4 w-4 text-green-500"}),e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:"تاریخ ایجاد"})]}),e.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:new Date(p.created_at).toLocaleDateString("fa-IR")})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(j,{className:"h-4 w-4 text-orange-500"}),e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:"آخرین بهروزرسانی"})]}),e.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:new Date(p.updated_at).toLocaleDateString("fa-IR")})]})]})]})]})]})]}):e.jsx("div",{children:"محصول یافت نشد"})};export{y as default};
|