+18
-5
@@ -1,19 +1,32 @@
|
|||||||
import { type FC, type ReactNode } from 'react'
|
import { type FC, type ReactNode } from 'react'
|
||||||
|
import { clx } from '../helpers/utils'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
text: string,
|
text: string,
|
||||||
children?: ReactNode,
|
children?: ReactNode,
|
||||||
dir?: string,
|
dir?: string,
|
||||||
|
align?: 'start' | 'center' | 'end',
|
||||||
|
className?: string,
|
||||||
}
|
}
|
||||||
|
|
||||||
const Td: FC<Props> = (props: Props) => {
|
const Td: FC<Props> = (props: Props) => {
|
||||||
|
const alignClass = props.align === 'end'
|
||||||
|
? 'text-end'
|
||||||
|
: props.align === 'center'
|
||||||
|
? 'text-center'
|
||||||
|
: props.align === 'start'
|
||||||
|
? 'text-start'
|
||||||
|
: ''
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<td className='td' style={{ direction: props.dir === "ltr" ? "ltr" : "rtl" }}>
|
<td
|
||||||
|
className={clx('td', alignClass, props.className)}
|
||||||
|
style={{ direction: props.dir === 'ltr' ? 'ltr' : 'rtl' }}
|
||||||
|
>
|
||||||
{
|
{
|
||||||
props.text ?
|
props.text
|
||||||
props.text
|
? props.text
|
||||||
:
|
: props.children
|
||||||
props.children
|
|
||||||
}
|
}
|
||||||
</td>
|
</td>
|
||||||
)
|
)
|
||||||
|
|||||||
+61
-36
@@ -13,7 +13,7 @@ import Td from '../../components/Td';
|
|||||||
import TrashWithConfrim from '../../components/TrashWithConfrim';
|
import TrashWithConfrim from '../../components/TrashWithConfrim';
|
||||||
import ModalConfrim from '../../components/ModalConfrim';
|
import ModalConfrim from '../../components/ModalConfrim';
|
||||||
import PageTitle from '../../components/PageTitle';
|
import PageTitle from '../../components/PageTitle';
|
||||||
import { Edit } from 'iconsax-react';
|
import { Box1 } from 'iconsax-react';
|
||||||
import Button from '@/components/Button';
|
import Button from '@/components/Button';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import { Pages } from '@/config/Pages';
|
import { Pages } from '@/config/Pages';
|
||||||
@@ -140,8 +140,8 @@ const List: FC = () => {
|
|||||||
className='w-fit'
|
className='w-fit'
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className='relative overflow-x-auto rounded-3xl mt-5 w-full'>
|
<div className='relative overflow-x-auto rounded-3xl mt-5 w-full border border-[#EAEDF5]'>
|
||||||
<table className='w-full text-sm'>
|
<table className='w-full text-sm min-w-[960px]'>
|
||||||
<thead className='thead'>
|
<thead className='thead'>
|
||||||
<tr>
|
<tr>
|
||||||
<Td text={'تصویر'} />
|
<Td text={'تصویر'} />
|
||||||
@@ -150,15 +150,15 @@ const List: FC = () => {
|
|||||||
<Td text={'دستهبندی'} />
|
<Td text={'دستهبندی'} />
|
||||||
<Td text='تنوع' />
|
<Td text='تنوع' />
|
||||||
<Td text={'وضعیت'} />
|
<Td text={'وضعیت'} />
|
||||||
<Td text={'قیمت'} />
|
<Td text={'قیمت'} align='end' />
|
||||||
<Td text={'موجودی'} />
|
<Td text={'موجودی'} align='end' />
|
||||||
<Td text={'عملیات'} />
|
<Td text={'عملیات'} align='center' className='min-w-[120px]' />
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{products.length === 0 ? (
|
{products.length === 0 ? (
|
||||||
<tr className='tr'>
|
<tr className='tr'>
|
||||||
<td colSpan={9} className="text-center py-8 text-gray-500">
|
<td colSpan={9} className="text-center py-8 text-gray-500 text-sm">
|
||||||
هیچ محصولی یافت نشد
|
هیچ محصولی یافت نشد
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -166,7 +166,7 @@ const List: FC = () => {
|
|||||||
products.map((product: ProductListType) => (
|
products.map((product: ProductListType) => (
|
||||||
<tr key={product._id} className='tr'>
|
<tr key={product._id} className='tr'>
|
||||||
<Td text="">
|
<Td text="">
|
||||||
<div className="w-12 h-12 rounded-lg overflow-hidden">
|
<div className="w-11 h-11 rounded-lg overflow-hidden bg-gray-50 shrink-0">
|
||||||
<img
|
<img
|
||||||
src={product.imagesUrl?.cover || '/placeholder-image.png'}
|
src={product.imagesUrl?.cover || '/placeholder-image.png'}
|
||||||
alt={product.title_fa}
|
alt={product.title_fa}
|
||||||
@@ -175,25 +175,35 @@ const List: FC = () => {
|
|||||||
</div>
|
</div>
|
||||||
</Td>
|
</Td>
|
||||||
<Td text="">
|
<Td text="">
|
||||||
<div>
|
<div className="max-w-[220px]">
|
||||||
<div className="font-medium text-gray-900">
|
<div className="font-medium text-gray-900 truncate" title={product.title_fa}>
|
||||||
{product.title_fa}
|
{product.title_fa}
|
||||||
</div>
|
</div>
|
||||||
<div className="text-gray-500 text-xs">
|
<div className="text-gray-400 text-xs truncate mt-0.5" title={product.title_en}>
|
||||||
{product.title_en}
|
{product.title_en}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Td>
|
</Td>
|
||||||
<Td text={product.brand_title_fa} />
|
<Td text="">
|
||||||
<Td text={product.category_title_fa} />
|
<span className="text-gray-700 max-w-[120px] truncate inline-block" title={product.brand_title_fa}>
|
||||||
|
{product.brand_title_fa}
|
||||||
|
</span>
|
||||||
|
</Td>
|
||||||
|
<Td text="">
|
||||||
|
<span className="text-gray-700 max-w-[120px] truncate inline-block" title={product.category_title_fa}>
|
||||||
|
{product.category_title_fa}
|
||||||
|
</span>
|
||||||
|
</Td>
|
||||||
<Td text=''>
|
<Td text=''>
|
||||||
<Link
|
<Link to={`${Pages.products.variants}${product._id}`}>
|
||||||
to={`${Pages.products.variants}${product._id}`}
|
|
||||||
>
|
|
||||||
<Button
|
<Button
|
||||||
className='h-8 text-xs'
|
variant='outline'
|
||||||
|
size='sm'
|
||||||
|
className='w-fit px-2.5 whitespace-nowrap'
|
||||||
>
|
>
|
||||||
مدیریت تنوع
|
<span className="flex items-center gap-1">
|
||||||
|
مدیریت تنوع
|
||||||
|
</span>
|
||||||
</Button>
|
</Button>
|
||||||
</Link>
|
</Link>
|
||||||
</Td>
|
</Td>
|
||||||
@@ -203,26 +213,41 @@ const List: FC = () => {
|
|||||||
text={getStatusText(product.status)}
|
text={getStatusText(product.status)}
|
||||||
/>
|
/>
|
||||||
</Td>
|
</Td>
|
||||||
<Td text={`${product.default_variant?.price?.selling_price?.toLocaleString('fa-IR') || 0} تومان`} />
|
<Td text="" align='end'>
|
||||||
<Td text={String(product.default_variant?.stock || 0)} />
|
<span className="text-gray-800 font-medium whitespace-nowrap">
|
||||||
<Td text="">
|
{(product.default_variant?.price?.selling_price ?? 0).toLocaleString('fa-IR')}
|
||||||
<div className="flex items-center gap-2">
|
<span className="text-gray-400 font-normal ms-1">تومان</span>
|
||||||
{
|
</span>
|
||||||
product.status !== ProductStatus.Draft && (
|
</Td>
|
||||||
<Button
|
<Td text="" align='end'>
|
||||||
variant='outline'
|
<span className="text-gray-700 tabular-nums">
|
||||||
label='پیش نویس'
|
{product.default_variant?.stock ?? 0}
|
||||||
className='text-xs h-8 px-2'
|
</span>
|
||||||
onClick={() => {
|
</Td>
|
||||||
setSelectedProductId(String(product._id));
|
<Td text="" align='center' className='min-w-[120px]'>
|
||||||
setIsDraftConfirmOpen(true);
|
<div className="flex items-center justify-center gap-1.5">
|
||||||
}}
|
{product.status !== ProductStatus.Draft && (
|
||||||
/>
|
<Button
|
||||||
)
|
variant='outline'
|
||||||
}
|
size='sm'
|
||||||
|
className='w-fit px-2.5 shrink-0'
|
||||||
|
onClick={() => {
|
||||||
|
setSelectedProductId(String(product._id));
|
||||||
|
setIsDraftConfirmOpen(true);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
پیشنویس
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
{product.status === ProductStatus.Draft && (
|
{product.status === ProductStatus.Draft && (
|
||||||
<Link to={`${Pages.products.update}${product._id}`}>
|
<Link to={`${Pages.products.update}${product._id}`}>
|
||||||
<Edit color='#8C90A3' size={16} className="cursor-pointer hover:text-blue-500" />
|
<Button
|
||||||
|
variant='outline'
|
||||||
|
size='sm'
|
||||||
|
className='w-fit px-2.5 shrink-0'
|
||||||
|
>
|
||||||
|
ویرایش
|
||||||
|
</Button>
|
||||||
</Link>
|
</Link>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user