diff --git a/src/config/Pages.ts b/src/config/Pages.ts
index 888cd56..6f37809 100644
--- a/src/config/Pages.ts
+++ b/src/config/Pages.ts
@@ -204,5 +204,6 @@ export const Pages = {
learning: "/sellers/learning",
learningCreate: "/sellers/learning/create",
learningUpdate: "/sellers/learning/update/",
+ contract: "/sellers/contract",
},
};
diff --git a/src/pages/seller/Contract.tsx b/src/pages/seller/Contract.tsx
new file mode 100644
index 0000000..fd80a4e
--- /dev/null
+++ b/src/pages/seller/Contract.tsx
@@ -0,0 +1,100 @@
+import { type FC } from 'react'
+import { useFormik } from 'formik'
+import * as Yup from 'yup'
+import { useGetContentContract, useUpdateContract } from './hooks/useSellerData'
+import PageLoading from '@/components/PageLoading'
+import Error from '@/components/Error'
+import Button from '@/components/Button'
+import TextEditor from '@/components/TextEditor'
+import { TickCircle } from 'iconsax-react'
+import { toast } from 'react-toastify'
+import { extractErrorMessage } from '@/helpers/utils'
+
+const validationSchema = Yup.object().shape({
+ content: Yup.string().required('محتوای قرارداد الزامی است')
+})
+
+const ContractPage: FC = () => {
+ const { data: contentContract, isLoading, error } = useGetContentContract()
+ const updateContractMutation = useUpdateContract()
+
+ const contract = contentContract?.results?.contract
+ const isDataLoaded = !!contract
+
+ const formik = useFormik({
+ initialValues: {
+ id: contract?._id || '',
+ content: contract?.content || '
در حال بارگذاری...
'
+ },
+ validationSchema,
+ enableReinitialize: true,
+ onSubmit: async (values) => {
+ updateContractMutation.mutate({
+ id: values.id,
+ content: values.content
+ }, {
+ onSuccess: () => {
+ toast.success('قرارداد با موفقیت بروزرسانی شد')
+ },
+ onError: (error) => {
+ toast.error(extractErrorMessage(error))
+ }
+ })
+ }
+ })
+
+
+ if (isLoading) {
+ return
+ }
+
+ if (error) {
+ return
+ }
+
+ return (
+
+
+
+
مدیریت قرارداد فروشندگان
+
+
+
+
+
+
+
+
+
محتوای قرارداد
+
+
+
formik.setFieldValue('content', value)}
+ placeholder='محتوای قرارداد را وارد کنید...'
+ height='h-[400px]'
+ />
+ {formik.touched.content && formik.errors.content && (
+
+ {String(formik.errors.content)}
+
+ )}
+
+
+
+
+ )
+}
+
+export default ContractPage
\ No newline at end of file
diff --git a/src/pages/seller/hooks/useSellerData.ts b/src/pages/seller/hooks/useSellerData.ts
index 07a5908..b6470e0 100644
--- a/src/pages/seller/hooks/useSellerData.ts
+++ b/src/pages/seller/hooks/useSellerData.ts
@@ -133,3 +133,16 @@ export const useDeleteLearning = () => {
},
});
};
+
+export const useGetContentContract = () => {
+ return useQuery({
+ queryKey: ["content-contract"],
+ queryFn: api.getContentContract,
+ });
+};
+
+export const useUpdateContract = () => {
+ return useMutation({
+ mutationFn: api.updateContract,
+ });
+};
diff --git a/src/pages/seller/service/SellerService.ts b/src/pages/seller/service/SellerService.ts
index 2445887..5589b17 100644
--- a/src/pages/seller/service/SellerService.ts
+++ b/src/pages/seller/service/SellerService.ts
@@ -11,6 +11,7 @@ import type {
GetLearningCategoryResponse,
GetLearningResponse,
CreateLearningType,
+ UpdateContractType,
} from "../types/Types";
export const getSellers = async (
@@ -144,3 +145,16 @@ export const deleteLearning = async (id: string) => {
const { data } = await axios.delete(`/admin/learning/${id}`);
return data;
};
+
+export const getContentContract = async () => {
+ const { data } = await axios.get(`/admin/settings/contract`);
+ return data;
+};
+
+export const updateContract = async (params: UpdateContractType) => {
+ const { data } = await axios.patch(
+ `/admin/settings/contract/${params.id}/update`,
+ params
+ );
+ return data;
+};
diff --git a/src/pages/seller/types/Types.ts b/src/pages/seller/types/Types.ts
index ce59b9d..c41cceb 100644
--- a/src/pages/seller/types/Types.ts
+++ b/src/pages/seller/types/Types.ts
@@ -362,3 +362,21 @@ export interface CreateLearningType {
cover: string;
category: string;
}
+
+export interface ContractResponse {
+ status: number;
+ success: boolean;
+ results: {
+ contract: {
+ _id: string;
+ content: string;
+ createdAt: string;
+ updatedAt: string;
+ };
+ };
+}
+
+export interface UpdateContractType {
+ id: string;
+ content: string;
+}
diff --git a/src/router/Main.tsx b/src/router/Main.tsx
index 060cd26..52137cf 100644
--- a/src/router/Main.tsx
+++ b/src/router/Main.tsx
@@ -71,6 +71,7 @@ import CategoryLearning from '@/pages/seller/CategoryLearning'
import Learning from '@/pages/seller/Learning'
import CreateLearning from '@/pages/seller/CreateLearning'
import UpdateLearning from '@/pages/seller/UpdateLearning'
+import ContractPage from '@/pages/seller/Contract'
const MainRouter: FC = () => {
const { hasSubMenu } = useSharedStore()
@@ -175,6 +176,7 @@ const MainRouter: FC = () => {
} />
} />
} />
+ } />
diff --git a/src/shared/SideBar.tsx b/src/shared/SideBar.tsx
index d25c826..614d669 100644
--- a/src/shared/SideBar.tsx
+++ b/src/shared/SideBar.tsx
@@ -523,8 +523,8 @@ const SellersSubMenu: FC = () => {
/>
{
isActive={isActive('category')}
link={Pages.sellers.learningCategory}
/>
+
+
)