diff --git a/.gitignore b/.gitignore index a547bf3..fc5ae9f 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,4 @@ dist-ssr *.njsproj *.sln *.sw? +.vercel diff --git a/src/components/Textarea.tsx b/src/components/Textarea.tsx new file mode 100644 index 0000000..0e738a7 --- /dev/null +++ b/src/components/Textarea.tsx @@ -0,0 +1,39 @@ +import type { FC, InputHTMLAttributes } from 'react' +import Error from './Error' +import { clx } from '../helpers/utils' + +type Props = { + label?: string, + error_text?: string +} & InputHTMLAttributes + +const Textarea: FC = (props: Props) => { + return ( +
+ { + props.label && + + } + + + { + props.error_text && + + } + +
+ ) +} + +export default Textarea \ No newline at end of file diff --git a/src/config/Paths.tsx b/src/config/Paths.tsx index 8037ed8..98d50ac 100644 --- a/src/config/Paths.tsx +++ b/src/config/Paths.tsx @@ -5,7 +5,9 @@ export const Paths = { newOrder: '/new-order', orderDetails: '/order/', tickets: { - list: '/tickets', + list: '/tickets/list', + create: '/tickets/create', + detail: '/tickets/detail/', }, announcement: { list: '/announcement', diff --git a/src/locale/fa.ts b/src/locale/fa.ts index b4a6511..e7e1d3c 100644 --- a/src/locale/fa.ts +++ b/src/locale/fa.ts @@ -42,4 +42,56 @@ export const fa = { uploadBox: { selectFile: "انتخاب فایل", }, + ticket: { + tickets: "تیکت‌ها", + new_ticket: "تیکت جدید", + all: "همه", + checking: "در حال بررسی", + answered: "پاسخ داده شده", + closed: "بسته شده", + number: "شماره", + title: "عنوان", + category: "دسته‌بندی", + service: "سرویس", + date: "تاریخ", + status: "وضعیت", + priority: "اولویت", + detail: "جزئیات", + PENDING: "در حال بررسی", + ANSWERED: "پاسخ داده شده", + CLOSED: "بسته شده", + HIGH: "بالا", + MEDIUM: "متوسط", + LOW: "پایین", + subject: "موضوع", + select_your_service: "انتخاب سرویس شما", + user_name: "نام کاربر", + expert: "کارشناس", + answer: "پاسخ", + your_description: "توضیحات شما", + attachment: "پیوست", + send: "ارسال", + send_answer: "ارسال پاسخ", + close_ticket: "بستن تیکت", + info_ticket: "اطلاعات تیکت", + ticket_number: "شماره تیکت", + asignto: "واگذار شده به", + low: "پایین", + medium: "متوسط", + high: "بالا", + update_sms: "اطلاع‌رسانی از طریق پیامک", + name: "نام", + email: "ایمیل", + enter_your_subject: "موضوع خود را وارد کنید", + not_once: "یکبار نیست", + submit_your_message: "پیام خود را ارسال کنید", + title_hint: "راهنمای تیکت", + }, + select: "انتخاب کنید", + description: "توضیحات", + attach: "پیوست", + success: "موفقیت‌آمیز", + errors: { + required: "این فیلد الزامی است", + }, }; diff --git a/src/pages/ticket/CreateTicket.tsx b/src/pages/ticket/CreateTicket.tsx new file mode 100644 index 0000000..ca52ffa --- /dev/null +++ b/src/pages/ticket/CreateTicket.tsx @@ -0,0 +1,277 @@ +import { type FC, useState } from 'react' +// import { useTranslation } from 'react-i18next' +import Input from '../../components/Input' +import Select from '../../components/Select' +// import Textarea from '../../components/Textarea' +import UploadBox from '../../components/UploadBox' +import Button from '../../components/Button' +import { TickCircle, TickSquare } from 'iconsax-react' +// import { useCreateTicket, useGetCategoriesTicket, useMultiUpload } from './hooks/useTicketData' +// import { useGetProfile } from '../profile/hooks/useProfileData' +import { staticCategoriesData, staticProfileData, staticServicesData } from './data/staticData' +// import PageLoading from '../../components/PageLoading' +// import { useFormik } from 'formik' +// import { type CreateTicketType } from './types/TicketTypes' +// import * as Yup from 'yup' +// import { toast } from '../../components/Toast' +// import { type ErrorType } from '../../helpers/types' +// import { useNavigate } from 'react-router-dom' +// import { Pages } from '../../config/Pages' +// import { useGetMyServices } from '../service/hooks/useServiceData' +// import { MyServicesItem } from '../service/types/ServiecTypes' +// import { Helmet } from 'react-helmet-async' +import { fa } from '@/locale/fa' +import Textarea from '@/components/Textarea' + +const CreateTicket: FC = () => { + + // const { t } = useTranslation('global') + const t = (key: string): string => { + const keys = key.split('.'); + let value: unknown = fa; + for (const k of keys) { + value = (value as Record)?.[k]; + } + return (value as string) || key; + } + // const navigate = useNavigate() + const [_files, setFiles] = useState([]) + const [percent] = useState(0) + // const getProfile = useGetProfile() + // const getCategories = useGetCategoriesTicket() + // const multiUpload = useMultiUpload(setPercent) + // const createTicket = useCreateTicket() + // const getMyservice = useGetMyServices('') + + // استفاده از داده‌های استاتیک + const getProfile = { + isPending: false, + data: staticProfileData + } + const getCategories = { + isPending: false, + data: staticCategoriesData + } + const multiUpload = { + isPending: false, + mutateAsync: () => Promise.resolve() + } + const createTicket = { + isPending: false, + mutate: () => { } + } + const getMyservice = { + isPending: false, + data: staticServicesData + } + + // Mock formik + const formik = { + values: { + subject: '', + message: '', + categoryId: '', + priority: 'LOW', + danakServiceId: '', + title: '', + attachmentUrls: [] + }, + handleChange: () => { }, + handleSubmit: () => { }, + resetForm: () => { }, + touched: { + subject: false, + priority: false, + danakServiceId: false, + categoryId: false, + message: false + }, + errors: { + subject: '', + priority: '', + danakServiceId: '', + categoryId: '', + message: '' + } + } + + + return ( +
+ {/* + + داناک | ایجاد تیکت + + */} +
+ {t('ticket.new_ticket')} +
+ + { + getProfile.isPending || getCategories.isPending ? +
Loading...
+ : +
+
+
+ {t('ticket.submit_your_message')} +
+ +
+ + +
+ + +
+ + ) => { + const plan = item.plan as Record; + const service = plan?.service as Record; + return { + label: service?.name as string, + value: service?.id as string + }; + }) + } + onChange={formik.handleChange} + error_text={formik.touched.danakServiceId && formik.errors.danakServiceId ? formik.errors.danakServiceId : ''} + /> +