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

[NoQA] Update icon for Expensify cards feature row and small clean up #49024

Merged
merged 4 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
55 changes: 2 additions & 53 deletions src/pages/workspace/WorkspaceInitialPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ type WorkspaceMenuItem = {
};

type WorkspaceInitialPageOnyxProps = {
/** Bank account attached to free plan */
reimbursementAccount: OnyxEntry<OnyxTypes.ReimbursementAccount>;

/** Collection of categories attached to a policy */
policyCategories: OnyxEntry<OnyxTypes.PolicyCategories>;
};
Expand All @@ -91,7 +88,7 @@ function dismissError(policyID: string, pendingAction: PendingAction | undefined
}
}

function WorkspaceInitialPage({policyDraft, policy: policyProp, reimbursementAccount, policyCategories, route}: WorkspaceInitialPageProps) {
function WorkspaceInitialPage({policyDraft, policy: policyProp, policyCategories, route}: WorkspaceInitialPageProps) {
const styles = useThemeStyles();
const policy = policyDraft?.id ? policyDraft : policyProp;
const [isCurrencyModalOpen, setIsCurrencyModalOpen] = useState(false);
Expand Down Expand Up @@ -165,51 +162,8 @@ function WorkspaceInitialPage({policyDraft, policy: policyProp, reimbursementAcc
const {login} = useCurrentUserPersonalDetails();
const shouldShowProtectedItems = PolicyUtils.isPolicyAdmin(policy, login);
const isPaidGroupPolicy = PolicyUtils.isPaidGroupPolicy(policy);
const isFreeGroupPolicy = PolicyUtils.isFreeGroupPolicy(policy);
const [featureStates, setFeatureStates] = useState(policyFeatureStates);

const protectedFreePolicyMenuItems: WorkspaceMenuItem[] = [
{
translationKey: 'workspace.common.card',
icon: Expensicons.ExpensifyCard,
action: singleExecution(waitForNavigate(() => Navigation.navigate(ROUTES.WORKSPACE_CARD.getRoute(policyID)))),
routeName: SCREENS.WORKSPACE.CARD,
},
{
translationKey: 'workspace.common.reimburse',
icon: Expensicons.Receipt,
action: singleExecution(waitForNavigate(() => Navigation.navigate(ROUTES.WORKSPACE_REIMBURSE.getRoute(policyID)))),
routeName: SCREENS.WORKSPACE.REIMBURSE,
},
{
translationKey: 'workspace.common.bills',
icon: Expensicons.Bill,
action: singleExecution(waitForNavigate(() => Navigation.navigate(ROUTES.WORKSPACE_BILLS.getRoute(policyID)))),
routeName: SCREENS.WORKSPACE.BILLS,
},
{
translationKey: 'workspace.common.invoices',
icon: Expensicons.Invoice,
action: singleExecution(waitForNavigate(() => Navigation.navigate(ROUTES.WORKSPACE_INVOICES.getRoute(policyID)))),
routeName: SCREENS.WORKSPACE.INVOICES,
},
{
translationKey: 'workspace.common.travel',
icon: Expensicons.Luggage,
action: singleExecution(waitForNavigate(() => Navigation.navigate(ROUTES.WORKSPACE_TRAVEL.getRoute(policyID)))),
routeName: SCREENS.WORKSPACE.TRAVEL,
},
{
translationKey: 'workspace.common.bankAccount',
icon: Expensicons.Bank,
action: () =>
policy?.outputCurrency === CONST.CURRENCY.USD
? singleExecution(waitForNavigate(() => ReimbursementAccount.navigateToBankAccountRoute(policyID, Navigation.getActiveRouteWithoutParams())))()
: setIsCurrencyModalOpen(true),
brickRoadIndicator: !isEmptyObject(reimbursementAccount?.errors) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined,
},
];

const protectedCollectPolicyMenuItems: WorkspaceMenuItem[] = [];

// We only update feature states if they aren't pending.
Expand Down Expand Up @@ -241,7 +195,7 @@ function WorkspaceInitialPage({policyDraft, policy: policyProp, reimbursementAcc
if (featureStates?.[CONST.POLICY.MORE_FEATURES.ARE_EXPENSIFY_CARDS_ENABLED]) {
protectedCollectPolicyMenuItems.push({
translationKey: 'workspace.common.expensifyCard',
icon: Expensicons.CreditCard,
icon: Expensicons.ExpensifyCard,
action: singleExecution(waitForNavigate(() => Navigation.navigate(ROUTES.WORKSPACE_EXPENSIFY_CARD.getRoute(policyID)))),
routeName: SCREENS.WORKSPACE.EXPENSIFY_CARD,
});
Expand Down Expand Up @@ -346,7 +300,6 @@ function WorkspaceInitialPage({policyDraft, policy: policyProp, reimbursementAcc
routeName: SCREENS.WORKSPACE.MEMBERS,
},
...(isPaidGroupPolicy && shouldShowProtectedItems ? protectedCollectPolicyMenuItems : []),
...(isFreeGroupPolicy && shouldShowProtectedItems ? protectedFreePolicyMenuItems : []),
];

const prevPolicy = usePrevious(policy);
Expand Down Expand Up @@ -475,10 +428,6 @@ WorkspaceInitialPage.displayName = 'WorkspaceInitialPage';

export default withPolicyAndFullscreenLoading(
withOnyx<WorkspaceInitialPageProps, WorkspaceInitialPageOnyxProps>({
// @ts-expect-error: ONYXKEYS.REIMBURSEMENT_ACCOUNT is conflicting with ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM
reimbursementAccount: {
key: ONYXKEYS.REIMBURSEMENT_ACCOUNT,
},
policyCategories: {
key: ({route}) => `${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${route.params?.policyID ?? '-1'}`,
},
Expand Down
2 changes: 1 addition & 1 deletion src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ function WorkspaceWorkflowsPage({policy, route}: WorkspaceWorkflowsPageProps) {
disabled={isOffline || !isPolicyAdmin}
shouldGreyOutWhenDisabled={!policy?.pendingFields?.reimbursementChoice}
shouldShowRightIcon={!isOffline && isPolicyAdmin}
wrapperStyle={[styles.sectionMenuItemTopDescription, styles.mbn3]}
wrapperStyle={[styles.sectionMenuItemTopDescription, styles.mt3, styles.mbn3]}
displayInDefaultIconColor
brickRoadIndicator={hasReimburserError ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined}
/>
Expand Down
Loading