Skip to content

Commit

Permalink
Re-work on Preferred exporter with new design
Browse files Browse the repository at this point in the history
  • Loading branch information
narefyev91 committed Apr 11, 2024
1 parent 5e1f432 commit d140a2a
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 89 deletions.
4 changes: 0 additions & 4 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -498,10 +498,6 @@ const ROUTES = {
route: 'settings/workspaces/:policyID/accounting/quickbooks-online/preferred-exporter',
getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/preferred-exporter` as const,
},
WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_PREFERRED_EXPORTER_SELECT: {
route: 'settings/workspaces/:policyID/accounting/quickbooks-online/preferred-exporter/select',
getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/preferred-exporter/select` as const,
},
WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES: {
route: 'settings/workspaces/:policyID/accounting/quickbooks-online/export/out-of-pocket-expense',
getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/export/out-of-pocket-expense` as const,
Expand Down
1 change: 0 additions & 1 deletion src/SCREENS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@ const SCREENS = {
QUICKBOOKS_ONLINE_EXPORT_COMPANY_CARD_EXPENSE: 'Workspace_Accounting_Quickbooks_Online_Export_Company_Card_Expense',
QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT: 'Workspace_Accounting_Quickbooks_Online_Export_Company_Card_Expense_Select',
QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER: 'Workspace_Accounting_Quickbooks_Online_Export_Preferred_Exporter',
QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER_SELECT: 'Workspace_Accounting_Quickbooks_Online_Export_Preferred_Exporter_Select',
QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES: 'Workspace_Accounting_Quickbooks_Online_Export_Out_Of_Pocket_Expenses',
QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_SELECT: 'Workspace_Accounting_Quickbooks_Online_Export_Out_Of_Pocket_Expenses_Select',
DISTANCE_RATE_EDIT: 'Distance_Rate_Edit',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,6 @@ const SettingsModalStackNavigator = createModalStackNavigator<SettingsNavigatorP
require('../../../../pages/workspace/accounting/qbo/QuickbooksCompanyCardExpenseAccountSelectPage').default as React.ComponentType,
[SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER]: () =>
require('../../../../pages/workspace/accounting/qbo/QuickbooksPreferredExporterConfigurationPage').default as React.ComponentType,
[SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER_SELECT]: () =>
require('../../../../pages/workspace/accounting/qbo/QuickbooksPreferredExporterSelectPage').default as React.ComponentType,
[SCREENS.REIMBURSEMENT_ACCOUNT]: () => require('../../../../pages/ReimbursementAccount/ReimbursementAccountPage').default as React.ComponentType,
[SCREENS.GET_ASSISTANCE]: () => require('../../../../pages/GetAssistancePage').default as React.ComponentType,
[SCREENS.SETTINGS.TWO_FACTOR_AUTH]: () => require('../../../../pages/settings/Security/TwoFactorAuth/TwoFactorAuthPage').default as React.ComponentType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ const FULL_SCREEN_TO_RHP_MAPPING: Partial<Record<FullScreenName, string[]>> = {
SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_COMPANY_CARD_EXPENSE,
SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT,
SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER,
SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER_SELECT,
SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES,
SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_SELECT,
],
Expand Down
1 change: 0 additions & 1 deletion src/libs/Navigation/linkingConfig/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,6 @@ const config: LinkingOptions<RootStackParamList>['config'] = {
path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT.route,
},
[SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER]: {path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_PREFERRED_EXPORTER.route},
[SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER_SELECT]: {path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_PREFERRED_EXPORTER_SELECT.route},
[SCREENS.WORKSPACE.DESCRIPTION]: {
path: ROUTES.WORKSPACE_PROFILE_DESCRIPTION.route,
},
Expand Down
3 changes: 0 additions & 3 deletions src/libs/Navigation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,9 +283,6 @@ type SettingsNavigatorParamList = {
[SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER]: {
policyID: string;
};
[SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER_SELECT]: {
policyID: string;
};
[SCREENS.GET_ASSISTANCE]: {
backTo: Routes;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,42 @@
import React from 'react';
import React, {useCallback, useMemo} from 'react';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription';
import OfflineWithFeedback from '@components/OfflineWithFeedback';
import ScreenWrapper from '@components/ScreenWrapper';
import ScrollView from '@components/ScrollView';
import SelectionList from '@components/SelectionList';
import RadioListItem from '@components/SelectionList/RadioListItem';
import Text from '@components/Text';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import Navigation from '@navigation/Navigation';
import withPolicy from '@pages/workspace/withPolicy';
import type {WithPolicyProps} from '@pages/workspace/withPolicy';
import ROUTES from '@src/ROUTES';

const draft = [
{name: '[email protected]', currency: 'USD', id: '94', email: '[email protected]'},
{name: 'Account Maintenance Fee', currency: 'USD', id: '141', email: '[email protected]'},
{name: 'Admin Test', currency: 'USD', id: '119', email: '[email protected]'},
{name: 'Alberto Gonzalez-Cela', currency: 'USD', id: '104', email: '[email protected]'},
{name: 'Aldo test QBO2 QBO2 Last name', currency: 'USD', id: '140', email: '[email protected]'},
];

function QuickBooksExportPreferredExporterPage({policy}: WithPolicyProps) {
const {translate} = useLocalize();
const styles = useThemeStyles();
const policyID = policy?.id ?? '';
const policyOwner = policy?.owner ?? '';
const {exporter} = policy?.connections?.quickbooksOnline?.config?.export ?? {};
const {data, config} = policy?.connections?.quickbooksOnline ?? {};
// const policyID = policy?.id ?? '';
const sections = useMemo(
() =>
(data?.vendors ?? draft)?.map((vendor) => ({
value: vendor.email,
text: vendor.email,
keyForList: vendor.email,
isSelected: config?.export?.exporter === vendor.email,

This comment has been minimized.

Copy link
@hungvu193

hungvu193 Aug 31, 2024

Contributor

Sometimes, config?.export?.exporter returns undefined, which causes #46675.
More details in this #46675 (comment)

})) ?? [],
[config?.export?.exporter, data?.vendors],
);

const updateMode = useCallback((mode: {value: string}) => {

Check failure on line 37 in src/pages/workspace/accounting/qbo/QuickbooksPreferredExporterConfigurationPage.tsx

View workflow job for this annotation

GitHub Actions / Run ESLint

'mode' is defined but never used
// TODO add API call for change
}, []);

return (
<ScreenWrapper
Expand All @@ -29,14 +48,12 @@ function QuickBooksExportPreferredExporterPage({policy}: WithPolicyProps) {
<ScrollView contentContainerStyle={styles.pb2}>
<Text style={[styles.ph5, styles.pb5]}>{translate('workspace.qbo.exportPreferredExporterNote')}</Text>
<Text style={[styles.ph5, styles.pb5]}>{translate('workspace.qbo.exportPreferredExporterSubNote')}</Text>
<OfflineWithFeedback>
<MenuItemWithTopDescription
shouldShowRightIcon
title={exporter ?? policyOwner}
onPress={() => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_PREFERRED_EXPORTER_SELECT.getRoute(policyID))}
brickRoadIndicator={undefined}
/>
</OfflineWithFeedback>
<SelectionList
sections={[{data: sections}]}
ListItem={RadioListItem}
onSelectRow={updateMode}
initiallyFocusedOptionKey={sections.find((mode) => mode.isSelected)?.keyForList}
/>
</ScrollView>
</ScreenWrapper>
);
Expand Down

This file was deleted.

0 comments on commit d140a2a

Please sign in to comment.