diff --git a/src/components/Tenant/OrganizationInfo.jsx b/src/components/Tenant/OrganizationInfo.jsx
index 8fd8f4c5..b465c4e1 100644
--- a/src/components/Tenant/OrganizationInfo.jsx
+++ b/src/components/Tenant/OrganizationInfo.jsx
@@ -25,7 +25,10 @@ const OrganizationInfo = ({ onNext, onPrev, onSubmitTenant }) => {
isError: tenantError,
error,
isPending,
- } = useCreateTenant(() => onNext());
+ } = useCreateTenant(() => {
+ debugger
+ onNext()
+ });
const handleNext = async () => {
const valid = await trigger([
diff --git a/src/components/Tenant/TenantForm.jsx b/src/components/Tenant/TenantForm.jsx
index fb3e5a9f..c07a3186 100644
--- a/src/components/Tenant/TenantForm.jsx
+++ b/src/components/Tenant/TenantForm.jsx
@@ -2,6 +2,7 @@ import React, { useState, useEffect } from "react";
import ContactInfro from "./ContactInfro";
import SubScription from "./SubScription";
import OrganizationInfo from "./OrganizationInfo";
+import Congratulation from "./Congratulation";
import { useForm, FormProvider } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
import {
@@ -11,7 +12,6 @@ import {
subscriptionSchema,
tenantDefaultValues,
} from "./TenantSchema";
-import Congratulation from "./Congratulation";
import { useSelector } from "react-redux";
const TenantForm = () => {
@@ -21,24 +21,23 @@ const TenantForm = () => {
const [activeTab, setActiveTab] = useState(0);
const [completedTabs, setCompletedTabs] = useState([]);
- const PlanTextLabel = HasSelectedCurrentTenant?.operationMode === 1 ? "Upgrade Plan":"Select Plan"
+ const PlanTextLabel =
+ HasSelectedCurrentTenant?.operationMode === 1
+ ? "Upgrade Plan"
+ : "Select Plan";
// Jump to subscription if tenant already exists
-useEffect(() => {
- if (HasSelectedCurrentTenant) {
- if (HasSelectedCurrentTenant.operationMode === 1) {
- // Skip to subscription step
- setActiveTab(2); // index for "SubScription"
- setCompletedTabs([0, 1]); // mark previous steps as completed
- } else if (HasSelectedCurrentTenant.operationMode === 0) {
- // Start from the beginning (new tenant creation)
- setActiveTab(0);
+ useEffect(() => {
+ if (HasSelectedCurrentTenant) {
+ if (HasSelectedCurrentTenant.operationMode === 1) {
+ // Skip to subscription step
+ setActiveTab(2); // index for "SubScription"
+ setCompletedTabs([0, 1]); // mark previous steps as completed
+ } else if (HasSelectedCurrentTenant.operationMode === 0) {
+ setActiveTab(0); // start from beginning
+ }
}
- } else {
- // Default: no tenant selected
- return ;
- }
-}, [HasSelectedCurrentTenant,activeTab]);
+ }, [HasSelectedCurrentTenant]);
const tenantForm = useForm({
resolver: zodResolver(newTenantSchema),
@@ -54,32 +53,50 @@ useEffect(() => {
activeTab === 2 ? subscriptionForm.trigger : tenantForm.trigger;
const handleNext = async () => {
- const currentStepFields = getStepFields(activeTab);
- const trigger = getCurrentTrigger();
- const valid = await trigger(currentStepFields);
+ const currentStepFields = getStepFields(activeTab);
+ const trigger = getCurrentTrigger();
+ const valid = await trigger(currentStepFields);
- if (valid) {
- setCompletedTabs((prev) => [...new Set([...prev, activeTab])]);
+ if (valid) {
+ setCompletedTabs((prev) => [...new Set([...prev, activeTab])]);
+
+ setActiveTab((prev) => {
+ let nextStep = Math.min(prev + 1, newTenantConfig.length - 1);
+
+ // Check tenant operationMode to decide navigation
+ if (
+ HasSelectedCurrentTenant &&
+ HasSelectedCurrentTenant.operationMode === 1 &&
+ nextStep === 2
+ ) {
+ // If tenant already has subscription, show upgrade
+ nextStep = 2;
+ } else if (
+ HasSelectedCurrentTenant &&
+ [0, 2].includes(HasSelectedCurrentTenant.operationMode) &&
+ nextStep === 2
+ ) {
+ // If tenant just created (0) OR exists without subscription (2)
+ // → stay on subscription tab
+ nextStep = 2;
+ }
+
+ return nextStep;
+ });
+ }
+};
- setActiveTab((prev) => {
- let nextStep = Math.min(prev + 1, newTenantConfig.length - 1);
- if (HasSelectedCurrentTenant && nextStep === 2) {
- nextStep = 3; // skip subscription if already upgraded
- }
- return nextStep;
- });
- }
- };
const handlePrev = () => {
setActiveTab((prev) => Math.max(prev - 1, 0));
};
const onSubmitTenant = (data) => {
- // console.log("Tenant Data:", data);
+ console.log("Tenant Data:", data);
};
+
const onSubmitSubScription = (data) => {
- // console.log("Subscription Data:", data);
+ console.log("Subscription Data:", data);
};
const newTenantConfig = [
@@ -113,9 +130,9 @@ useEffect(() => {
),
},
{
- name: "congratulation",
- icon: "bx bx-star bx-md",
- subtitle: "Select a plan",
+ name: "Congratulation",
+ icon: "bx bx-check-circle bx-md",
+ subtitle: "Completed",
component: