Go to Dashboard
@@ -79,3 +143,5 @@ useEffect(() => {
};
export default VerifiedPayment;
+
+
diff --git a/src/hooks/useAuth.jsx b/src/hooks/useAuth.jsx
index ed45725e..11558b8a 100644
--- a/src/hooks/useAuth.jsx
+++ b/src/hooks/useAuth.jsx
@@ -16,6 +16,7 @@ import {
import { removeSession } from "../utils/authUtils.js";
import showToast from "../services/toastService.tsx";
import eventBus from "../services/eventBus.js";
+import { blockUI } from "../utils/blockUI.js";
// ----------------------------Modal--------------------------
@@ -39,7 +40,7 @@ export const useSubscription = (frequency) => {
const resp = await AuthRepository.getSubscription(frequency);
return resp.data;
},
- enabled: frequency !== null && frequency !== undefined
+ enabled: frequency !== null && frequency !== undefined,
});
};
@@ -88,18 +89,53 @@ export const useCreateSelfTenant = (onSuccessCallBack, onFailureCallBack) => {
return resp.data;
},
onSuccess: (response, variables) => {
-
dispatch(
setSelfTenant({
tenantEnquireId: response?.id,
planId: null,
- details:response
+ details: response,
})
);
if (onSuccessCallBack) onSuccessCallBack(response);
},
onError: (error) => {
- showToast("Somthing worng went happend", "error");
+ showToast(
+ `${error?.response?.data?.errors || ""} ${
+ error?.response?.data?.message || ""
+ } ${error?.response?.data?.statusCode || ""}`.trim() ||
+ error?.message ||
+ "Something went wrong, please try again!",
+ "error"
+ );
+
+ if (onFailureCallBack) onFailureCallBack();
+ },
+ });
+};
+
+export const useSelfGetSubscription = (
+ onSuccessCallBack,
+ onFailureCallBack
+) => {
+ const dispatch = useDispatch();
+ return useMutation({
+ mutationFn: async (payload) => {
+ blockUI();
+ const resp = await AuthRepository.selfCreateSubscription(payload);
+ return resp.data;
+ },
+ onSuccess: (response, variables) => {
+ if (onSuccessCallBack) onSuccessCallBack(response);
+ },
+ onError: (error) => {
+ showToast(
+ `${error?.response?.data?.errors || ""} ${
+ error?.response?.data?.message || ""
+ } ${error?.response?.data?.statusCode || ""}`.trim() ||
+ error?.message ||
+ "Something went wrong, please try again!",
+ "error"
+ );
if (onFailureCallBack) onFailureCallBack();
},
});
diff --git a/src/hooks/usePayment.jsx b/src/hooks/usePayment.jsx
index bfe19fe8..fcbf44d1 100644
--- a/src/hooks/usePayment.jsx
+++ b/src/hooks/usePayment.jsx
@@ -1,8 +1,9 @@
import { useMutation, useQueryClient } from "@tanstack/react-query";
import { PaymentRepository } from "../repositories/PaymentRepository";
import showToast from "../services/toastService";
-import { useSelector } from "react-redux";
+import { useDispatch, useSelector } from "react-redux";
import { blockUI, unblockUI } from "../utils/blockUI";
+import { setSelfTenant } from "../slices/localVariablesSlice";
export const removeRazorpayArtifacts=()=> {
try {
@@ -56,11 +57,13 @@ const closeRazorpayPopup=()=> {
export const useVerifyPayment = (onSuccessCallBack, onFailureCallBack) => {
const client = useQueryClient();
+ const dispatch = useDispatch()
return useMutation({
mutationFn: (payload) => PaymentRepository.verifyPayment(payload),
onSuccess: (data) => {
+ dispatch(setSelfTenant({ paymentDetailId: data?.data?.id }));
if (onSuccessCallBack) onSuccessCallBack(data);
},
diff --git a/src/pages/Home/MakeSubscription.jsx b/src/pages/Home/MakeSubscription.jsx
index 1995fe03..12456155 100644
--- a/src/pages/Home/MakeSubscription.jsx
+++ b/src/pages/Home/MakeSubscription.jsx
@@ -97,10 +97,9 @@ const MakeSubscription = () => {
name: "Verified",
component: () => (
{
- setStepStatus((prev) => ({ ...prev, 5: "success" }))
- }}
- responsePayment={responsePayment}
+ responsePayment={responsePayment}
+ setStepStatus={setStepStatus}
+
/>
),
},
diff --git a/src/repositories/AuthRepository.jsx b/src/repositories/AuthRepository.jsx
index 81c677b3..61cbc1d6 100644
--- a/src/repositories/AuthRepository.jsx
+++ b/src/repositories/AuthRepository.jsx
@@ -12,7 +12,9 @@ const AuthRepository = {
sendMail: (data) => api.postPublic("/api/auth/sendmail", data),
getSubscription: (frequency) =>
api.getPublic(`/api/market/list/subscription-plan?frequency=${frequency}`),
- createSuscription:(data)=>api.post(`/api/Tenant/self/create`,data),
+ createSuscription: (data) => api.post(`/api/Tenant/self/create`, data), // this will put entry inside enquiry table
+ selfCreateSubscription: (data) =>
+ api.post(`/api/Tenant/self/subscription`, data),
// Protected routes (require auth token)
logout: (data) => api.post("/api/auth/logout", data),
diff --git a/src/slices/localVariablesSlice.jsx b/src/slices/localVariablesSlice.jsx
index f80780bd..fba4390c 100644
--- a/src/slices/localVariablesSlice.jsx
+++ b/src/slices/localVariablesSlice.jsx
@@ -37,6 +37,7 @@ const localVariablesSlice = createSlice({
planId: null,
details:null,
frequency:null,
+ paymentDetailId:null
},
},
reducers: {
@@ -111,6 +112,7 @@ const localVariablesSlice = createSlice({
state.selfTenant.details =
action.payload.details ?? state.selfTenant.details;
state.selfTenant.frequency = action.payload.frequency ?? state.selfTenant.frequency;
+ state.selfTenant.paymentDetailId = action.payload.paymentDetailId ?? state.selfTenant.paymentDetailId;
},
},
});