From 342acaac963d20abd9f3caa9521fdc653ef57df3 Mon Sep 17 00:00:00 2001 From: hamid zarghami Date: Sun, 23 Nov 2025 09:59:37 +0330 Subject: [PATCH] structure payment methods --- src/config/Pages.ts | 5 +++++ src/langs/fa.json | 9 ++++++++- src/pages/paymentMethods/List.tsx | 11 +++++++++++ .../paymentMethods/hooks/usePaymentMethodData.ts | 16 ++++++++++++++++ .../service/PaymentMethodService.ts | 11 +++++++++++ src/router/Main.tsx | 3 +++ src/shared/SideBar.tsx | 11 ++++++++++- 7 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 src/pages/paymentMethods/List.tsx create mode 100644 src/pages/paymentMethods/hooks/usePaymentMethodData.ts create mode 100644 src/pages/paymentMethods/service/PaymentMethodService.ts diff --git a/src/config/Pages.ts b/src/config/Pages.ts index aa2fbf6..67fc5dd 100644 --- a/src/config/Pages.ts +++ b/src/config/Pages.ts @@ -10,6 +10,11 @@ export const Pages = { update: "/schedule/update/", create: "/schedule/create", }, + payment_methods: { + list: "/payment_methods/list", + add: "/payment_methods/add", + update: "/payment_methods/update/", + }, foods: { list: "/foods/list", add: "/foods/add", diff --git a/src/langs/fa.json b/src/langs/fa.json index 0ddff8d..b983ea5 100644 --- a/src/langs/fa.json +++ b/src/langs/fa.json @@ -61,7 +61,8 @@ "comments": "نظرات", "setting": "تنظیمات", "logout": "خروج", - "roles": "سطح دسترسی ها" + "roles": "سطح دسترسی ها", + "payment_methods": "روش های پرداخت" }, "slider": { "new_slider": "اسلایدر جدید", @@ -821,5 +822,11 @@ "5": "پنج‌شنبه", "6": "جمعه" } + }, + "payment_methods": { + "payment_methods": "روش های پرداخت", + "payment_methods_list": "لیست روش های پرداخت", + "payment_methods_add": "افزودن روش پرداخت", + "payment_methods_update": "ویرایش روش پرداخت" } } diff --git a/src/pages/paymentMethods/List.tsx b/src/pages/paymentMethods/List.tsx new file mode 100644 index 0000000..0c3d82f --- /dev/null +++ b/src/pages/paymentMethods/List.tsx @@ -0,0 +1,11 @@ +import { type FC } from 'react' + +const PaymentMethodsList: FC = () => { + return ( +
+

لیست روش های پرداخت

+
+ ) +} + +export default PaymentMethodsList \ No newline at end of file diff --git a/src/pages/paymentMethods/hooks/usePaymentMethodData.ts b/src/pages/paymentMethods/hooks/usePaymentMethodData.ts new file mode 100644 index 0000000..fd4682d --- /dev/null +++ b/src/pages/paymentMethods/hooks/usePaymentMethodData.ts @@ -0,0 +1,16 @@ +import * as api from "../service/PaymentMethodService"; +import { useQuery } from "@tanstack/react-query"; + +export const useGetPaymentMethods = () => { + return useQuery({ + queryKey: ["payment-methods"], + queryFn: api.getPaymentMethods, + }); +}; + +export const useGetRestaurantPaymentMethods = () => { + return useQuery({ + queryKey: ["restaurant-payment-methods"], + queryFn: api.getRestaurantPaymentMethods, + }); +}; diff --git a/src/pages/paymentMethods/service/PaymentMethodService.ts b/src/pages/paymentMethods/service/PaymentMethodService.ts new file mode 100644 index 0000000..091c09e --- /dev/null +++ b/src/pages/paymentMethods/service/PaymentMethodService.ts @@ -0,0 +1,11 @@ +import axios from "@/config/axios"; + +export const getPaymentMethods = async () => { + const { data } = await axios.get("/admin/payment-methods"); + return data; +}; + +export const getRestaurantPaymentMethods = async () => { + const { data } = await axios.get("/admin/restaurant-payment-methods"); + return data; +}; diff --git a/src/router/Main.tsx b/src/router/Main.tsx index 3f01c24..d83d144 100644 --- a/src/router/Main.tsx +++ b/src/router/Main.tsx @@ -24,6 +24,7 @@ import CreateRole from '@/pages/roles/Create' import UpdateRole from '@/pages/roles/Update' import UpdateSchedule from '@/pages/schedule/Update' import Setting from '@/pages/settings/Setting' +import PaymentMethodsList from '@/pages/paymentMethods/List' const MainRouter: FC = () => { const { hasSubMenu } = useSharedStore() @@ -59,6 +60,8 @@ const MainRouter: FC = () => { } /> } /> } /> + + } /> diff --git a/src/shared/SideBar.tsx b/src/shared/SideBar.tsx index d45ab9a..1df712d 100644 --- a/src/shared/SideBar.tsx +++ b/src/shared/SideBar.tsx @@ -2,7 +2,7 @@ import { type FC, useEffect } from 'react' import LogoImage from '../assets/images/logo.svg' import LogoSmall from '../assets/images/logo-small.svg' import { useTranslation } from 'react-i18next' -import { DocumentText, Home2, Logout, Message, NotificationStatus, People, Setting2, TicketDiscount, Chart, Calendar, Security } from 'iconsax-react' +import { DocumentText, Home2, Logout, Message, NotificationStatus, People, Setting2, TicketDiscount, Chart, Calendar, Security, Card } from 'iconsax-react' import SideBarItem from './SideBarItem' import { useLocation } from 'react-router-dom' import { Pages } from '../config/Pages' @@ -85,6 +85,15 @@ const SideBar: FC = () => { activeName='schedule' /> + } + title={t('sidebar.payment_methods')} + isActive={isActive('payment_methods')} + link={Pages.payment_methods.list} + name='payment_methods' + activeName='payment_methods' + /> + } title={t('sidebar.orders')}