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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | 9x 9x 9x 110x 110x 110x 110x 110x 40x 38x 38x 110x 40x 38x 38x | import { useEffect } from "react";
import { useDispatch } from "react-redux";
import {
removeHiddenStepKeys,
setHiddenStepKeys,
} from "@redux/slices/onboardingWizard";
import { IApiData } from "@features/GiveOnboarding/types/form";
import { IStep } from "@features/GiveOnboarding/types";
const stepsToHideWhenLinkedBP: IStep[] = [
"business_address",
"business_owners",
];
const stepsToHideWhenBALinked: IStep[] = [
"business_bank_statement",
"business_bank_confirm",
];
export const useUpdateGlobalOnboardingState = (initialApiData: IApiData) => {
const dispatch = useDispatch();
const { wasFilledAnExistingTaxID, showLinkedBusinessProfile } =
initialApiData?.data?.business_profile?.businessProfileDataAux || {};
const showLinkedBA =
initialApiData?.data?.business_bank_connect?.bankDataAux?.isLinked;
// PAH006 SS-4: in identity-only re-onboarding, useIdentityOnlyMode hides every
// non-identity step. This hook must NOT touch those keys then — its
// removeHiddenStepKeys calls would un-hide business_address/business_owners and
// business_bank_statement/business_bank_confirm, re-surfacing the Business and
// Business bank account sections that identity-only mode deliberately hid.
const isIdentityOnly = Boolean(
initialApiData?.data?.merchant_info?.isPahReassignmentIdentityOnly,
);
useEffect(() => {
if (isIdentityOnly) return;
Iif (wasFilledAnExistingTaxID || showLinkedBusinessProfile) {
dispatch(setHiddenStepKeys(stepsToHideWhenLinkedBP));
} else {
dispatch(removeHiddenStepKeys(stepsToHideWhenLinkedBP));
}
}, [wasFilledAnExistingTaxID, showLinkedBusinessProfile, isIdentityOnly]);
useEffect(() => {
if (isIdentityOnly) return;
Iif (showLinkedBA) {
dispatch(setHiddenStepKeys(stepsToHideWhenBALinked));
} else {
dispatch(removeHiddenStepKeys(stepsToHideWhenBALinked));
}
}, [showLinkedBA, isIdentityOnly]);
};
|