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',
|
||||
INACTIVE: 'inactive',
|
||||
PAYMENT_DUE: "payment_due",
|
||||
};
|
||||
|
||||
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) => {
|
||||
const url = `/admin/clinic/status`;
|
||||
return new Promise((resolve, reject) => {
|
||||
|
|
|
|||
|
|
@ -246,10 +246,6 @@ function ClinicDetails() {
|
|||
setButtonClickStatus("Rejected");
|
||||
};
|
||||
|
||||
const handleOnHoldClick = () => {
|
||||
setIsShowReasonModel(true);
|
||||
setButtonClickStatus("On Hold");
|
||||
};
|
||||
|
||||
const handleAcceptClick = () => {
|
||||
// setIsShowReasonModel(true);
|
||||
|
|
|
|||
|
|
@ -211,8 +211,8 @@ const ClinicsList = () => {
|
|||
label={
|
||||
status === CLINIC_STATUS.UNDER_REVIEW.toLowerCase() ? (
|
||||
"Under Review"
|
||||
) : status === CLINIC_STATUS.NOT_REVIEWED ? (
|
||||
"Approval Pending"
|
||||
) : status === CLINIC_STATUS.PAYMENT_DUE ? (
|
||||
"Payment Due"
|
||||
) : status ===
|
||||
CLINIC_STATUS.APPROVAL_PENDING_DOCUMENT_RESUBMITTED ? (
|
||||
<div>
|
||||
|
|
@ -231,7 +231,7 @@ const ClinicsList = () => {
|
|||
backgroundColor:
|
||||
status === CLINIC_STATUS.ON_HOLD.toLowerCase()
|
||||
? theme.palette.orange.light
|
||||
: status === CLINIC_STATUS.NOT_REVIEWED.toLowerCase() ||
|
||||
: status === CLINIC_STATUS.PAYMENT_DUE.toLowerCase() ||
|
||||
status === CLINIC_STATUS.REJECTED.toLowerCase()
|
||||
? theme.palette.primary.highlight
|
||||
: status ===
|
||||
|
|
@ -241,7 +241,7 @@ const ClinicsList = () => {
|
|||
color:
|
||||
status === CLINIC_STATUS.ON_HOLD.toLowerCase()
|
||||
? theme.palette.orange.main
|
||||
: status === CLINIC_STATUS.NOT_REVIEWED.toLowerCase() ||
|
||||
: status === CLINIC_STATUS.PAYMENT_DUE.toLowerCase() ||
|
||||
status === CLINIC_STATUS.REJECTED.toLowerCase()
|
||||
? theme.palette.primary.main
|
||||
: status ===
|
||||
|
|
|
|||
|
|
@ -46,6 +46,15 @@ const SuperAdminTotals = ({ isLoading, data }) => {
|
|||
color={theme.palette.grey[57]}
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item>
|
||||
<TotalNumber
|
||||
heading={`Payment Due`}
|
||||
isLoading={isLoading}
|
||||
viewAllClick={() => viewAllClick(false)}
|
||||
value={rejected}
|
||||
color={theme.palette.grey[57]}
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item>
|
||||
<TotalNumber
|
||||
heading={"Total Requests"}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ const SuperAdmin = () => {
|
|||
registrationRequest: 0,
|
||||
rejected: 0,
|
||||
registered: 0,
|
||||
paymentDue: 0,
|
||||
});
|
||||
|
||||
const fetchDashboardStats = async () => {
|
||||
|
|
@ -26,6 +27,7 @@ const SuperAdmin = () => {
|
|||
registrationRequest: apiData?.totalUnderReviewClinics,
|
||||
rejected: apiData?.totalRejectedClinics,
|
||||
registered: apiData?.totalActiveClinics,
|
||||
paymentDue: apiData?.totalPaymentDueClinics,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("Error fetching data:", error);
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import { selectUserRole, setUserRole } from "../../redux/userRoleSlice";
|
|||
import Totals from "./Tiles/Totals";
|
||||
import { useStyles } from "./dashboardStyles";
|
||||
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 { useNavigate } from "react-router-dom";
|
||||
import { updateFormDetails } from "../Signup/signupAction";
|
||||
|
|
@ -66,6 +66,23 @@ function Dashboard() {
|
|||
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"){
|
||||
// setIsActive(false);
|
||||
// pushNotification("Payment due", NOTIFICATION.WARNING);
|
||||
|
|
|
|||
|
|
@ -94,10 +94,6 @@ function YourDetailsForm() {
|
|||
const selectedLocalityRef = useRef();
|
||||
const [testConnection, setTestConnDone] = useState(false);
|
||||
|
||||
const errorStatus = new URLSearchParams(window.location.search).get("status");
|
||||
|
||||
console.log(errorStatus);
|
||||
|
||||
useEffect(() => {
|
||||
setIsLoading(true);
|
||||
getLatestClinicId().then((res) => {
|
||||
|
|
@ -397,8 +393,14 @@ function YourDetailsForm() {
|
|||
return;
|
||||
}
|
||||
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());
|
||||
navigate("/auth/signup/payment");
|
||||
navigate("/");
|
||||
} catch (error) {
|
||||
console.error("Error signing up:", error);
|
||||
} finally {
|
||||
|
|
|
|||
Loading…
Reference in New Issue