delete category theme
This commit is contained in:
@@ -158,6 +158,7 @@ export const Pages = {
|
||||
list: "/products/theme",
|
||||
create: "/products/theme/create",
|
||||
update: "/products/theme/update/",
|
||||
values: "/products/theme/values/",
|
||||
},
|
||||
create: "/products/create",
|
||||
list: "/products/list",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { type FC } from 'react'
|
||||
import PageTitle from '@/components/PageTitle'
|
||||
import { useGetThemes } from './hooks/useThemeData'
|
||||
import { useDeleteTheme, useGetThemes } from './hooks/useThemeData'
|
||||
import Button from '@/components/Button';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { Pages } from '@/config/Pages';
|
||||
@@ -8,10 +8,13 @@ import { Plus } from 'lucide-react';
|
||||
import Td from '@/components/Td';
|
||||
import TrashWithConfrim from '@/components/TrashWithConfrim';
|
||||
import { Eye } from 'iconsax-react';
|
||||
import { toast } from 'react-toastify';
|
||||
import { extractErrorMessage } from '@/helpers/utils';
|
||||
|
||||
const ThemeList: FC = () => {
|
||||
|
||||
const { data, isLoading } = useGetThemes();
|
||||
const { mutate: deleteTheme, isPending } = useDeleteTheme();
|
||||
|
||||
if (isLoading) {
|
||||
return <div className="flex justify-center items-center h-64">در حال بارگذاری...</div>;
|
||||
@@ -38,6 +41,7 @@ const ThemeList: FC = () => {
|
||||
<tr>
|
||||
<Td text={'عنوان'} />
|
||||
<Td text={'نوع ورودی'} />
|
||||
<Td text={'مقادیر تم'} />
|
||||
<Td text={'عملیات'} />
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -48,14 +52,26 @@ const ThemeList: FC = () => {
|
||||
<tr className='tr' key={item._id}>
|
||||
<Td text={item.title} />
|
||||
<Td text={item.inputType} />
|
||||
<Td text=''>
|
||||
<Link to={`${Pages.products.theme.values}${item._id}`}>
|
||||
<Button variant='outline' className='h-7 text-xs w-fit px-4' label='مدیریت مقادیر' />
|
||||
</Link>
|
||||
</Td>
|
||||
<Td text=''>
|
||||
<div className='flex gap-2'>
|
||||
<Link to={`${Pages.products.theme.update}${item._id}`}>
|
||||
<Eye size={16} color='#8C90A3' />
|
||||
</Link>
|
||||
<TrashWithConfrim
|
||||
onDelete={() => null}
|
||||
isLoading={false}
|
||||
onDelete={() => deleteTheme(item._id, {
|
||||
onSuccess: () => {
|
||||
toast.success('تم با موفقیت حذف شد')
|
||||
},
|
||||
onError: (error) => {
|
||||
toast.error(extractErrorMessage(error))
|
||||
}
|
||||
})}
|
||||
isLoading={isPending}
|
||||
/>
|
||||
</div>
|
||||
</Td>
|
||||
|
||||
Reference in New Issue
Block a user