diff --git a/src/pages/print/List.tsx b/src/pages/print/List.tsx
index 90cd314..d1c3bee 100644
--- a/src/pages/print/List.tsx
+++ b/src/pages/print/List.tsx
@@ -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 (
@@ -61,11 +63,11 @@ const SectionList: FC = () => {
- {/* handleDelete(item.id)}
- isloading={isDeleting}
+ mutate(item.id)}
+ isloading={isPending}
colorIcon='red'
- /> */}
+ />
)
}
diff --git a/src/pages/print/hooks/usePrintData.ts b/src/pages/print/hooks/usePrintData.ts
index d6568ad..a4b0988 100644
--- a/src/pages/print/hooks/usePrintData.ts
+++ b/src/pages/print/hooks/usePrintData.ts
@@ -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"],
+ });
+ },
+ });
+};
diff --git a/src/pages/print/service/PrintService.ts b/src/pages/print/service/PrintService.ts
index c4e1316..5acb631 100644
--- a/src/pages/print/service/PrintService.ts
+++ b/src/pages/print/service/PrintService.ts
@@ -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;
+};