diff --git a/src/config/Pages.ts b/src/config/Pages.ts index 33b0c7e..a3ed756 100644 --- a/src/config/Pages.ts +++ b/src/config/Pages.ts @@ -110,5 +110,6 @@ export const Pages = { create: "/support/create", list: "/support/list", detail: "/support/detail/", + planUsers: "/support/plan-users/", }, }; diff --git a/src/config/SideBarSubMenu.ts b/src/config/SideBarSubMenu.ts index 73ef588..e3e9467 100644 --- a/src/config/SideBarSubMenu.ts +++ b/src/config/SideBarSubMenu.ts @@ -6,4 +6,5 @@ export const SideBarItemHasSubMenu = [ "tickets", "learning", "blog", + "support", ]; diff --git a/src/langs/fa.json b/src/langs/fa.json index 6745cb8..8468ef7 100644 --- a/src/langs/fa.json +++ b/src/langs/fa.json @@ -102,7 +102,10 @@ "add_user": "افزودن کاربر", "role_list": "لیست نقش ها", "role_create": "افزودن نقش", - "reviews": "نظرات" + "reviews": "نظرات", + "create_plan": "ایجاد پلن", + "plan_users": "کاربران پلن", + "plan_list": "لیست پلن ها" }, "review": { "title": "عنوان", @@ -779,12 +782,23 @@ "on_site_support": "پشتیبانی در محل", "on_site_training": "آموزش در محل", "ticket_limit": "ظرفیت ارسال تیکت", + "technical_issue_resolution": "رفع ایراد فنی", + "service_functionality_test": "تست عملکرد سرویس", "plans": "پلن ها", "plan_name": "نام پلن", "price": "قیمت", "duration": "مدت", "features": "ویژگی ها", "actions": "عملیات", - "new_plan": "پلن جدید" + "new_plan": "پلن جدید", + "plan_users": "کاربران ", + "ACTIVE": "فعال", + "INACTIVE": "غیرفعال", + "EXPIRED": "منقضی شده", + "start_date": "تاریخ شروع", + "end_date": "تاریخ پایان", + "status": "وضعیت", + "full_name": "نام و نام خانوادگی", + "users": "کاربران" } } diff --git a/src/pages/support/List.tsx b/src/pages/support/List.tsx index e8e1285..45c61a1 100644 --- a/src/pages/support/List.tsx +++ b/src/pages/support/List.tsx @@ -41,17 +41,28 @@ const SupportList: FC = () => { + { - data?.data?.supportPlans?.map((item: { id: string, name: string, price: number, duration: string }) => { + data?.data?.supportPlans?.map((item: { id: string, name: string, price: number, duration: string, userCount: number }) => { return ( + + +
+
+ {item.userCount} +
+ کاربر +
+ +
diff --git a/src/pages/support/PlanUsers.tsx b/src/pages/support/PlanUsers.tsx new file mode 100644 index 0000000..4835d07 --- /dev/null +++ b/src/pages/support/PlanUsers.tsx @@ -0,0 +1,56 @@ +import { FC } from 'react' +import { useTranslation } from 'react-i18next' +import { useGetPlanUsers } from './hooks/useSupportData' +import { useParams } from 'react-router-dom' +import Td from '../../components/Td' +import moment from 'moment-jalaali' +import { PlanItemUserType } from './types/SupportTypes' +const PlanUsers: FC = () => { + + const { t } = useTranslation('global') + const { id } = useParams() + const { data } = useGetPlanUsers(id) + + return ( +
+
+ {t('support.plan_users')} {data?.data?.users?.[0]?.supportPlan?.name} +
+ +
+ + + + + + + {data?.data?.users?.map((item: PlanItemUserType) => ( + + + + + ))} + +
+ + + + +
+ +
+ {moment(item.startDate).format('jYYYY/jMM/jDD HH:mm')} +
+
+
+ {moment(item.endDate).format('jYYYY/jMM/jDD HH:mm')} +
+
+ +
+
+
+ ) +} + +export default PlanUsers \ No newline at end of file diff --git a/src/pages/support/enum/SupportEnum.ts b/src/pages/support/enum/SupportEnum.ts index 1c587d2..87a640e 100644 --- a/src/pages/support/enum/SupportEnum.ts +++ b/src/pages/support/enum/SupportEnum.ts @@ -1,11 +1,13 @@ export enum SupportPlanFeatureKey { LEARNING_DOCS = "learning_docs", // راهنما و مستندات آموزشی TICKET_SUPPORT = "ticket_support", // ارسال تیکت + TICKET_LIMIT = "ticket_limit", // ظرفیت ارسال تیکت RESPONSE_TIME = "response_time", // زمان پاسخگویی به تیکت PHONE_SUPPORT = "phone_support", // پاسخگویی تلفنی - BACKUP_VERSION = "backup_version", // نسخه بکاپ + TECHNICAL_ISSUE_RESOLUTION = "technical_issue_resolution", // رفع ایراد فنی TECHNICAL_EXPERT_ACCESS = "technical_expert_access", // دسترسی به متخصصین فنی + BACKUP_VERSION = "backup_version", // نسخه بکاپ + SERVICE_FUNCTIONALITY_TEST = "service_functionality_test", // تست عملکرد سرویس ON_SITE_SUPPORT = "on_site_support", // پشتیبانی در محل ON_SITE_TRAINING = "on_site_training", // آموزش در محل - TICKET_LIMIT = "ticket_limit", // ظرفیت ارسال تیکت } diff --git a/src/pages/support/hooks/useSupportData.ts b/src/pages/support/hooks/useSupportData.ts index 6a6056d..0af201a 100644 --- a/src/pages/support/hooks/useSupportData.ts +++ b/src/pages/support/hooks/useSupportData.ts @@ -34,3 +34,11 @@ export const useDeletePlan = () => { mutationFn: (id: string) => api.deletePlan(id), }); }; + +export const useGetPlanUsers = (id?: string) => { + return useQuery({ + queryKey: ["plan-users", id], + queryFn: () => api.getPlanUsers(id), + enabled: !!id, + }); +}; diff --git a/src/pages/support/service/SupportService.ts b/src/pages/support/service/SupportService.ts index fd879ad..6c31d8c 100644 --- a/src/pages/support/service/SupportService.ts +++ b/src/pages/support/service/SupportService.ts @@ -25,3 +25,8 @@ export const deletePlan = async (id: string) => { const { data } = await axios.delete(`/support-plans/${id}`); return data; }; + +export const getPlanUsers = async (id?: string) => { + const { data } = await axios.get(`/support-plans/${id}/users`); + return data; +}; diff --git a/src/pages/support/types/SupportTypes.ts b/src/pages/support/types/SupportTypes.ts index 15450d5..c92b316 100644 --- a/src/pages/support/types/SupportTypes.ts +++ b/src/pages/support/types/SupportTypes.ts @@ -10,3 +10,40 @@ export type CreatePlanType = { featureType: "boolean" | "text"; }[]; }; + +export type PlanItemUserType = { + id: string; + createdAt: string; + updatedAt: string; + user: { + id: string; + createdAt: string; + updatedAt: string; + email: string; + phone: string; + userName: string; + firstName: string; + lastName: string; + birthDate: string; + nationalCode: string; + profilePic: string | null; + emailVerified: boolean; + financialType: string; + deletedAt: string | null; + }; + supportPlan: { + id: string; + createdAt: string; + updatedAt: string; + name: string; + description: string; + price: number; + isFree: boolean; + duration: number; + isActive: boolean; + deletedAt: string | null; + }; + startDate: string; + endDate: string; + status: string; +}; diff --git a/src/router/Main.tsx b/src/router/Main.tsx index a21201d..eb19e22 100644 --- a/src/router/Main.tsx +++ b/src/router/Main.tsx @@ -68,6 +68,7 @@ import Comments from '../pages/blog/Comments' import CreatePlan from '../pages/support/Create' import SupportList from '../pages/support/List' import UpdateSupport from '../pages/support/Update' +import PlanUsers from '../pages/support/PlanUsers' const MainRouter: FC = () => { const { hasSubMenu } = useSharedStore() @@ -147,6 +148,7 @@ const MainRouter: FC = () => { } /> } /> } /> + } />
diff --git a/src/shared/SideBar.tsx b/src/shared/SideBar.tsx index ca191d3..b99d592 100644 --- a/src/shared/SideBar.tsx +++ b/src/shared/SideBar.tsx @@ -17,6 +17,7 @@ import UsersSubMenu from './components/UsersSubMenu' import LearningSubMenu from './components/LearningSubMenu' import BlogSubMenu from './components/BlogSubMenu' import { useGetProfile } from '../pages/profile/hooks/useProfileData' +import SupportSubMenu from './components/SupportSubMenu' const SideBar: FC = () => { const { t } = useTranslation('global') @@ -324,7 +325,9 @@ const SideBar: FC = () => { : subMenuName === 'blog' ? - : null + : subMenuName === 'support' ? + + : null } } diff --git a/src/shared/components/SupportSubMenu.tsx b/src/shared/components/SupportSubMenu.tsx new file mode 100644 index 0000000..9e0c9c8 --- /dev/null +++ b/src/shared/components/SupportSubMenu.tsx @@ -0,0 +1,47 @@ +import { Headphone } from 'iconsax-react' +import { FC } from 'react' +import { useTranslation } from 'react-i18next' +import { useLocation } from 'react-router-dom' +import { Pages } from '../../config/Pages' +import SubMenuItem from './SubMenuItem' + +const SupportSubMenu: FC = () => { + + const location = useLocation() + const { t } = useTranslation('global') + + + const isActive = (name: string) => { + return location.pathname.includes(name) + } + + + return
+
+ +
+ {t('sidebar.support')} +
+
+ +
+ + +
+ +
+} + +export default SupportSubMenu \ No newline at end of file