From fbcdf3fccc6bd95c28f012cfd5d40caeaea8bb38 Mon Sep 17 00:00:00 2001 From: deepvasoya Date: Wed, 28 May 2025 11:51:06 +0530 Subject: [PATCH] fix: clinic doc update --- src/components/CustomFileUpload.jsx | 6 - src/services/clinics.service.js | 10 + .../component/GeneralInformation.jsx | 2 +- src/views/ClinicDocUpdate/index.jsx | 190 ++++++++++-------- src/views/PaymentManagement/index.jsx | 2 +- src/views/Signup/YourDetailsForm.jsx | 2 +- src/views/Signup/signupReducer.js | 1 - src/views/ThankYou/index.jsx | 12 +- 8 files changed, 126 insertions(+), 99 deletions(-) diff --git a/src/components/CustomFileUpload.jsx b/src/components/CustomFileUpload.jsx index 4fa1f9c..47e16af 100644 --- a/src/components/CustomFileUpload.jsx +++ b/src/components/CustomFileUpload.jsx @@ -481,12 +481,6 @@ const CustomFileUpload = forwardRef(function CustomFileUpload( - - - {imageName} - - - {!oldUploadedFileUrl ? ( <> diff --git a/src/services/clinics.service.js b/src/services/clinics.service.js index b240d5d..f8244c9 100644 --- a/src/services/clinics.service.js +++ b/src/services/clinics.service.js @@ -49,6 +49,16 @@ export const updateClinicStatus = (data) => { }); }; +export const getClinicDocs = (id) => { + const url = `/clinics/verified-files/${id}`; + return new Promise((resolve, reject) => { + axiosInstance + .get(url) + .then((response) => resolve(response)) + .catch((err) => reject(err)); + }); +}; + export const updateClinicDocs = (id, data) => { const url = `/clinics/${id}`; return new Promise((resolve, reject) => { diff --git a/src/views/ClinicDetails/component/GeneralInformation.jsx b/src/views/ClinicDetails/component/GeneralInformation.jsx index 6f33197..81fe70d 100644 --- a/src/views/ClinicDetails/component/GeneralInformation.jsx +++ b/src/views/ClinicDetails/component/GeneralInformation.jsx @@ -92,7 +92,7 @@ const GeneralInformation = ({ clinicData, clinicAdminData }) => { {clinicAdminData?.designation - ? clinicAdminData?.designation.toUpperCase() + ? clinicAdminData?.designation?.toUpperCase()?.replace(/_/g, ' ') : NOT_AVAILABLE_TEXT} diff --git a/src/views/ClinicDocUpdate/index.jsx b/src/views/ClinicDocUpdate/index.jsx index 8305706..00d9de5 100644 --- a/src/views/ClinicDocUpdate/index.jsx +++ b/src/views/ClinicDocUpdate/index.jsx @@ -5,34 +5,64 @@ import CustomFileUpload from "../../components/CustomFileUpload"; import { useFormik } from "formik"; import * as Yup from "yup"; import { MAX_FILE_SIZE_IN_MB, MAX_FILES } from "../../constants"; -import { updateClinicDocs } from "../../services/clinics.service"; +import { + getClinicDocs, + updateClinicDocs, +} from "../../services/clinics.service"; import { useNavigate } from "react-router-dom"; +import { useSelector } from "react-redux"; const ClinicDocUpdater = () => { const navigate = useNavigate(); + const user = useSelector((state) => state.login.user); // Use state instead of ref for initial form data const [initialFormData, setInitialFormData] = useState({ companyABNImage: "", contract: "", logo: "", clinicId: "", + isABNVerified: false, + isContractVerified: false, + isLogoVerified: false, }); - + // Track if data is loaded const [isDataLoaded, setIsDataLoaded] = useState(false); + const _getClinicDocs = async () => { + try { + const response = await getClinicDocs(user.created_clinics[0].id); + const files = response?.data?.data?.clinic_files; + const clinic = response?.data?.data?.clinic; + setInitialFormData({ + ...initialFormData, + clinicId: user.created_clinics[0].id, + companyABNImage: clinic?.abn_doc, + contract: clinic?.contract_doc, + logo: clinic?.logo, + isABNVerified: files?.abn_doc_is_verified ?? false, + isContractVerified: files?.contract_doc_is_verified ?? false, + isLogoVerified: files?.logo_is_verified ?? false, + }); + } catch (error) { + console.error("Error getting clinic docs:", error); + } + }; + useEffect(() => { // Load user data from localStorage try { const user = JSON.parse(localStorage.getItem("user")); - - if (user && user.created_clinics ) { + + if (user && user.created_clinics) { setInitialFormData({ companyABNImage: user.created_clinics.abn_doc || "", contract: user.created_clinics.contract_doc || "", logo: user.created_clinics.logo || "", clinicId: user.created_clinics.id || "", }); + } else { + _getClinicDocs(); } } catch (error) { console.error("Error loading user data:", error); @@ -48,12 +78,11 @@ const ClinicDocUpdater = () => { }); const handleFormSubmit = async () => { - console.log("Form values:", formik.values); const payload = { abn_doc: formik.values.companyABNImage, contract_doc: formik.values.contract, logo: formik.values.logo, - } + }; const resp = await updateClinicDocs(formik.values.clinicId, payload); console.log(resp); @@ -78,13 +107,8 @@ const ClinicDocUpdater = () => { // Set uploaded file URL const setUploadedFileUrl = (documentName, fileUrl) => { - console.log("Document Name:", documentName); - console.log("File URL:", fileUrl); - console.log("File URL Type:", typeof fileUrl); - if (documentName && fileUrl !== undefined) { formik.setFieldValue(documentName, fileUrl); - console.log("After setting value:", formik.values[documentName]); } else { console.error("Invalid parameters for setUploadedFileUrl:", { documentName, @@ -106,83 +130,83 @@ const ClinicDocUpdater = () => { }} > - Clinic Docs + Clinic Documents {isDataLoaded ? ( -
- - + - - + + + + + + + + + + - - - - - - - - - - + +
+ ) : ( Loading clinic documents... diff --git a/src/views/PaymentManagement/index.jsx b/src/views/PaymentManagement/index.jsx index cd831cb..50dcb50 100644 --- a/src/views/PaymentManagement/index.jsx +++ b/src/views/PaymentManagement/index.jsx @@ -265,7 +265,7 @@ const PaymentManagement = () => { showFilters: true, }} showAction={true} - searchText="Staff" + searchText="Payments" showSearchBox={true} actions={[ { diff --git a/src/views/Signup/YourDetailsForm.jsx b/src/views/Signup/YourDetailsForm.jsx index e902f10..1a7eb5b 100644 --- a/src/views/Signup/YourDetailsForm.jsx +++ b/src/views/Signup/YourDetailsForm.jsx @@ -374,7 +374,7 @@ function YourDetailsForm() { }; const handleFormSubmit = async () => { - dispatch(updateFormDetails(formik.values)); + // dispatch(updateFormDetails(formik.values)); if (!otpField) { pushNotification("Please Request OTP first", NOTIFICATION.ERROR); diff --git a/src/views/Signup/signupReducer.js b/src/views/Signup/signupReducer.js index 9142ba7..54c8a68 100644 --- a/src/views/Signup/signupReducer.js +++ b/src/views/Signup/signupReducer.js @@ -39,7 +39,6 @@ const updateFormDetails = (state, payload) => ({ ...payload, }); const resetFormData = (state) => ({ - ...state, ...initialState, }); diff --git a/src/views/ThankYou/index.jsx b/src/views/ThankYou/index.jsx index 1586483..778a112 100644 --- a/src/views/ThankYou/index.jsx +++ b/src/views/ThankYou/index.jsx @@ -103,7 +103,7 @@ const ThankYou = ({ canClose = true, setShowPopup }) => {
- {faqData.map((faq, index) => ( + {/* {faqData.map((faq, index) => ( } @@ -120,7 +120,7 @@ const ThankYou = ({ canClose = true, setShowPopup }) => { - ))} + ))} */} ) : ( @@ -143,13 +143,13 @@ const ThankYou = ({ canClose = true, setShowPopup }) => { Please wait while 24x7 AIHR team is verifying your details. - + {/* After verification we will send you a link on your registered Email Address. - - */} + {/* { onClick={() => setShowFqaSection(true)} > FAQs - + */} )}