delete section

This commit is contained in:
hamid zarghami
2026-02-02 10:19:39 +03:30
parent 7f2000ec6d
commit 41acb02611
3 changed files with 30 additions and 5 deletions
+7 -5
View File
@@ -1,14 +1,16 @@
import { type FC } from 'react'
import { useGetSections } from './hooks/usePrintData'
import { useDeleteSection, useGetSections } from './hooks/usePrintData'
import { Link } from 'react-router-dom'
import { Paths } from '@/config/Paths'
import Button from '@/components/Button'
import { AddSquare, Edit, More2 } from 'iconsax-react'
import Table from '@/components/Table'
import TrashWithConfrim from '@/components/TrashWithConfrim'
const SectionList: FC = () => {
const { data } = useGetSections()
const { mutate, isPending } = useDeleteSection()
return (
<div className='mt-5'>
@@ -61,11 +63,11 @@ const SectionList: FC = () => {
<Link to={Paths.print.update + item.id}>
<Edit size={20} color='#0037FF' />
</Link>
{/* <TrashWithConfrim
onDelete={() => handleDelete(item.id)}
isloading={isDeleting}
<TrashWithConfrim
onDelete={() => mutate(item.id)}
isloading={isPending}
colorIcon='red'
/> */}
/>
</div>
)
}
+18
View File
@@ -17,8 +17,14 @@ export const useGetSectionsDetail = (id: number) => {
};
export const useCreateSection = () => {
const queryClient = useQueryClient();
return useMutation({
mutationFn: api.createSection,
onSuccess: () => {
queryClient.refetchQueries({
queryKey: ["sections"],
});
},
});
};
@@ -37,3 +43,15 @@ export const useUpdateSection = () => {
},
});
};
export const useDeleteSection = () => {
const queryClient = useQueryClient();
return useMutation({
mutationFn: (id: number) => api.deleteSection(id),
onSuccess: () => {
queryClient.refetchQueries({
queryKey: ["sections"],
});
},
});
};
+5
View File
@@ -26,3 +26,8 @@ export const getSectionDetail = async (id: number) => {
);
return data;
};
export const deleteSection = async (id: number) => {
const { data } = await axios.delete(`/admin/section/${id}`);
return data;
};