diff --git a/src/config/Pages.ts b/src/config/Pages.ts index 6f37809..0bd6970 100644 --- a/src/config/Pages.ts +++ b/src/config/Pages.ts @@ -32,7 +32,11 @@ export const Pages = { list: "/tickets/list", create: "/tickets/create", detail: "/tickets/messages/", - category: "/tickets/category", + category: { + list: "/tickets/category", + create: "/tickets/category/create", + update: "/tickets/category/update/", + }, }, announcement: { list: "/announcement", diff --git a/src/pages/ticket/Category.tsx b/src/pages/ticket/Category.tsx new file mode 100644 index 0000000..d090be6 --- /dev/null +++ b/src/pages/ticket/Category.tsx @@ -0,0 +1,85 @@ +import { type FC } from 'react' +import { useGetTicketCategories } from './hooks/useTicketData' +import { type ITicketCategory } from './types/Types' +import { Pages } from '../../config/Pages' +import Button from '../../components/Button' +import Td from '../../components/Td' +import { useNavigate } from 'react-router-dom' +import PageLoading from '../../components/PageLoading' + +const Category: FC = () => { + const navigate = useNavigate() + const { data, isLoading } = useGetTicketCategories() + // const deleteCategoryMutation = useDeleteTicketCategory() + + // const handleDeleteCategory = async (categoryId: string) => { + // await deleteCategoryMutation.mutateAsync(categoryId) + // refetch() + // } + + if (isLoading) { + return ( +
+ +
+ ) + } + + const categories = data?.results?.categories || [] + + return ( +
+
+
+
+ + + + + + + {categories.length === 0 ? ( + + + + ) : ( + categories.map((category: ITicketCategory) => ( + + */} + + )) + )} + +
+ + + + {/* */} +
+ هیچ دسته‌بندی یافت نشد +
+ + + + {/* +
+ + + + handleDeleteCategory(category._id)} + isLoading={deleteCategoryMutation.isPending} + /> +
+
+
+
+ ) +} + +export default Category \ No newline at end of file diff --git a/src/pages/ticket/Create.tsx b/src/pages/ticket/Create.tsx new file mode 100644 index 0000000..a51d0fa --- /dev/null +++ b/src/pages/ticket/Create.tsx @@ -0,0 +1,88 @@ +import { useFormik } from 'formik' +import { type FC } from 'react' +import { useCreateTicketCategory } from './hooks/useTicketData' +import type { CreateTicketCategoryType } from './types/Types' +import * as Yup from 'yup' +import { useNavigate } from 'react-router-dom' +import Input from '../../components/Input' +import Textarea from '../../components/Textarea' +import Button from '../../components/Button' +import { TickCircle } from 'iconsax-react' +import { toast } from 'react-toastify' +import { extractErrorMessage } from '@/helpers/utils' +import { Pages } from '../../config/Pages' + +const Create: FC = () => { + const navigate = useNavigate() + const createCategoryMutation = useCreateTicketCategory() + + const formik = useFormik({ + initialValues: { + title_fa: "", + description: "", + }, + validationSchema: Yup.object({ + title_fa: Yup.string().required("عنوان الزامی است"), + description: Yup.string().required("توضیحات الزامی است"), + }), + onSubmit: async (values) => { + createCategoryMutation.mutate(values, { + onSuccess: () => { + toast.success('دسته‌بندی با موفقیت ایجاد شد') + navigate(Pages.ticket.category.list) + }, + onError: (error) => { + toast.error(extractErrorMessage(error)) + } + }) + } + }) + + return ( +
+
+
+

ساخت دسته‌بندی جدید

+
+
+ +
+
+ +
+ {/* اطلاعات اصلی */} +
+

اطلاعات دسته‌بندی

+ +
+ + +