Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Step 4 UI #52384

Merged
merged 18 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: user removal upon going back
  • Loading branch information
MrMuzyk committed Nov 12, 2024
commit da53fea4a279529605646d7e02ff9ce254df5de7
1 change: 1 addition & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,7 @@ const CONST = {
ZIP_CODE: 'zipCode',
COUNTRY: 'country',
},
CURRENT_USER_KEY: 'currentUser',
},
STEP_NAMES: ['1', '2', '3', '4', '5', '6'],
STEP_HEADER_HEIGHT: 40,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type BeneficialOwnerInfoProps = {
onSubmit: () => void;
};

const {OWNS_MORE_THAN_25_PERCENT, ANY_INDIVIDUAL_OWN_25_PERCENT_OR_MORE, BENEFICIAL_OWNERS, COMPANY_NAME} = INPUT_IDS.ADDITIONAL_DATA.CORPAY;
const {OWNS_MORE_THAN_25_PERCENT, ANY_INDIVIDUAL_OWN_25_PERCENT_OR_MORE, BENEFICIAL_OWNERS, COMPANY_NAME, ENTITY_CHART} = INPUT_IDS.ADDITIONAL_DATA.CORPAY;
const {FIRST_NAME, LAST_NAME, OWNERSHIP_PERCENTAGE, DOB, SSN_LAST_4, STREET, CITY, STATE, ZIP_CODE, COUNTRY, PREFIX} =
CONST.NON_USD_BANK_ACCOUNT.BENEFICIAL_OWNER_INFO_STEP.BENEFICIAL_OWNER_DATA;
const SUBSTEP = CONST.NON_USD_BANK_ACCOUNT.BENEFICIAL_OWNER_INFO_STEP.SUBSTEP;
Expand All @@ -50,14 +50,15 @@ function BeneficialOwnerInfo({onBackButtonPress, onSubmit}: BeneficialOwnerInfoP
const [reimbursementAccountDraft] = useOnyx(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT);

const [ownerKeys, setOwnerKeys] = useState<string[]>([]);
const [ownerBeingModifiedID, setOwnerBeingModifiedID] = useState('currentUser');
const [ownerBeingModifiedID, setOwnerBeingModifiedID] = useState<string>(CONST.NON_USD_BANK_ACCOUNT.BENEFICIAL_OWNER_INFO_STEP.CURRENT_USER_KEY);
const [isEditingCreatedOwner, setIsEditingCreatedOwner] = useState(false);
const [isUserEnteringHisOwnData, setIsUserEnteringHisOwnData] = useState(false);
const [isUserOwner, setIsUserOwner] = useState(false);
const [isAnyoneElseOwner, setIsAnyoneElseOwner] = useState(false);
const [currentSubStep, setCurrentSubStep] = useState<number>(SUBSTEP.IS_USER_BENEFICIAL_OWNER);
const [totalOwnedPercentage, setTotalOwnedPercentage] = useState<Record<string, number>>({});
const companyName = reimbursementAccount?.achData?.additionalData?.corpay?.[COMPANY_NAME] ?? reimbursementAccountDraft?.[COMPANY_NAME] ?? '';
const entityChart = reimbursementAccount?.achData?.additionalData?.corpay?.[ENTITY_CHART] ?? reimbursementAccountDraft?.[ENTITY_CHART] ?? [];

const policyID = reimbursementAccount?.achData?.policyID ?? '-1';
const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`);
Expand Down Expand Up @@ -99,7 +100,7 @@ function BeneficialOwnerInfo({onBackButtonPress, onSubmit}: BeneficialOwnerInfoP

let nextSubStep;
if (isEditingCreatedOwner || !canAddMoreOwners) {
nextSubStep = shouldAskForEntityChart ? SUBSTEP.OWNERSHIP_CHART : SUBSTEP.BENEFICIAL_OWNERS_LIST;
nextSubStep = shouldAskForEntityChart && entityChart.length === 0 ? SUBSTEP.OWNERSHIP_CHART : SUBSTEP.BENEFICIAL_OWNERS_LIST;
} else {
nextSubStep = isUserEnteringHisOwnData ? SUBSTEP.IS_ANYONE_ELSE_BENEFICIAL_OWNER : SUBSTEP.ARE_THERE_MORE_BENEFICIAL_OWNERS;
}
Expand Down Expand Up @@ -192,6 +193,7 @@ function BeneficialOwnerInfo({onBackButtonPress, onSubmit}: BeneficialOwnerInfoP

setIsUserOwner(value);
setIsUserEnteringHisOwnData(value);
setOwnerKeys((currentOwnersKeys) => currentOwnersKeys.filter((key) => key !== CONST.NON_USD_BANK_ACCOUNT.BENEFICIAL_OWNER_INFO_STEP.CURRENT_USER_KEY));

// User is an owner but there are 4 other owners already added, so we remove last one
if (value && ownerKeys.length === 4) {
Expand Down Expand Up @@ -220,6 +222,8 @@ function BeneficialOwnerInfo({onBackButtonPress, onSubmit}: BeneficialOwnerInfoP

// User is not an owner and no one else is an owner
if (!isUserOwner && !value) {
setOwnerKeys([]);

// Gather ownership chart if AUD account
if (shouldAskForEntityChart) {
setCurrentSubStep(SUBSTEP.OWNERSHIP_CHART);
Expand All @@ -233,6 +237,7 @@ function BeneficialOwnerInfo({onBackButtonPress, onSubmit}: BeneficialOwnerInfoP

// User is an owner and no one else is an owner
if (isUserOwner && !value) {
setOwnerKeys([CONST.NON_USD_BANK_ACCOUNT.BENEFICIAL_OWNER_INFO_STEP.CURRENT_USER_KEY]);
// Gather ownership chart if AUD account
if (shouldAskForEntityChart) {
setCurrentSubStep(SUBSTEP.OWNERSHIP_CHART);
Expand Down
Loading