list foods

This commit is contained in:
hamid zarghami
2025-11-15 12:26:31 +03:30
parent b7562f911d
commit 59e2e62c56
8 changed files with 250 additions and 85 deletions
@@ -0,0 +1,81 @@
import { Eye } from 'iconsax-react'
import type { ColumnType } from '@/components/types/TableTypes'
import type { Food } from '../types/Types'
import { formatPrice, formatTime } from '../utils/formatters'
export const getFoodTableColumns = (): ColumnType<Food>[] => {
return [
{
key: 'image',
title: 'تصویر',
render: (item: Food) => {
const imageUrl = item.images && item.images.length > 0 ? item.images[0] : ''
return (
<div className='w-10 h-10 rounded-full overflow-hidden bg-gray-200'>
{imageUrl ? (
<img src={imageUrl} alt={item.title} className='w-full h-full object-cover' />
) : (
<div className='w-full h-full flex items-center justify-center text-gray-400 text-xs'>
بدون تصویر
</div>
)}
</div>
)
}
},
{
key: 'title',
title: 'نام غذا',
},
{
key: 'categories',
title: 'دسته بندی',
render: (item: Food) => {
return item.categories && item.categories.length > 0
? item.categories.map(cat => cat.title).join(', ')
: '-'
}
},
{
key: 'price',
title: 'قیمت',
render: (item: Food) => {
return formatPrice(item.price)
}
},
{
key: 'prepareTime',
title: 'زمان آماده سازی',
render: (item: Food) => {
return formatTime(item.prepareTime)
}
},
{
key: 'isActive',
title: 'وضعیت',
render: (item: Food) => {
return (
<div className={`h-6 w-fit flex items-center rounded-full px-2.5 text-xs ${
item.isActive
? 'bg-[#FFEDCA] text-[#FF7B00]'
: 'bg-gray-200 text-gray-600'
}`}>
{item.isActive ? 'فعال' : 'غیرفعال'}
</div>
)
}
},
{
key: 'view',
title: '',
render: () => {
return (
<div className='flex gap-2 items-center'>
<Eye size={20} color='#8C90A3' />
</div>
)
}
},
]
}