From a6788fdaeffe2b157c7fd41a70ee9ce398b1508c Mon Sep 17 00:00:00 2001 From: baslani Date: Tue, 18 Nov 2025 15:05:38 +0330 Subject: [PATCH] implemented referal action for privacy office --- .../RowActions/Forms/ReferForm.jsx | 43 ++++++++++++++++--- .../RowActions/RenderActionForm.jsx | 2 +- 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ReferForm.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ReferForm.jsx index 46af9d4..30477f7 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ReferForm.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ReferForm.jsx @@ -1,19 +1,37 @@ +import { PRIVACY_ADMIN_ACTION_API } from "@/core/utils/routes"; +import useRequest from "@/lib/hooks/useRequest"; import { Box, Button, DialogActions, TextField } from "@mui/material"; import { useState } from "react"; import { Controller, useForm } from "react-hook-form"; -export default function ReferForm({ mutate, onClose }) { +export default function ReferForm({ mutate, onClose, rowId }) { const [isSubmitting, setIsSubmitting] = useState(false); - const { control, handleSubmit } = useForm({ + const request = useRequest({ notificationSuccess: true }); + + const { + control, + handleSubmit, + formState: { errors }, + } = useForm({ defaultValues: { expert_description: "", }, }); const onSubmit = (data) => { - console.log(data); setIsSubmitting(true); - mutate(); + try { + request(`${PRIVACY_ADMIN_ACTION_API}/refer_request/${rowId}`, "post", { + data, + }).then(() => { + onClose(); + mutate(); + }); + } catch (error) { + console.log(error); + } finally { + setIsSubmitting(false); + } }; return ( @@ -21,14 +39,27 @@ export default function ReferForm({ mutate, onClose }) { } + rules={{ + required: "توضیحات الزامی است", + }} + render={({ field }) => ( + + )} /> diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RenderActionForm.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RenderActionForm.jsx index 874916c..63a1305 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RenderActionForm.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RenderActionForm.jsx @@ -12,7 +12,7 @@ export default function RenderActionForm({ type, rowData, mutate, onClose }) { function renderForm() { switch (formType) { case "refer_request_2": - return ; + return ; case "reject_request_2": return ; case "reject_request_5":