fix: clinic doc update
This commit is contained in:
parent
24c600ac32
commit
fbcdf3fccc
|
|
@ -481,12 +481,6 @@ const CustomFileUpload = forwardRef(function CustomFileUpload(
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<Grid container>
|
|
||||||
<Grid item md={12} className={classes.previewFileTitle}>
|
|
||||||
<Typography color="white">{imageName}</Typography>
|
|
||||||
</Grid>
|
|
||||||
</Grid>
|
|
||||||
|
|
||||||
<Grid xs={12} className={classes.previewImageGrid}>
|
<Grid xs={12} className={classes.previewImageGrid}>
|
||||||
{!oldUploadedFileUrl ? (
|
{!oldUploadedFileUrl ? (
|
||||||
<>
|
<>
|
||||||
|
|
|
||||||
|
|
@ -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) => {
|
export const updateClinicDocs = (id, data) => {
|
||||||
const url = `/clinics/${id}`;
|
const url = `/clinics/${id}`;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ const GeneralInformation = ({ clinicData, clinicAdminData }) => {
|
||||||
<Box>
|
<Box>
|
||||||
<Typography className={classes.companyUserDetailsTitle}>
|
<Typography className={classes.companyUserDetailsTitle}>
|
||||||
{clinicAdminData?.designation
|
{clinicAdminData?.designation
|
||||||
? clinicAdminData?.designation.toUpperCase()
|
? clinicAdminData?.designation?.toUpperCase()?.replace(/_/g, ' ')
|
||||||
: NOT_AVAILABLE_TEXT}
|
: NOT_AVAILABLE_TEXT}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography className={classes.companyUserDetailsSubTitle}>
|
<Typography className={classes.companyUserDetailsSubTitle}>
|
||||||
|
|
|
||||||
|
|
@ -5,34 +5,64 @@ import CustomFileUpload from "../../components/CustomFileUpload";
|
||||||
import { useFormik } from "formik";
|
import { useFormik } from "formik";
|
||||||
import * as Yup from "yup";
|
import * as Yup from "yup";
|
||||||
import { MAX_FILE_SIZE_IN_MB, MAX_FILES } from "../../constants";
|
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 { useNavigate } from "react-router-dom";
|
||||||
|
import { useSelector } from "react-redux";
|
||||||
|
|
||||||
const ClinicDocUpdater = () => {
|
const ClinicDocUpdater = () => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
const user = useSelector((state) => state.login.user);
|
||||||
// Use state instead of ref for initial form data
|
// Use state instead of ref for initial form data
|
||||||
const [initialFormData, setInitialFormData] = useState({
|
const [initialFormData, setInitialFormData] = useState({
|
||||||
companyABNImage: "",
|
companyABNImage: "",
|
||||||
contract: "",
|
contract: "",
|
||||||
logo: "",
|
logo: "",
|
||||||
clinicId: "",
|
clinicId: "",
|
||||||
|
isABNVerified: false,
|
||||||
|
isContractVerified: false,
|
||||||
|
isLogoVerified: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Track if data is loaded
|
// Track if data is loaded
|
||||||
const [isDataLoaded, setIsDataLoaded] = useState(false);
|
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(() => {
|
useEffect(() => {
|
||||||
// Load user data from localStorage
|
// Load user data from localStorage
|
||||||
try {
|
try {
|
||||||
const user = JSON.parse(localStorage.getItem("user"));
|
const user = JSON.parse(localStorage.getItem("user"));
|
||||||
|
|
||||||
if (user && user.created_clinics ) {
|
if (user && user.created_clinics) {
|
||||||
setInitialFormData({
|
setInitialFormData({
|
||||||
companyABNImage: user.created_clinics.abn_doc || "",
|
companyABNImage: user.created_clinics.abn_doc || "",
|
||||||
contract: user.created_clinics.contract_doc || "",
|
contract: user.created_clinics.contract_doc || "",
|
||||||
logo: user.created_clinics.logo || "",
|
logo: user.created_clinics.logo || "",
|
||||||
clinicId: user.created_clinics.id || "",
|
clinicId: user.created_clinics.id || "",
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
_getClinicDocs();
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error loading user data:", error);
|
console.error("Error loading user data:", error);
|
||||||
|
|
@ -48,12 +78,11 @@ const ClinicDocUpdater = () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleFormSubmit = async () => {
|
const handleFormSubmit = async () => {
|
||||||
console.log("Form values:", formik.values);
|
|
||||||
const payload = {
|
const payload = {
|
||||||
abn_doc: formik.values.companyABNImage,
|
abn_doc: formik.values.companyABNImage,
|
||||||
contract_doc: formik.values.contract,
|
contract_doc: formik.values.contract,
|
||||||
logo: formik.values.logo,
|
logo: formik.values.logo,
|
||||||
}
|
};
|
||||||
|
|
||||||
const resp = await updateClinicDocs(formik.values.clinicId, payload);
|
const resp = await updateClinicDocs(formik.values.clinicId, payload);
|
||||||
console.log(resp);
|
console.log(resp);
|
||||||
|
|
@ -78,13 +107,8 @@ const ClinicDocUpdater = () => {
|
||||||
|
|
||||||
// Set uploaded file URL
|
// Set uploaded file URL
|
||||||
const setUploadedFileUrl = (documentName, fileUrl) => {
|
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) {
|
if (documentName && fileUrl !== undefined) {
|
||||||
formik.setFieldValue(documentName, fileUrl);
|
formik.setFieldValue(documentName, fileUrl);
|
||||||
console.log("After setting value:", formik.values[documentName]);
|
|
||||||
} else {
|
} else {
|
||||||
console.error("Invalid parameters for setUploadedFileUrl:", {
|
console.error("Invalid parameters for setUploadedFileUrl:", {
|
||||||
documentName,
|
documentName,
|
||||||
|
|
@ -106,7 +130,7 @@ const ClinicDocUpdater = () => {
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Typography variant="h6" component="div">
|
<Typography variant="h6" component="div">
|
||||||
Clinic Docs
|
Clinic Documents
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
{isDataLoaded ? (
|
{isDataLoaded ? (
|
||||||
|
|
@ -123,9 +147,6 @@ const ClinicDocUpdater = () => {
|
||||||
<Grid
|
<Grid
|
||||||
container
|
container
|
||||||
spacing={5}
|
spacing={5}
|
||||||
// padding={`0 ${theme.spacing(3.2)}`}
|
|
||||||
// className={classes.formRoot}
|
|
||||||
// sx={{ display: "flex" }}
|
|
||||||
>
|
>
|
||||||
<Grid item md={4} sm={12} xs={12}>
|
<Grid item md={4} sm={12} xs={12}>
|
||||||
<CustomFileUpload
|
<CustomFileUpload
|
||||||
|
|
@ -141,6 +162,7 @@ const ClinicDocUpdater = () => {
|
||||||
? formik.errors.companyABNImage
|
? formik.errors.companyABNImage
|
||||||
: ""
|
: ""
|
||||||
}
|
}
|
||||||
|
isDisabled={formik.values.isABNVerified}
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item md={4} sm={12} xs={12}>
|
<Grid item md={4} sm={12} xs={12}>
|
||||||
|
|
@ -156,6 +178,7 @@ const ClinicDocUpdater = () => {
|
||||||
? formik.errors.contract
|
? formik.errors.contract
|
||||||
: ""
|
: ""
|
||||||
}
|
}
|
||||||
|
isDisabled={formik.values.isContractVerified}
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item md={4} sm={12} xs={12}>
|
<Grid item md={4} sm={12} xs={12}>
|
||||||
|
|
@ -171,6 +194,7 @@ const ClinicDocUpdater = () => {
|
||||||
? formik.errors.logo
|
? formik.errors.logo
|
||||||
: ""
|
: ""
|
||||||
}
|
}
|
||||||
|
isDisabled={formik.values.isLogoVerified}
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
|
||||||
|
|
@ -265,7 +265,7 @@ const PaymentManagement = () => {
|
||||||
showFilters: true,
|
showFilters: true,
|
||||||
}}
|
}}
|
||||||
showAction={true}
|
showAction={true}
|
||||||
searchText="Staff"
|
searchText="Payments"
|
||||||
showSearchBox={true}
|
showSearchBox={true}
|
||||||
actions={[
|
actions={[
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -374,7 +374,7 @@ function YourDetailsForm() {
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleFormSubmit = async () => {
|
const handleFormSubmit = async () => {
|
||||||
dispatch(updateFormDetails(formik.values));
|
// dispatch(updateFormDetails(formik.values));
|
||||||
|
|
||||||
if (!otpField) {
|
if (!otpField) {
|
||||||
pushNotification("Please Request OTP first", NOTIFICATION.ERROR);
|
pushNotification("Please Request OTP first", NOTIFICATION.ERROR);
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,6 @@ const updateFormDetails = (state, payload) => ({
|
||||||
...payload,
|
...payload,
|
||||||
});
|
});
|
||||||
const resetFormData = (state) => ({
|
const resetFormData = (state) => ({
|
||||||
...state,
|
|
||||||
...initialState,
|
...initialState,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,7 @@ const ThankYou = ({ canClose = true, setShowPopup }) => {
|
||||||
</Typography>
|
</Typography>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
{faqData.map((faq, index) => (
|
{/* {faqData.map((faq, index) => (
|
||||||
<Accordion key={index}>
|
<Accordion key={index}>
|
||||||
<AccordionSummary
|
<AccordionSummary
|
||||||
expandIcon={<ExpandMoreIcon />}
|
expandIcon={<ExpandMoreIcon />}
|
||||||
|
|
@ -120,7 +120,7 @@ const ThankYou = ({ canClose = true, setShowPopup }) => {
|
||||||
</Typography>
|
</Typography>
|
||||||
</AccordionDetails>
|
</AccordionDetails>
|
||||||
</Accordion>
|
</Accordion>
|
||||||
))}
|
))} */}
|
||||||
</Box>
|
</Box>
|
||||||
) : (
|
) : (
|
||||||
<Box className={classes.thankYouTitle}>
|
<Box className={classes.thankYouTitle}>
|
||||||
|
|
@ -143,13 +143,13 @@ const ThankYou = ({ canClose = true, setShowPopup }) => {
|
||||||
Please wait while 24x7 AIHR team is verifying your details.
|
Please wait while 24x7 AIHR team is verifying your details.
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
<Box>
|
{/*<Box>
|
||||||
<Typography className={classes.description}>
|
<Typography className={classes.description}>
|
||||||
After verification we will send you a link on your
|
After verification we will send you a link on your
|
||||||
registered Email Address.
|
registered Email Address.
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>*/}
|
||||||
<LoadingButton
|
{/* <LoadingButton
|
||||||
className={classes.faqButton}
|
className={classes.faqButton}
|
||||||
size="small"
|
size="small"
|
||||||
type="submit"
|
type="submit"
|
||||||
|
|
@ -157,7 +157,7 @@ const ThankYou = ({ canClose = true, setShowPopup }) => {
|
||||||
onClick={() => setShowFqaSection(true)}
|
onClick={() => setShowFqaSection(true)}
|
||||||
>
|
>
|
||||||
FAQs
|
FAQs
|
||||||
</LoadingButton>
|
</LoadingButton> */}
|
||||||
</Box>
|
</Box>
|
||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue