feat: payment dues handling
This commit is contained in:
parent
d3d33912ed
commit
3073ef90b8
|
|
@ -43,6 +43,7 @@ export const CLINIC_STATUS = {
|
||||||
APPROVAL_PENDING_DOCUMENT_RESUBMITTED:
|
APPROVAL_PENDING_DOCUMENT_RESUBMITTED:
|
||||||
'APPROVAL_PENDING_DOCUMENT_RESUBMITTED',
|
'APPROVAL_PENDING_DOCUMENT_RESUBMITTED',
|
||||||
INACTIVE: 'inactive',
|
INACTIVE: 'inactive',
|
||||||
|
PAYMENT_DUE: "payment_due",
|
||||||
};
|
};
|
||||||
|
|
||||||
export const CLINIC_DOCUMENT_STATUS = {
|
export const CLINIC_DOCUMENT_STATUS = {
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,16 @@ export const getClinicsById = (id) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const generatePaymentSession = () =>{
|
||||||
|
const url = `/stripe/create-payment-session`;
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
axiosInstance
|
||||||
|
.post(url)
|
||||||
|
.then((response) => resolve(response))
|
||||||
|
.catch((err) => reject(err));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export const updateClinicStatus = (data) => {
|
export const updateClinicStatus = (data) => {
|
||||||
const url = `/admin/clinic/status`;
|
const url = `/admin/clinic/status`;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
|
|
||||||
|
|
@ -246,10 +246,6 @@ function ClinicDetails() {
|
||||||
setButtonClickStatus("Rejected");
|
setButtonClickStatus("Rejected");
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleOnHoldClick = () => {
|
|
||||||
setIsShowReasonModel(true);
|
|
||||||
setButtonClickStatus("On Hold");
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleAcceptClick = () => {
|
const handleAcceptClick = () => {
|
||||||
// setIsShowReasonModel(true);
|
// setIsShowReasonModel(true);
|
||||||
|
|
|
||||||
|
|
@ -211,8 +211,8 @@ const ClinicsList = () => {
|
||||||
label={
|
label={
|
||||||
status === CLINIC_STATUS.UNDER_REVIEW.toLowerCase() ? (
|
status === CLINIC_STATUS.UNDER_REVIEW.toLowerCase() ? (
|
||||||
"Under Review"
|
"Under Review"
|
||||||
) : status === CLINIC_STATUS.NOT_REVIEWED ? (
|
) : status === CLINIC_STATUS.PAYMENT_DUE ? (
|
||||||
"Approval Pending"
|
"Payment Due"
|
||||||
) : status ===
|
) : status ===
|
||||||
CLINIC_STATUS.APPROVAL_PENDING_DOCUMENT_RESUBMITTED ? (
|
CLINIC_STATUS.APPROVAL_PENDING_DOCUMENT_RESUBMITTED ? (
|
||||||
<div>
|
<div>
|
||||||
|
|
@ -231,7 +231,7 @@ const ClinicsList = () => {
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
status === CLINIC_STATUS.ON_HOLD.toLowerCase()
|
status === CLINIC_STATUS.ON_HOLD.toLowerCase()
|
||||||
? theme.palette.orange.light
|
? theme.palette.orange.light
|
||||||
: status === CLINIC_STATUS.NOT_REVIEWED.toLowerCase() ||
|
: status === CLINIC_STATUS.PAYMENT_DUE.toLowerCase() ||
|
||||||
status === CLINIC_STATUS.REJECTED.toLowerCase()
|
status === CLINIC_STATUS.REJECTED.toLowerCase()
|
||||||
? theme.palette.primary.highlight
|
? theme.palette.primary.highlight
|
||||||
: status ===
|
: status ===
|
||||||
|
|
@ -241,7 +241,7 @@ const ClinicsList = () => {
|
||||||
color:
|
color:
|
||||||
status === CLINIC_STATUS.ON_HOLD.toLowerCase()
|
status === CLINIC_STATUS.ON_HOLD.toLowerCase()
|
||||||
? theme.palette.orange.main
|
? theme.palette.orange.main
|
||||||
: status === CLINIC_STATUS.NOT_REVIEWED.toLowerCase() ||
|
: status === CLINIC_STATUS.PAYMENT_DUE.toLowerCase() ||
|
||||||
status === CLINIC_STATUS.REJECTED.toLowerCase()
|
status === CLINIC_STATUS.REJECTED.toLowerCase()
|
||||||
? theme.palette.primary.main
|
? theme.palette.primary.main
|
||||||
: status ===
|
: status ===
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,15 @@ const SuperAdminTotals = ({ isLoading, data }) => {
|
||||||
color={theme.palette.grey[57]}
|
color={theme.palette.grey[57]}
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
<Grid item>
|
||||||
|
<TotalNumber
|
||||||
|
heading={`Payment Due`}
|
||||||
|
isLoading={isLoading}
|
||||||
|
viewAllClick={() => viewAllClick(false)}
|
||||||
|
value={rejected}
|
||||||
|
color={theme.palette.grey[57]}
|
||||||
|
/>
|
||||||
|
</Grid>
|
||||||
<Grid item>
|
<Grid item>
|
||||||
<TotalNumber
|
<TotalNumber
|
||||||
heading={"Total Requests"}
|
heading={"Total Requests"}
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ const SuperAdmin = () => {
|
||||||
registrationRequest: 0,
|
registrationRequest: 0,
|
||||||
rejected: 0,
|
rejected: 0,
|
||||||
registered: 0,
|
registered: 0,
|
||||||
|
paymentDue: 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
const fetchDashboardStats = async () => {
|
const fetchDashboardStats = async () => {
|
||||||
|
|
@ -26,6 +27,7 @@ const SuperAdmin = () => {
|
||||||
registrationRequest: apiData?.totalUnderReviewClinics,
|
registrationRequest: apiData?.totalUnderReviewClinics,
|
||||||
rejected: apiData?.totalRejectedClinics,
|
rejected: apiData?.totalRejectedClinics,
|
||||||
registered: apiData?.totalActiveClinics,
|
registered: apiData?.totalActiveClinics,
|
||||||
|
paymentDue: apiData?.totalPaymentDueClinics,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error fetching data:", error);
|
console.error("Error fetching data:", error);
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import { selectUserRole, setUserRole } from "../../redux/userRoleSlice";
|
||||||
import Totals from "./Tiles/Totals";
|
import Totals from "./Tiles/Totals";
|
||||||
import { useStyles } from "./dashboardStyles";
|
import { useStyles } from "./dashboardStyles";
|
||||||
import { NOTIFICATION, USER_ROLES } from "../../constants";
|
import { NOTIFICATION, USER_ROLES } from "../../constants";
|
||||||
import { getClinicsById } from "../../services/clinics.service";
|
import { generatePaymentSession, getClinicsById } from "../../services/clinics.service";
|
||||||
import { pushNotification } from "../../utils/notification";
|
import { pushNotification } from "../../utils/notification";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { updateFormDetails } from "../Signup/signupAction";
|
import { updateFormDetails } from "../Signup/signupAction";
|
||||||
|
|
@ -66,6 +66,23 @@ function Dashboard() {
|
||||||
navigation("/docs");
|
navigation("/docs");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(status=="payment_due"){
|
||||||
|
setIsActive(false);
|
||||||
|
pushNotification("Payment due", NOTIFICATION.WARNING);
|
||||||
|
const session = await generatePaymentSession();
|
||||||
|
|
||||||
|
if(session?.data?.error){
|
||||||
|
pushNotification(session?.data?.message, NOTIFICATION.ERROR);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const newWindow = window.open(session?.data?.data, "_blank", "noopener,noreferrer");
|
||||||
|
if (!newWindow || newWindow.closed || typeof newWindow.closed === 'undefined') {
|
||||||
|
// Fallback in case popup is blocked
|
||||||
|
window.location.href = session?.data?.data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// if(status=="payment_due"){
|
// if(status=="payment_due"){
|
||||||
// setIsActive(false);
|
// setIsActive(false);
|
||||||
// pushNotification("Payment due", NOTIFICATION.WARNING);
|
// pushNotification("Payment due", NOTIFICATION.WARNING);
|
||||||
|
|
|
||||||
|
|
@ -94,10 +94,6 @@ function YourDetailsForm() {
|
||||||
const selectedLocalityRef = useRef();
|
const selectedLocalityRef = useRef();
|
||||||
const [testConnection, setTestConnDone] = useState(false);
|
const [testConnection, setTestConnDone] = useState(false);
|
||||||
|
|
||||||
const errorStatus = new URLSearchParams(window.location.search).get("status");
|
|
||||||
|
|
||||||
console.log(errorStatus);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
getLatestClinicId().then((res) => {
|
getLatestClinicId().then((res) => {
|
||||||
|
|
@ -397,8 +393,14 @@ function YourDetailsForm() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pushNotification(response?.data?.message, NOTIFICATION.SUCCESS);
|
pushNotification(response?.data?.message, NOTIFICATION.SUCCESS);
|
||||||
|
// open new page for stripe payment from url
|
||||||
|
const newWindow = window.open(response?.data?.data, "_blank", "noopener,noreferrer");
|
||||||
|
if (!newWindow || newWindow.closed || typeof newWindow.closed === 'undefined') {
|
||||||
|
// Fallback in case popup is blocked
|
||||||
|
window.location.href = response?.data?.data;
|
||||||
|
}
|
||||||
dispatch(resetFormData());
|
dispatch(resetFormData());
|
||||||
navigate("/auth/signup/payment");
|
navigate("/");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error signing up:", error);
|
console.error("Error signing up:", error);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue