Skip to content
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
49 changes: 42 additions & 7 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1697,15 +1697,25 @@ const ROUTES = {
},
POLICY_ACCOUNTING_QUICKBOOKS_DESKTOP_CLASSES: {
route: 'workspaces/:policyID/accounting/quickbooks-desktop/import/classes',
getRoute: (policyID: string) => `workspaces/${policyID}/accounting/quickbooks-desktop/import/classes` as const,
getRoute: (policyID: string | undefined) => {
if (!policyID) {
Log.warn('Invalid policyID is used to build the POLICY_ACCOUNTING_QUICKBOOKS_DESKTOP_CLASSES route');
}
return `workspaces/${policyID}/accounting/quickbooks-desktop/import/classes` as const;
},
},
POLICY_ACCOUNTING_QUICKBOOKS_DESKTOP_CLASSES_DISPLAYED_AS: {
route: 'workspaces/:policyID/accounting/quickbooks-desktop/import/classes/displayed_as',
getRoute: (policyID: string) => `workspaces/${policyID}/accounting/quickbooks-desktop/import/classes/displayed_as` as const,
},
POLICY_ACCOUNTING_QUICKBOOKS_DESKTOP_CUSTOMERS: {
route: 'workspaces/:policyID/accounting/quickbooks-desktop/import/customers',
getRoute: (policyID: string) => `workspaces/${policyID}/accounting/quickbooks-desktop/import/customers` as const,
getRoute: (policyID: string | undefined) => {
if (!policyID) {
Log.warn('Invalid policyID is used to build the POLICY_ACCOUNTING_QUICKBOOKS_DESKTOP_CUSTOMERS route');
}
return `workspaces/${policyID}/accounting/quickbooks-desktop/import/customers` as const;
},
},
POLICY_ACCOUNTING_QUICKBOOKS_DESKTOP_CUSTOMERS_DISPLAYED_AS: {
route: 'workspaces/:policyID/accounting/quickbooks-desktop/import/customers/displayed_as',
Expand Down Expand Up @@ -3043,23 +3053,38 @@ const ROUTES = {
},
POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_CLASSES: {
route: 'workspaces/:policyID/accounting/quickbooks-online/import/classes',
getRoute: (policyID: string) => `workspaces/${policyID}/accounting/quickbooks-online/import/classes` as const,
getRoute: (policyID: string | undefined) => {
if (!policyID) {
Log.warn('Invalid policyID is used to build the POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_CLASSES route');
}
return `workspaces/${policyID}/accounting/quickbooks-online/import/classes` as const;
},
},
POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_CLASSES_DISPLAYED_AS: {
route: 'workspaces/:policyID/accounting/quickbooks-online/import/classes/displayed-as',
getRoute: (policyID: string) => `workspaces/${policyID}/accounting/quickbooks-online/import/classes/displayed-as` as const,
},
POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_CUSTOMERS: {
route: 'workspaces/:policyID/accounting/quickbooks-online/import/customers',
getRoute: (policyID: string) => `workspaces/${policyID}/accounting/quickbooks-online/import/customers` as const,
getRoute: (policyID: string | undefined) => {
if (!policyID) {
Log.warn('Invalid policyID is used to build the POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_CUSTOMERS route');
}
return `workspaces/${policyID}/accounting/quickbooks-online/import/customers` as const;
},
},
POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_CUSTOMERS_DISPLAYED_AS: {
route: 'workspaces/:policyID/accounting/quickbooks-online/import/customers/displayed-as',
getRoute: (policyID: string) => `workspaces/${policyID}/accounting/quickbooks-online/import/customers/displayed-as` as const,
},
POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_LOCATIONS: {
route: 'workspaces/:policyID/accounting/quickbooks-online/import/locations',
getRoute: (policyID: string) => `workspaces/${policyID}/accounting/quickbooks-online/import/locations` as const,
getRoute: (policyID: string | undefined) => {
if (!policyID) {
Log.warn('Invalid policyID is used to build the POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_LOCATIONS route');
}
return `workspaces/${policyID}/accounting/quickbooks-online/import/locations` as const;
},
},
POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_LOCATIONS_DISPLAYED_AS: {
route: 'workspaces/:policyID/accounting/quickbooks-online/import/locations/displayed-as',
Expand Down Expand Up @@ -3094,7 +3119,12 @@ const ROUTES = {
},
POLICY_ACCOUNTING_NETSUITE_IMPORT: {
route: 'workspaces/:policyID/accounting/netsuite/import',
getRoute: (policyID: string) => `workspaces/${policyID}/accounting/netsuite/import` as const,
getRoute: (policyID: string | undefined) => {
if (!policyID) {
Log.warn('Invalid policyID is used to build the POLICY_ACCOUNTING_NETSUITE_IMPORT route');
}
return `workspaces/${policyID}/accounting/netsuite/import` as const;
},
},
POLICY_ACCOUNTING_NETSUITE_IMPORT_MAPPING: {
route: 'workspaces/:policyID/accounting/netsuite/import/mapping/:importField',
Expand Down Expand Up @@ -3134,7 +3164,12 @@ const ROUTES = {
},
POLICY_ACCOUNTING_NETSUITE_IMPORT_CUSTOMERS_OR_PROJECTS: {
route: 'workspaces/:policyID/accounting/netsuite/import/customer-projects',
getRoute: (policyID: string) => `workspaces/${policyID}/accounting/netsuite/import/customer-projects` as const,
getRoute: (policyID: string | undefined) => {
if (!policyID) {
Log.warn('Invalid policyID is used to build the POLICY_ACCOUNTING_NETSUITE_IMPORT_CUSTOMERS_OR_PROJECTS route');
}
return `workspaces/${policyID}/accounting/netsuite/import/customer-projects` as const;
},
},
POLICY_ACCOUNTING_NETSUITE_IMPORT_CUSTOMERS_OR_PROJECTS_SELECT: {
route: 'workspaces/:policyID/accounting/netsuite/import/customer-projects/select',
Expand Down
3 changes: 3 additions & 0 deletions src/components/SelectionList/ListItem/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,9 @@ type ListItemProps<TItem extends ListItem> = CommonListItemProps<TItem> & {
/** Whether to show RBR */
shouldDisplayRBR?: boolean;

/** Boolean whether to display the right icon */
shouldShowRightCaret?: boolean;

/** Styles applied for the title */
titleStyles?: StyleProp<TextStyle>;

Expand Down
11 changes: 6 additions & 5 deletions src/components/SelectionListWithSections/TableListItem.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React, {useCallback} from 'react';
import React from 'react';
import {View} from 'react-native';
import Icon from '@components/Icon';
import * as Expensicons from '@components/Icon/Expensicons';
import PressableWithFeedback from '@components/Pressable/PressableWithFeedback';
import ReportActionAvatars from '@components/ReportActionAvatars';
import TextWithTooltip from '@components/TextWithTooltip';
import useAnimatedHighlightStyle from '@hooks/useAnimatedHighlightStyle';
import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset';
import useStyleUtils from '@hooks/useStyleUtils';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
Expand Down Expand Up @@ -33,6 +33,7 @@ function TableListItem<TItem extends ListItem>({
const styles = useThemeStyles();
const theme = useTheme();
const StyleUtils = useStyleUtils();
const icons = useMemoizedLazyExpensifyIcons(['Checkmark']);

const animatedHighlightStyle = useAnimatedHighlightStyle({
borderRadius: styles.selectionListPressableItemWrapper.borderRadius,
Expand All @@ -44,13 +45,13 @@ function TableListItem<TItem extends ListItem>({
const focusedBackgroundColor = styles.sidebarLinkActive.backgroundColor;
const hoveredBackgroundColor = styles.sidebarLinkHover?.backgroundColor ? styles.sidebarLinkHover.backgroundColor : theme.sidebar;

const handleCheckboxPress = useCallback(() => {
const handleCheckboxPress = () => {
if (onCheckboxPress) {
onCheckboxPress(item);
} else {
onSelectRow(item);
}
}, [item, onCheckboxPress, onSelectRow]);
};

return (
<BaseListItem
Expand Down Expand Up @@ -100,7 +101,7 @@ function TableListItem<TItem extends ListItem>({
<View style={[StyleUtils.getCheckboxContainerStyle(20), StyleUtils.getMultiselectListStyles(!!item.isSelected, !!item.isDisabled), item.cursorStyle]}>
{!!item.isSelected && (
<Icon
src={Expensicons.Checkmark}
src={icons.Checkmark}
fill={theme.textLight}
height={14}
width={14}
Expand Down
39 changes: 21 additions & 18 deletions src/components/SelectionScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ import HeaderWithBackButton from './HeaderWithBackButton';
import OfflineWithFeedback from './OfflineWithFeedback';
import ScreenWrapper from './ScreenWrapper';
// eslint-disable-next-line no-restricted-imports
import SelectionList from './SelectionListWithSections';
import type RadioListItem from './SelectionListWithSections/RadioListItem';
import type TableListItem from './SelectionListWithSections/TableListItem';
import type {ListItem, SectionListDataType} from './SelectionListWithSections/types';
import SelectionList from './SelectionList';
import type RadioListItem from './SelectionList/ListItem/RadioListItem';
import type TableListItem from './SelectionList/ListItem/TableListItem';
import type {ListItem} from './SelectionList/types';
import type UserListItem from './SelectionListWithSections/UserListItem';

type SelectorType<T = string> = ListItem & {
Expand All @@ -46,7 +46,7 @@ type SelectionScreenProps<T = string> = {
listFooterContent?: React.JSX.Element | null;

/** Sections for the section list */
sections: Array<SectionListDataType<SelectorType<T>>>;
data: Array<SelectorType<T>>;

/** Default renderer for every item in the list */
listItem: typeof RadioListItem | typeof UserListItem | typeof TableListItem;
Expand All @@ -55,10 +55,10 @@ type SelectionScreenProps<T = string> = {
listItemWrapperStyle?: StyleProp<ViewStyle>;

/** Item `keyForList` to focus initially */
initiallyFocusedOptionKey?: string | null | undefined;
initiallyFocusedOptionKey?: string | undefined;

/** Callback to fire when a row is pressed */
onSelectRow: (selection: SelectorType<T>) => void;
onSelectRow: (item: SelectorType<T>) => void;

/** Callback to fire when back button is pressed */
onBackButtonPress?: () => void;
Expand Down Expand Up @@ -118,7 +118,7 @@ function SelectionScreen<T = string>({
headerContent,
listEmptyContent,
listFooterContent,
sections,
data,
listItem,
listItemWrapperStyle,
initiallyFocusedOptionKey,
Expand Down Expand Up @@ -147,6 +147,12 @@ function SelectionScreen<T = string>({
const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, {canBeMissing: false});
const isConnectionEmpty = isEmpty(policy?.connections?.[connectionName]);

const textInputOptions = {
onChangeText,
textInputLabel,
textInputValue,
};

return (
<AccessOrNotFoundWrapper
policyID={policyID}
Expand All @@ -167,26 +173,23 @@ function SelectionScreen<T = string>({
pendingAction={pendingAction}
style={[styles.flex1]}
contentContainerStyle={[styles.flex1]}
shouldDisableOpacity={!sections.length}
shouldDisableOpacity={!data.length}
>
<SelectionList
onSelectRow={onSelectRow}
sections={sections}
data={data}
ListItem={listItem}
onSelectRow={onSelectRow}
showScrollIndicator
onChangeText={onChangeText}
shouldShowTooltips={false}
initiallyFocusedOptionKey={initiallyFocusedOptionKey}
initiallyFocusedItemKey={initiallyFocusedOptionKey}
textInputOptions={textInputOptions}
listEmptyContent={listEmptyContent}
textInputLabel={textInputLabel}
textInputValue={textInputValue}
shouldShowTextInput={shouldShowTextInput}
listFooterContent={listFooterContent}
sectionListStyle={!!sections.length && [styles.flexGrow0]}
style={{listItemWrapperStyle}}
shouldSingleExecuteRowSelect={shouldSingleExecuteRowSelect}
shouldUpdateFocusedIndex={shouldUpdateFocusedIndex}
isAlternateTextMultilineSupported
listItemWrapperStyle={listItemWrapperStyle}
alternateNumberOfSupportedLines={2}
addBottomSafeAreaPadding={!errors || isEmptyObject(errors)}
>
<ErrorMessageRow
Expand Down
10 changes: 8 additions & 2 deletions src/libs/actions/connections/NetSuiteCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,11 +321,14 @@ function updateNetSuiteSubsidiary(policyID: string, newSubsidiary: SubsidiaryPar
}

function updateNetSuiteImportMapping<TMappingName extends keyof Connections['netsuite']['options']['config']['syncOptions']['mapping']>(
policyID: string,
policyID: string | undefined,
mappingName: TMappingName,
mappingValue: ValueOf<typeof CONST.INTEGRATION_ENTITY_MAP_TYPES>,
oldMappingValue?: ValueOf<typeof CONST.INTEGRATION_ENTITY_MAP_TYPES> | null,
) {
if (!policyID) {
return;
}
const onyxData: OnyxData = {
optimisticData: [
{
Expand Down Expand Up @@ -440,7 +443,7 @@ function updateNetSuiteImportMapping<TMappingName extends keyof Connections['net
}

function updateNetSuiteCustomersJobsMapping(
policyID: string,
policyID: string | undefined,
mappingValue: {
customersMapping: NetSuiteMappingValues;
jobsMapping: NetSuiteMappingValues;
Expand All @@ -450,6 +453,9 @@ function updateNetSuiteCustomersJobsMapping(
jobsMapping?: NetSuiteMappingValues;
},
) {
if (!policyID) {
return;
}
const onyxData: OnyxData = {
optimisticData: [
{
Expand Down
10 changes: 8 additions & 2 deletions src/libs/actions/connections/QuickbooksDesktop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,10 +429,13 @@ function updateQuickbooksDesktopEnableNewCategories<TSettingValue extends Connec
}

function updateQuickbooksDesktopSyncClasses<TSettingValue extends Connections['quickbooksDesktop']['config']['mappings']['classes']>(
policyID: string,
policyID: string | undefined,
settingValue: TSettingValue,
oldSettingValue?: TSettingValue,
) {
if (!policyID) {
return;
}
const onyxData = buildOnyxDataForQuickbooksDesktopMappingsConfiguration(policyID, CONST.QUICKBOOKS_DESKTOP_CONFIG.MAPPINGS.CLASSES, settingValue, oldSettingValue);
const parameters: UpdateQuickbooksDesktopGenericTypeParams = {
policyID,
Expand All @@ -443,10 +446,13 @@ function updateQuickbooksDesktopSyncClasses<TSettingValue extends Connections['q
}

function updateQuickbooksDesktopSyncCustomers<TSettingValue extends Connections['quickbooksDesktop']['config']['mappings']['customers']>(
policyID: string,
policyID: string | undefined,
settingValue: TSettingValue,
oldSettingValue?: TSettingValue,
) {
if (!policyID) {
return;
}
const onyxData = buildOnyxDataForQuickbooksDesktopMappingsConfiguration(policyID, CONST.QUICKBOOKS_DESKTOP_CONFIG.MAPPINGS.CUSTOMERS, settingValue, oldSettingValue);
const parameters: UpdateQuickbooksDesktopGenericTypeParams = {
policyID,
Expand Down
15 changes: 12 additions & 3 deletions src/libs/actions/connections/QuickbooksOnline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,13 @@ function updateQuickbooksOnlineReimbursableExpensesAccount<TSettingValue extends
}

function updateQuickbooksOnlineSyncLocations<TSettingValue extends Connections['quickbooksOnline']['config']['syncLocations']>(
policyID: string,
policyID: string | undefined,
settingValue: TSettingValue,
oldSettingValue?: TSettingValue,
) {
if (!policyID) {
return;
}
const onyxData = buildOnyxDataForQuickbooksConfiguration(policyID, CONST.QUICKBOOKS_CONFIG.SYNC_LOCATIONS, settingValue, oldSettingValue);

const parameters: UpdateQuickbooksOnlineGenericTypeParams = {
Expand All @@ -271,10 +274,13 @@ function updateQuickbooksOnlineSyncLocations<TSettingValue extends Connections['
}

function updateQuickbooksOnlineSyncCustomers<TSettingValue extends Connections['quickbooksOnline']['config']['syncCustomers']>(
policyID: string,
policyID: string | undefined,
settingValue: TSettingValue,
oldSettingValue?: TSettingValue,
) {
if (!policyID) {
return;
}
const onyxData = buildOnyxDataForQuickbooksConfiguration(policyID, CONST.QUICKBOOKS_CONFIG.SYNC_CUSTOMERS, settingValue, oldSettingValue);

const parameters: UpdateQuickbooksOnlineGenericTypeParams = {
Expand All @@ -286,10 +292,13 @@ function updateQuickbooksOnlineSyncCustomers<TSettingValue extends Connections['
}

function updateQuickbooksOnlineSyncClasses<TSettingValue extends Connections['quickbooksOnline']['config']['syncClasses']>(
policyID: string,
policyID: string | undefined,
settingValue: TSettingValue,
oldSettingValue?: TSettingValue,
) {
if (!policyID) {
return;
}
const onyxData = buildOnyxDataForQuickbooksConfiguration(policyID, CONST.QUICKBOOKS_CONFIG.SYNC_CLASSES, settingValue, oldSettingValue);
const parameters: UpdateQuickbooksOnlineGenericTypeParams = {
policyID,
Expand Down
4 changes: 3 additions & 1 deletion src/pages/home/report/ReportDetailsExportPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ function ReportDetailsExportPage({route}: ReportDetailsExportPageProps) {
},
],
isDisabled: !canBeExported,
keyForList: CONST.REPORT.EXPORT_OPTIONS.EXPORT_TO_INTEGRATION,
},
{
value: CONST.REPORT.EXPORT_OPTIONS.MARK_AS_EXPORTED,
Expand All @@ -95,6 +96,7 @@ function ReportDetailsExportPage({route}: ReportDetailsExportPageProps) {
},
],
isDisabled: !canBeExported,
keyForList: CONST.REPORT.EXPORT_OPTIONS.MARK_AS_EXPORTED,
},
];

Expand Down Expand Up @@ -125,7 +127,7 @@ function ReportDetailsExportPage({route}: ReportDetailsExportPageProps) {
accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN, CONST.POLICY.ACCESS_VARIANTS.PAID]}
featureName={CONST.POLICY.MORE_FEATURES.ARE_CONNECTIONS_ENABLED}
displayName="ReportDetailsExportPage"
sections={[{data: exportSelectorOptions}]}
data={exportSelectorOptions}
listItem={UserListItem}
shouldBeBlocked={false}
onBackButtonPress={() => Navigation.goBack(ROUTES.REPORT_WITH_ID_DETAILS.getRoute(reportID, backTo))}
Expand Down
Loading
Loading