diff --git a/src/components/ServiceItem.tsx b/src/components/ServiceItem.tsx index 351be5a..4cca2e8 100644 --- a/src/components/ServiceItem.tsx +++ b/src/components/ServiceItem.tsx @@ -31,7 +31,7 @@ const ServiceItem: FC = (props: Props) => {
{item.description}
-
+
: getMyservices.data?.data?.subscriptions?.map((item: MyServicesItem) => { - const active = getQuikAccess.data?.data?.quickAccesses?.find((o: any) => o.service?.id === item.plan?.service?.id) ? true : false + const active = getQuikAccess.data?.data?.quickAccesses?.find((o: any) => o.userSubscription?.id === item?.id) ? true : false return (
@@ -129,7 +129,7 @@ const BoxNewAccessbility: FC = () => {
diff --git a/src/pages/home/components/DanakLearning.tsx b/src/pages/home/components/DanakLearning.tsx index e87affa..021120f 100644 --- a/src/pages/home/components/DanakLearning.tsx +++ b/src/pages/home/components/DanakLearning.tsx @@ -1,11 +1,16 @@ import { FC } from 'react' import { useTranslation } from 'react-i18next' import { ArrowLeft } from 'iconsax-react' -import CoverImage from '../../../assets/images/banner.png' +import { useGetLearnings } from '../../learning/hooks/useLearningData' +import { LearningItemType } from '../../learning/types/LearningTypes' +import moment from 'moment-jalaali' +import { Link } from 'react-router-dom' +import { Pages } from '../../../config/Pages' const DanakLearning: FC = () => { const { t } = useTranslation('global') + const getLearnings = useGetLearnings('', 5) return (
@@ -13,31 +18,38 @@ const DanakLearning: FC = () => {
{t('home.danak_learning')}
-
+
{t('home.see_all')}
-
+
-
-
- danak-learning-1 -
+ { + getLearnings.data?.data?.learnings?.map((item: LearningItemType) => { + return ( +
+ + danak-learning-1 + -
-
- لورم ایپسوم متن ساختگی با تولید سادگی -
-
-
دیزاین ,
-
۲۴ دقیقه
-
-
- آذر ماه 1403 -
-
-
+
+
+ {item.title} +
+
+
{item.category.name} ,
+
{item.videoDuration} دقیقه
+
+
+ {moment(item.createdAt).format('jYYYY/jMM/jDD')} +
+
+
+ ) + } + ) + }
) diff --git a/src/pages/learning/hooks/useLearningData.ts b/src/pages/learning/hooks/useLearningData.ts index cf4c6bf..cb9b908 100644 --- a/src/pages/learning/hooks/useLearningData.ts +++ b/src/pages/learning/hooks/useLearningData.ts @@ -1,10 +1,10 @@ import { useQuery } from "@tanstack/react-query"; import * as api from "../service/LearningService"; -export const useGetLearnings = (search: string) => { +export const useGetLearnings = (search: string, limit?: number) => { return useQuery({ - queryKey: ["learnings", search], - queryFn: () => api.getLearnings(search), + queryKey: ["learnings", search, limit], + queryFn: () => api.getLearnings(search, limit), }); }; diff --git a/src/pages/learning/service/LearningService.ts b/src/pages/learning/service/LearningService.ts index 2cc0aa3..f80447b 100644 --- a/src/pages/learning/service/LearningService.ts +++ b/src/pages/learning/service/LearningService.ts @@ -1,7 +1,9 @@ import axios from "../../../config/axios"; -export const getLearnings = async (search: string) => { - const { data } = await axios.get(`/learnings?q=${search}`); +export const getLearnings = async (search: string, limit?: number) => { + const { data } = await axios.get( + `/learnings?q=${search}&limit=${limit ? limit : 20}` + ); return data; }; diff --git a/src/pages/receipts/List.tsx b/src/pages/receipts/List.tsx index afb28a6..40c18db 100644 --- a/src/pages/receipts/List.tsx +++ b/src/pages/receipts/List.tsx @@ -1,7 +1,7 @@ import { FC, useState } from 'react' import { useTranslation } from 'react-i18next' import Tabs from '../../components/Tabs' -import { CloseCircle, Eye, FolderOpen, WalletCheck, WalletRemove } from 'iconsax-react' +import { CloseCircle, Eye, FolderOpen, WalletCheck, WalletRemove, WalletSearch } from 'iconsax-react' import Td from '../../components/Td' import { Link } from 'react-router-dom' import { Pages } from '../../config/Pages' @@ -15,7 +15,7 @@ import { Helmet } from 'react-helmet-async' const ReceiptsList: FC = () => { const { t } = useTranslation('global') - const [activeTab, setActiveTab] = useState<"PENDING" | "PAID" | "CANCELED" | "EXPIRED">('PENDING') + const [activeTab, setActiveTab] = useState<"PENDING" | "WAIT_PAYMENT" | "PAID" | "CANCELLED" | "EXPIRED">('PENDING') const getInvoices = useGetInvoices(activeTab) return ( @@ -34,19 +34,24 @@ const ReceiptsList: FC = () => { active={activeTab} items={[ { - icon: , - label: t('receip.dont_pay'), + icon: , + label: t('receip.pending'), value: 'PENDING' }, + { + icon: , + label: t('receip.dont_pay'), + value: 'WAIT_PAYMENT' + }, { icon: , label: t('receip.paid'), value: 'PAID' }, { - icon: , + icon: , label: t('receip.canceled'), - value: 'CANCELED' + value: 'CANCELLED' }, { icon: , @@ -54,7 +59,7 @@ const ReceiptsList: FC = () => { value: 'EXPIRED' }, ]} - onChange={(value) => setActiveTab(value as "PENDING" | "PAID" | "CANCELED" | "EXPIRED")} + onChange={(value) => setActiveTab(value as "PENDING" | "PAID" | "CANCELLED" | "EXPIRED")} />
diff --git a/src/pages/service/BuyService.tsx b/src/pages/service/BuyService.tsx index 01d04c0..8c72660 100644 --- a/src/pages/service/BuyService.tsx +++ b/src/pages/service/BuyService.tsx @@ -1,13 +1,54 @@ import { FC } from 'react' -import { useParams } from 'react-router-dom' -import { useGetDetailService } from './hooks/useServiceData' +import { useNavigate, useParams } from 'react-router-dom' +import { useBuyService, useGetDetailService } from './hooks/useServiceData' import HeaderBuy from './components/HeaderBuy' import PageLoading from '../../components/PageLoading' +import Button from '../../components/Button' +import { TickCircle } from 'iconsax-react' +import Textarea from '../../components/Textarea' +import Input from '../../components/Input' +import { useTranslation } from 'react-i18next' +import { useFormik } from 'formik' +import * as Yup from 'yup' +import { BuyServiceType } from './types/ServiecTypes' +import { toast } from 'react-toastify' +import { ErrorType } from '../../helpers/types' +import { Pages } from '../../config/Pages' const BuyService: FC = () => { + const { t } = useTranslation('global') + const navigate = useNavigate() const { serviceId, planId } = useParams() const getDetailService = useGetDetailService(serviceId ? serviceId : '') + const buyService = useBuyService() + + const formik = useFormik({ + initialValues: { + businessName: '', + businessPhone: '', + description: '', + planId: planId ? planId : '', + serviceId: serviceId ? serviceId : '' + }, + validationSchema: Yup.object({ + businessName: Yup.string().required(t('errors.required')), + businessPhone: Yup.string().required(t('errors.required')), + description: Yup.string().required(t('errors.required')), + planId: Yup.string().required(t('errors.required')) + }), + onSubmit: (values) => { + buyService.mutate(values, { + onSuccess: () => { + toast.success(t('success')) + navigate(Pages.services.mine) + }, + onError: (error: ErrorType) => { + toast.error(error.response?.data?.error.message[0]) + } + }) + } + }) return (
@@ -17,6 +58,57 @@ const BuyService: FC = () => { :
+ +
+
+
+ {t('service.info_business')} +
+ +
+ {t('service.enter_info_business')} +
+
+ +
+
+ +
+
+ +
+
+