From f83a66f6968aeb9d70f6b2bb56c86b33353f5d61 Mon Sep 17 00:00:00 2001 From: hamid zarghami Date: Sat, 15 Nov 2025 12:41:49 +0330 Subject: [PATCH] statuscomponent --- src/components/Status.tsx | 33 +++++++++++++++++++ .../food/components/FoodTableColumns.tsx | 9 ++--- 2 files changed, 35 insertions(+), 7 deletions(-) create mode 100644 src/components/Status.tsx diff --git a/src/components/Status.tsx b/src/components/Status.tsx new file mode 100644 index 0000000..376d67f --- /dev/null +++ b/src/components/Status.tsx @@ -0,0 +1,33 @@ +import { type FC } from 'react' +import { clx } from '@/helpers/utils' + +type StatusVariant = 'success' | 'error' | 'warning' | 'info' | 'pending' | 'active' | 'inactive' + +type Props = { + variant: StatusVariant + label: string +} + +const Status: FC = ({ variant, label }) => { + const variantStyles: Record = { + success: 'bg-green-100 text-green-600', + error: 'bg-red-100 text-red-600', + warning: 'bg-yellow-100 text-yellow-600', + info: 'bg-blue-100 text-blue-600', + pending: 'bg-gray-100 text-gray-600', + active: 'bg-green-100 text-green-600', + inactive: 'bg-gray-100 text-gray-400', + } + + return ( +
+ {label} +
+ ) +} + +export default Status + diff --git a/src/pages/food/components/FoodTableColumns.tsx b/src/pages/food/components/FoodTableColumns.tsx index 932c45c..fc2d2c6 100644 --- a/src/pages/food/components/FoodTableColumns.tsx +++ b/src/pages/food/components/FoodTableColumns.tsx @@ -2,6 +2,7 @@ import { Eye } from 'iconsax-react' import type { ColumnType } from '@/components/types/TableTypes' import type { Food } from '../types/Types' import { formatPrice, formatTime } from '../utils/formatters' +import Status from '@/components/Status' export const getFoodTableColumns = (): ColumnType[] => { return [ @@ -55,13 +56,7 @@ export const getFoodTableColumns = (): ColumnType[] => { title: 'وضعیت', render: (item: Food) => { return ( -
- {item.isActive ? 'فعال' : 'غیرفعال'} -
+ ) } },