From 3b409a3c56fd90f7bc4a4986383d82e75773dfb5 Mon Sep 17 00:00:00 2001 From: hamid zarghami Date: Tue, 6 May 2025 12:32:06 +0330 Subject: [PATCH] plan --- src/pages/support/Support.tsx | 41 ++---------- src/pages/support/components/BuyPlan.tsx | 65 +++++++++++++++++++ src/pages/support/components/SidebarHint.tsx | 2 +- .../support/components/SupportSkeleton.tsx | 18 +---- src/pages/support/hooks/useSupportData.ts | 20 +++++- src/pages/support/service/SupportService.ts | 10 +++ 6 files changed, 104 insertions(+), 52 deletions(-) create mode 100644 src/pages/support/components/BuyPlan.tsx diff --git a/src/pages/support/Support.tsx b/src/pages/support/Support.tsx index 6728865..165e6e5 100644 --- a/src/pages/support/Support.tsx +++ b/src/pages/support/Support.tsx @@ -3,27 +3,20 @@ import { Helmet } from 'react-helmet-async' import { useTranslation } from 'react-i18next' import SidebarHint from './components/SidebarHint' import SupportImage from '../../assets/images/support.png' -import Button from '../../components/Button' import { CloseCircle, Document, Element3, TickCircle } from 'iconsax-react' import Tabs from '../../components/Tabs' -import { useBuySupportPlan, useGetSupportPlans } from './hooks/useSupportData' +import { useGetSupportPlans } from './hooks/useSupportData' import { NumberFormat } from '../../config/func' import { PlanItemType, featureItemType } from './types/SupportTypes' import SupportSkeleton from './components/SupportSkeleton' import SupportIcon from './components/SupportIcon' import { SupportPlanFeatureKey } from './enum/SupportEnum' -import { toast } from '../../components/Toast' -import { ErrorType } from '../../helpers/types' -import { useNavigate } from 'react-router-dom' -import { Pages } from '../../config/Pages' +import BuyPlan from './components/BuyPlan' const Support: FC = () => { const { data, isLoading } = useGetSupportPlans() const { t } = useTranslation('global') const [activeTab, setActiveTab] = useState('') - const [loadingPlanId, setLoadingPlanId] = useState('') - const { mutate: buySupportPlan } = useBuySupportPlan() - const navigate = useNavigate() useEffect(() => { if (data?.data?.supportPlans?.length > 0 && !activeTab) { @@ -31,20 +24,6 @@ const Support: FC = () => { } }, [data, activeTab]) - const handleBuy = (planId: string) => { - setLoadingPlanId(planId) - buySupportPlan(planId, { - onSuccess: (data) => { - toast(data?.data?.message, 'success') - navigate(Pages.receipts.detail + data?.data?.invoice?.id) - setLoadingPlanId('') - }, - onError: (error: ErrorType) => { - toast(error?.response?.data?.error.message[0], 'error') - setLoadingPlanId('') - } - }) - } if (isLoading || !data?.data) { return @@ -92,17 +71,14 @@ const Support: FC = () => { ماهیانه
- {NumberFormat(item.price)} + {item.price === 0 ? 'رایگان' : NumberFormat(item.price)}
تومان
-