delete category theme

This commit is contained in:
hamid zarghami
2025-11-29 10:05:44 +03:30
parent a4aaf21803
commit 322e2f6173
2 changed files with 20 additions and 3 deletions
+1
View File
@@ -158,6 +158,7 @@ export const Pages = {
list: "/products/theme", list: "/products/theme",
create: "/products/theme/create", create: "/products/theme/create",
update: "/products/theme/update/", update: "/products/theme/update/",
values: "/products/theme/values/",
}, },
create: "/products/create", create: "/products/create",
list: "/products/list", list: "/products/list",
+19 -3
View File
@@ -1,6 +1,6 @@
import { type FC } from 'react' import { type FC } from 'react'
import PageTitle from '@/components/PageTitle' import PageTitle from '@/components/PageTitle'
import { useGetThemes } from './hooks/useThemeData' import { useDeleteTheme, useGetThemes } from './hooks/useThemeData'
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';
@@ -8,10 +8,13 @@ import { Plus } from 'lucide-react';
import Td from '@/components/Td'; import Td from '@/components/Td';
import TrashWithConfrim from '@/components/TrashWithConfrim'; import TrashWithConfrim from '@/components/TrashWithConfrim';
import { Eye } from 'iconsax-react'; import { Eye } from 'iconsax-react';
import { toast } from 'react-toastify';
import { extractErrorMessage } from '@/helpers/utils';
const ThemeList: FC = () => { const ThemeList: FC = () => {
const { data, isLoading } = useGetThemes(); const { data, isLoading } = useGetThemes();
const { mutate: deleteTheme, isPending } = useDeleteTheme();
if (isLoading) { if (isLoading) {
return <div className="flex justify-center items-center h-64">در حال بارگذاری...</div>; return <div className="flex justify-center items-center h-64">در حال بارگذاری...</div>;
@@ -38,6 +41,7 @@ const ThemeList: FC = () => {
<tr> <tr>
<Td text={'عنوان'} /> <Td text={'عنوان'} />
<Td text={'نوع ورودی'} /> <Td text={'نوع ورودی'} />
<Td text={'مقادیر تم'} />
<Td text={'عملیات'} /> <Td text={'عملیات'} />
</tr> </tr>
</thead> </thead>
@@ -48,14 +52,26 @@ const ThemeList: FC = () => {
<tr className='tr' key={item._id}> <tr className='tr' key={item._id}>
<Td text={item.title} /> <Td text={item.title} />
<Td text={item.inputType} /> <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=''> <Td text=''>
<div className='flex gap-2'> <div className='flex gap-2'>
<Link to={`${Pages.products.theme.update}${item._id}`}> <Link to={`${Pages.products.theme.update}${item._id}`}>
<Eye size={16} color='#8C90A3' /> <Eye size={16} color='#8C90A3' />
</Link> </Link>
<TrashWithConfrim <TrashWithConfrim
onDelete={() => null} onDelete={() => deleteTheme(item._id, {
isLoading={false} onSuccess: () => {
toast.success('تم با موفقیت حذف شد')
},
onError: (error) => {
toast.error(extractErrorMessage(error))
}
})}
isLoading={isPending}
/> />
</div> </div>
</Td> </Td>