diff --git a/src/components/UserSubscription/Review.jsx b/src/components/UserSubscription/Review.jsx
new file mode 100644
index 00000000..a7c6ccd4
--- /dev/null
+++ b/src/components/UserSubscription/Review.jsx
@@ -0,0 +1,11 @@
+import React from 'react'
+
+const Review = () => {
+ return (
+
+
+
+ )
+}
+
+export default Review
diff --git a/src/components/UserSubscription/SelectPlan.jsx b/src/components/UserSubscription/SelectPlan.jsx
new file mode 100644
index 00000000..ace3d2cf
--- /dev/null
+++ b/src/components/UserSubscription/SelectPlan.jsx
@@ -0,0 +1,238 @@
+import React, { useEffect, useState } from "react";
+import { useDispatch, useSelector } from "react-redux";
+import { useParams } from "react-router-dom";
+import { useSubscription } from "../../hooks/useAuth";
+import { formatFigure, frequencyLabel } from "../../utils/appUtils";
+import { setSelfTenant } from "../../slices/localVariablesSlice";
+
+const SelectPlan = ({ currentStep, setStepStatus, onNext }) => {
+ const { frequency, planName } = useParams();
+ const dispatch = useDispatch();
+
+ const client = useSelector(
+ (store) => store.localVariables.selfTenant.details
+ );
+ const [selectedPlan, setSelectedPlan] = useState(planName);
+ const [currentPlan, setCurrentPlan] = useState(null);
+ const [failPayment, setFailPayment] = useState(null);
+
+ const {
+ data: plans,
+ isError: isPlanError,
+ isLoading,
+ } = useSubscription(frequency);
+
+ const handleChange = (e) => setSelectedPlan(e.target.value);
+
+ useEffect(() => {
+ if (!plans || !selectedPlan) return;
+ const selected = plans.find((p) => p.planName === selectedPlan);
+ if (selected) {
+ setCurrentPlan(selected);
+ dispatch(setSelfTenant({ planId: selected.id }));
+ }
+ }, [plans, selectedPlan, dispatch]);
+
+ const handleNextStep = () => {
+ setStepStatus((prev) => ({ ...prev, 2: "success"}));
+ onNext();
+ };
+
+ return (
+
+
+
+
+
+
Choose the Perfect Plan for Your Organization
+
+ Select a plan that fits your team’s needs and unlock the
+ features that drive productivity.
+
+
+
+ {plans?.map((plan) => (
+
+
+
+
+
+ {plan?.planName}
+
+ {plan.currency?.symbol} {plan.price} /{" "}
+ {frequencyLabel(frequency)}
+
+
+
+ {plan?.description}
+
+
+
+
+ ))}
+
+ {selectedPlan && (
+
+
+ {(() => {
+ const selected = plans?.find(
+ (p) => p.planName === selectedPlan
+ );
+ if (!selected) return null;
+
+ const {
+ price,
+ frequency,
+ trialDays,
+ maxUser,
+ maxStorage,
+ currency,
+ features,
+ } = selected;
+
+ return (
+ <>
+
+
+
+
+ Max Users: {maxUser}
+
+
+
+
+
+ Max Storage: {maxStorage} MB
+
+
+
+
+
+ Trial Days: {trialDays}
+
+
+
+
+
+ Included Features
+
+
+ {features &&
+ Object.entries(features?.modules || {})
+ .filter(([key]) => key !== "id")
+ .map(([key, mod]) => (
+
+
+ {mod.name}
+
+ ))}
+
+
+
+ Support
+
+
+ {features?.supports?.emailSupport && (
+
+
+ Email Support
+
+ )}
+ {features?.supports?.phoneSupport && (
+
+
+ Phone Support
+
+ )}
+ {features?.supports?.prioritySupport && (
+
+
+ Priority Support
+
+ )}
+
+
+
+
+
+
Duration
+
+ {frequencyLabel(frequency, true)}
+
+
+
+
+
Total Price
+
+ {formatFigure(price, {
+ type: "currency",
+ currency: currency.currencyCode,
+ })}
+
+
+
+ >
+ );
+ })()}
+
+
+ )}
+
+
+
+ {/* Image Section */}
+
+
+
+
+
+
+
+ Next
+
+
+
+
+ );
+};
+
+export default SelectPlan;
diff --git a/src/components/UserSubscription/SubscriptionForm.jsx b/src/components/UserSubscription/SubscriptionForm.jsx
index b033fb65..73353f1e 100644
--- a/src/components/UserSubscription/SubscriptionForm.jsx
+++ b/src/components/UserSubscription/SubscriptionForm.jsx
@@ -12,9 +12,7 @@ import { useCreateTenant, useIndustries } from "../../hooks/useTenant";
import { useCreateSelfTenant } from "../../hooks/useAuth";
import { blockUI } from "../../utils/blockUI";
-const SubscriptionForm = ({currentStep,
- setCurrentStep,
- setStepStatus }) => {
+const SubscriptionForm = ({ currentStep, setCurrentStep, setStepStatus }) => {
const { data, isError, isLoading: industryLoading } = useIndustries();
const {
register,
@@ -42,9 +40,9 @@ const SubscriptionForm = ({currentStep,
// reset();
};
return (
-
-
-
+
+
+
-
+
{isPending ? (
- "Please Wait..."
+ Please Wait...
) : (
<>
Next
@@ -252,103 +250,6 @@ const SubscriptionForm = ({currentStep,
-
- {/*
-
-
-
-
-
-
-
-
-
-
First slide
-
- Eos mutat malis maluisset et, agam ancillae quo te, in vim
- congue pertinacia.
-
-
-
-
-
-
-
Second slide
-
In numquam omittam sea.
-
-
-
-
-
-
Third slide
-
- Lorem ipsum dolor sit amet, virtute consequat ea qui, minim
- graeco mel no.
-
-
-
-
-
-
- Previous
-
-
-
- Next
-
-
*/}
-
-
- Provide organization information including name, size, industry,
- and contact details.
-
-
-
);
diff --git a/src/components/UserSubscription/SubscriptionLayout.jsx b/src/components/UserSubscription/SubscriptionLayout.jsx
index 34db25b2..9a7523c3 100644
--- a/src/components/UserSubscription/SubscriptionLayout.jsx
+++ b/src/components/UserSubscription/SubscriptionLayout.jsx
@@ -7,7 +7,7 @@ const SubscriptionLayout = ({
stepStatus = {},
}) => {
return (
-
+
{configStep.map((step, index) => {
const stepNumber = index + 1;
@@ -34,8 +34,10 @@ const SubscriptionLayout = ({
)}
-
+ {/* ${
status === "success"
? "text-success"
: status === "failed"
@@ -43,10 +45,9 @@ const SubscriptionLayout = ({
: stepNumber === currentStep
? "text-primary"
: "text-muted"
- }`}
- >
+ } */}
{step.name}
-
+
{index !== configStep.length - 1 && (
diff --git a/src/hooks/useAuth.jsx b/src/hooks/useAuth.jsx
index ad59f964..e0bf44a3 100644
--- a/src/hooks/useAuth.jsx
+++ b/src/hooks/useAuth.jsx
@@ -89,10 +89,12 @@ export const useCreateSelfTenant = (onSuccessCallBack, onFailureCallBack) => {
dispatch(
setSelfTenant({
- tenantEnquireId: response?.tenantEnquireId,
+ tenantEnquireId: response?.id,
planId: null,
+ details:response
})
);
+ debugger
if (onSuccessCallBack) onSuccessCallBack(response);
},
onError: (error) => {
diff --git a/src/pages/Home/MakeSubscription.jsx b/src/pages/Home/MakeSubscription.jsx
index 3f9449c7..609dbd0b 100644
--- a/src/pages/Home/MakeSubscription.jsx
+++ b/src/pages/Home/MakeSubscription.jsx
@@ -4,26 +4,37 @@ import SubscriptionLayout from "../../components/UserSubscription/SubscriptionLa
import SubscriptionForm from "../../components/UserSubscription/SubscriptionForm";
import ProcessedPayment from "../../components/UserSubscription/ProcessedPayment";
import VerifiedPayment from "../../components/UserSubscription/VerifiedPayment";
+import SelectPlan from "../../components/UserSubscription/SelectPlan";
+import Review from "../../components/UserSubscription/Review";
const MakeSubscription = () => {
- const [currentStep, setCurrentStep] = useState(1);
+ const [currentStep, setCurrentStep] = useState(4);
const [responsePayment, setResponsePayment] = useState(null);
const [stepStatus, setStepStatus] = useState({
1: "pending",
2: "pending",
3: "pending",
+ 4: "pending",
+ 5: "pending",
});
const handleVerification = (resp) => {
setResponsePayment(resp);
if (resp?.success) {
- setStepStatus((prev) => ({ ...prev, 2: "success", 3: "success" }));
+ setStepStatus((prev) => ({ ...prev, 4: "success" }));
setCurrentStep(3);
} else {
- setStepStatus((prev) => ({ ...prev, 2: "failed" }));
+ setStepStatus((prev) => ({ ...prev, 4: "failed" }));
}
};
+const handleNext = () => {
+ setStepStatus((prev) => ({
+ ...prev,
+ [currentStep + 1]: "pending",
+ }));
+ setCurrentStep((prev) => prev + 1);
+};
const checkOut_Steps = [
{
@@ -37,14 +48,48 @@ const MakeSubscription = () => {
),
},
{
- name: "Payment",
+ name: "Select Plan",
+ component: () => (
+
+ ),
+ },
+ {
+ name: "Review",
component: () => (
handleVerification(resp)}
- onFail={() => setStepStatus((prev) => ({ ...prev, 2: "failed" }))}
+
resetPaymentStep={() =>
- setStepStatus((prev) => ({ ...prev, 2: "pending" }))
+ setStepStatus((prev) => ({ ...prev, 4: "pending" }))
}
+ setCurrentStep={setCurrentStep}
+ setStepStatus={setStepStatus}
+ resetFormStep={() => {
+ setStepStatus((prev) => ({ ...prev, 1: "pending" }));
+ setCurrentStep(1);
+ }}
+ />
+ ),
+ },
+ {
+ name: "Payment",
+ component: () => (
+ handleVerification(resp)}
+
+ resetPaymentStep={() =>
+ setStepStatus((prev) => ({ ...prev, 4: "pending" }))
+ }
+ setCurrentStep={setCurrentStep}
+ setStepStatus={setStepStatus}
+ resetFormStep={() => {
+ setStepStatus((prev) => ({ ...prev, 1: "pending" }));
+ setCurrentStep(1);
+ }}
/>
),
},
@@ -60,14 +105,96 @@ const MakeSubscription = () => {
];
return (
-
-
-
+ <>
+
+
+
+
+
+
+
+ >
);
};
diff --git a/src/slices/localVariablesSlice.jsx b/src/slices/localVariablesSlice.jsx
index 83695f25..af70d936 100644
--- a/src/slices/localVariablesSlice.jsx
+++ b/src/slices/localVariablesSlice.jsx
@@ -35,6 +35,7 @@ const localVariablesSlice = createSlice({
selfTenant: {
tenantEnquireId: null,
planId: null,
+ details:null,
},
},
reducers: {
@@ -106,6 +107,8 @@ const localVariablesSlice = createSlice({
action.payload.tenantEnquireId ?? state.selfTenant.tenantEnquireId;
state.selfTenant.planId =
action.payload.planId ?? state.selfTenant.planId;
+ state.selfTenant.details =
+ action.payload.details ?? state.selfTenant.details;
},
},
});