Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | import { ENTERPRISE_PATHS, MERCHANT_PATHS } from "@routes/paths";
import { checkPortals } from "@utils/routing";
import { useGetMerchantById } from "@hooks/enterprise-api/account/useGetMerchants";
import { useLocation } from "react-router-dom";
import { useGetFeatureFlagValues } from "FeatureFlags/useGetFeatureFlagValues";
export const useHandleMerchantDefaultRoute = () => {
const { state } = useLocation();
const { isMerchantPortal, isEnterprisePortal } = checkPortals();
const { data } = useGetMerchantById({ enabled: isMerchantPortal });
const { isMerchantOnboardingModalEnabled } = useGetFeatureFlagValues();
//I dont believe anything else is necesary to change the redirection flow
//the open status of the modal woudl be handle internally
const isOnboarding = isMerchantOnboardingModalEnabled;
const path = ENTERPRISE_PATHS.TRANSACTIONS;
if (isEnterprisePortal) {
return {
defaultRoute:
state?.status == "approved" ? path : ENTERPRISE_PATHS.WELCOME,
};
}
if (isOnboarding) {
return {
defaultRoute: MERCHANT_PATHS.MANAGE_MONEY,
};
}
return {
defaultRoute:
data?.sponsorStatusName === "approved" || state?.status == "approved"
? MERCHANT_PATHS.MANAGE_MONEY
: MERCHANT_PATHS.WELCOME,
};
};
|