From dbee916ad370356154e349f092f0be6e1d83114f Mon Sep 17 00:00:00 2001 From: hamid zarghami Date: Mon, 21 Apr 2025 12:09:01 +0330 Subject: [PATCH] redirect url + accordion + blog + ... --- src/app/about/page.tsx | 52 ++------ src/app/blogs/[id]/page.tsx | 2 - src/app/blogs/components/CreateReview.tsx | 112 ++++++++++++++++++ src/app/blogs/components/SingleBlogPage.tsx | 67 ++++++++++- src/app/blogs/hooks/useBlogsData.ts | 9 +- src/app/blogs/service/BlogService.ts | 12 ++ src/app/blogs/types/BlogTypes.ts | 23 ++++ src/app/contact/page.tsx | 4 +- .../danak-services/DanakServicesContent.tsx | 2 +- src/app/developers/page.tsx | 2 +- src/app/products/DetailService.tsx | 73 ++++++------ src/app/products/components/ServiceHeader.tsx | 10 +- src/components/Accordion.tsx | 47 ++++++++ src/components/Input.tsx | 4 +- src/components/Textarea.tsx | 4 +- src/config/QueryProvider.tsx | 14 ++- src/config/axios.ts | 3 +- src/config/const.ts | 5 + src/config/func.ts | 9 +- src/shared/Header.tsx | 31 ++++- src/shared/hooks/useShareData.ts | 13 ++ src/shared/service/SharedService.ts | 7 ++ src/shared/store/sharedStore.ts | 2 + src/shared/types/SharedTypes.ts | 27 +++++ src/types/error.types.ts | 14 +++ src/types/response.types.ts | 7 ++ 26 files changed, 452 insertions(+), 103 deletions(-) create mode 100644 src/app/blogs/components/CreateReview.tsx create mode 100644 src/components/Accordion.tsx create mode 100644 src/config/const.ts create mode 100644 src/shared/hooks/useShareData.ts create mode 100644 src/shared/service/SharedService.ts create mode 100644 src/types/error.types.ts create mode 100644 src/types/response.types.ts diff --git a/src/app/about/page.tsx b/src/app/about/page.tsx index 87b97a3..35f1ebf 100644 --- a/src/app/about/page.tsx +++ b/src/app/about/page.tsx @@ -1,7 +1,8 @@ import InfoBox from '@/components/InfoBox' -import { AddCircle, TickCircle } from 'iconsax-react' +import { TickCircle } from 'iconsax-react' import { NextPage } from 'next' import React from 'react' +import Accordion from '@/components/Accordion' import WhyDanak from '../home/WhyDanak' const About: NextPage = () => { @@ -63,19 +64,19 @@ const About: NextPage = () => { صادرکنندگان نرم افزار
- صادرکنندگان نرم افزار + مشاوره استقرار ISMS
- صادرکنندگان نرم افزار + نظام صنفی
- صادرکنندگان نرم افزار + GDPR
- صادرکنندگان نرم افزار + ISO:27001
- صادرکنندگان نرم افزار + SSAE18
@@ -93,42 +94,9 @@ const About: NextPage = () => {
-
-
-
- تعهد -
- - -
-
-
-
-
- تعهد -
- - -
-
-
-
-
- تعهد -
- - -
-
+ + +
diff --git a/src/app/blogs/[id]/page.tsx b/src/app/blogs/[id]/page.tsx index 91fbed1..8a66de3 100644 --- a/src/app/blogs/[id]/page.tsx +++ b/src/app/blogs/[id]/page.tsx @@ -14,7 +14,6 @@ interface PageProps { const SingleBlog: NextPage = async ({ params }) => { const { id } = await params - console.log("loading", id); return ( }> @@ -24,7 +23,6 @@ const SingleBlog: NextPage = async ({ params }) => { } async function BlogContent({ id }: { id: string }) { - console.log(id) const queryClient = new QueryClient() await Promise.all([ diff --git a/src/app/blogs/components/CreateReview.tsx b/src/app/blogs/components/CreateReview.tsx new file mode 100644 index 0000000..5b13b40 --- /dev/null +++ b/src/app/blogs/components/CreateReview.tsx @@ -0,0 +1,112 @@ +import { FC } from 'react' +import Input from '../../../components/Input' +import Textarea from '../../../components/Textarea' +import Button from '../../../components/Button' +import { useFormik } from 'formik' +import * as Yup from 'yup' +import { ErrorType } from '../../../helpers/types' +import { toast } from 'react-toastify' +import { useCreateBlogComment } from '../hooks/useBlogsData' +import { CreateBlogCommentType } from '../types/BlogTypes' +import { useSharedStore } from '@/shared/store/sharedStore' +import Link from 'next/link' +import { LOGIN_URL } from '@/config/const' +type Props = { + refetch: () => void + id: string +} + +const CreateReview: FC = ({ refetch, id }) => { + + const { isLogin } = useSharedStore() + + const createReview = useCreateBlogComment() + + const formik = useFormik({ + initialValues: { + title: '', + content: '' + }, + validationSchema: Yup.object({ + title: Yup.string().required('این فیلد الزامی است'), + content: Yup.string().required('این فیلد الزامی است'), + }), + onSubmit: (values) => { + createReview.mutate({ id: id, params: values }, { + onSuccess: () => { + formik.resetForm() + refetch() + }, + onError: (error: ErrorType) => { + if (error.response && 'status' in error.response && error.response.status === 401) { + window.location.href = LOGIN_URL + '?redirect=' + window.location.href + } else { + toast.error(error.response?.data?.error?.message?.[0] || 'An error occurred') + } + } + }) + }, + + }) + + return ( +
+
+ ارسال نظر +
+ + + { + !isLogin ? ( +
+
+ برای ارسال نظر لطفا وارد حساب کاربری خود شوید +
+ +
+ + +
+ + +
+ ) : ( +
+ +
+ +
+ +
+