Skip to content

Commit f2dad3a

Browse files
authored
Merge pull request #47091 from cretadn22/new-design-in-selection-page
2 parents a14668a + 48a3dae commit f2dad3a

File tree

7 files changed

+76
-18
lines changed

7 files changed

+76
-18
lines changed

src/components/SelectionList/BaseSelectionList.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,11 @@ function BaseSelectionList<TItem extends ListItem>(
538538

539539
useEffect(() => {
540540
// Avoid changing focus if the textInputValue remains unchanged.
541-
if ((prevTextInputValue === textInputValue && flattenedSections.selectedOptions.length === prevSelectedOptionsLength) || flattenedSections.allOptions.length === 0) {
541+
if (
542+
(prevTextInputValue === textInputValue && flattenedSections.selectedOptions.length === prevSelectedOptionsLength) ||
543+
flattenedSections.allOptions.length === 0 ||
544+
shouldUpdateFocusedIndex
545+
) {
542546
return;
543547
}
544548
// Remove the focus if the search input is empty or selected options length is changed (and allOptions length remains the same)
@@ -559,6 +563,7 @@ function BaseSelectionList<TItem extends ListItem>(
559563
updateAndScrollToFocusedIndex,
560564
prevSelectedOptionsLength,
561565
prevAllOptionsLength,
566+
shouldUpdateFocusedIndex,
562567
]);
563568

564569
useEffect(

src/languages/en.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ export default {
266266
enterDate: 'Enter a date.',
267267
invalidTimeRange: 'Please enter a time using the 12-hour clock format (e.g., 2:30 PM).',
268268
pleaseCompleteForm: 'Please complete the form above to continue.',
269+
pleaseSelectOne: 'Please select an option above.',
269270
},
270271
comma: 'comma',
271272
semicolon: 'semicolon',

src/languages/es.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ export default {
256256
enterDate: 'Introduce una fecha.',
257257
invalidTimeRange: 'Por favor, introduce una hora entre 1 y 12 (por ejemplo, 2:30 PM).',
258258
pleaseCompleteForm: 'Por favor complete el formulario de arriba para continuar.',
259+
pleaseSelectOne: 'Seleccione una de las opciones.',
259260
},
260261
comma: 'la coma',
261262
semicolon: 'el punto y coma',

src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomFieldNew/NetSuiteCustomFieldMappingPicker.tsx

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
11
import React from 'react';
2+
import {View} from 'react-native';
3+
import FormHelpMessage from '@components/FormHelpMessage';
24
import SelectionList from '@components/SelectionList';
35
import RadioListItem from '@components/SelectionList/RadioListItem';
46
import useLocalize from '@hooks/useLocalize';
7+
import useThemeStyles from '@hooks/useThemeStyles';
58
import CONST from '@src/CONST';
69

710
type NetSuiteCustomListPickerProps = {
811
/** Selected mapping value */
912
value?: string;
1013

14+
/** Text to display on error message */
15+
errorText?: string;
16+
1117
/** Callback to fire when mapping is selected */
1218
onInputChange?: (value: string) => void;
1319
};
1420

15-
function NetSuiteCustomFieldMappingPicker({value, onInputChange}: NetSuiteCustomListPickerProps) {
21+
function NetSuiteCustomFieldMappingPicker({value, errorText, onInputChange}: NetSuiteCustomListPickerProps) {
1622
const {translate} = useLocalize();
23+
const styles = useThemeStyles();
1724

1825
const options = [CONST.INTEGRATION_ENTITY_MAP_TYPES.TAG, CONST.INTEGRATION_ENTITY_MAP_TYPES.REPORT_FIELD];
1926

@@ -27,14 +34,26 @@ function NetSuiteCustomFieldMappingPicker({value, onInputChange}: NetSuiteCustom
2734
})) ?? [];
2835

2936
return (
30-
<SelectionList
31-
sections={[{data: selectionData}]}
32-
onSelectRow={(selected) => {
33-
onInputChange?.(selected.value);
34-
}}
35-
ListItem={RadioListItem}
36-
initiallyFocusedOptionKey={value ?? CONST.INTEGRATION_ENTITY_MAP_TYPES.TAG}
37-
/>
37+
<>
38+
<SelectionList
39+
sections={[{data: selectionData}]}
40+
onSelectRow={(selected) => {
41+
onInputChange?.(selected.value);
42+
}}
43+
ListItem={RadioListItem}
44+
initiallyFocusedOptionKey={value ?? CONST.INTEGRATION_ENTITY_MAP_TYPES.TAG}
45+
shouldSingleExecuteRowSelect
46+
shouldUpdateFocusedIndex
47+
/>
48+
{!!errorText && (
49+
<View style={styles.ph5}>
50+
<FormHelpMessage
51+
isError={!!errorText}
52+
message={errorText}
53+
/>
54+
</View>
55+
)}
56+
</>
3857
);
3958
}
4059

src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomFieldNew/NetSuiteImportAddCustomSegmentPage.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,10 @@ function NetSuiteImportAddCustomSegmentPage({policy}: WithPolicyConnectionsProps
122122
}
123123
return errors;
124124
case CONST.NETSUITE_CUSTOM_FIELD_SUBSTEP_INDEXES.CUSTOM_SEGMENTS.MAPPING:
125-
return ValidationUtils.getFieldRequiredErrors(values, [INPUT_IDS.MAPPING]);
125+
if (!ValidationUtils.isRequiredFulfilled(values[INPUT_IDS.MAPPING])) {
126+
errors[INPUT_IDS.MAPPING] = translate('common.error.pleaseSelectOne');
127+
}
128+
return errors;
126129
default:
127130
return errors;
128131
}
@@ -206,6 +209,7 @@ function NetSuiteImportAddCustomSegmentPage({policy}: WithPolicyConnectionsProps
206209
enabledWhenOffline
207210
isSubmitDisabled={!!config?.syncOptions?.pendingFields?.customSegments}
208211
submitFlexEnabled={submitFlexAllowed}
212+
shouldHideFixErrorsAlert={screenIndex === CONST.NETSUITE_CUSTOM_FIELD_SUBSTEP_INDEXES.CUSTOM_SEGMENTS.MAPPING}
209213
>
210214
{renderSubStepContent}
211215
</FormProvider>

src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomFieldNew/substeps/ChooseSegmentTypeStep.tsx

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import React from 'react';
1+
import React, {useState} from 'react';
2+
import {View} from 'react-native';
3+
import FormHelpMessage from '@components/FormHelpMessage';
24
import SelectionList from '@components/SelectionList';
35
import RadioListItem from '@components/SelectionList/RadioListItem';
46
import Text from '@components/Text';
@@ -10,22 +12,33 @@ import CONST from '@src/CONST';
1012
function ChooseSegmentTypeStep({onNext, customSegmentType, setCustomSegmentType}: CustomFieldSubStepWithPolicy) {
1113
const styles = useThemeStyles();
1214
const {translate} = useLocalize();
15+
const [selectedType, setSelectedType] = useState(customSegmentType);
16+
const [isError, setIsError] = useState(false);
1317

1418
const selectionData = [
1519
{
1620
text: translate(`workspace.netsuite.import.importCustomFields.customSegments.addForm.segmentTitle`),
1721
keyForList: CONST.NETSUITE_CUSTOM_RECORD_TYPES.CUSTOM_SEGMENT,
18-
isSelected: customSegmentType === CONST.NETSUITE_CUSTOM_RECORD_TYPES.CUSTOM_SEGMENT,
22+
isSelected: selectedType === CONST.NETSUITE_CUSTOM_RECORD_TYPES.CUSTOM_SEGMENT,
1923
value: CONST.NETSUITE_CUSTOM_RECORD_TYPES.CUSTOM_SEGMENT,
2024
},
2125
{
2226
text: translate(`workspace.netsuite.import.importCustomFields.customSegments.addForm.recordTitle`),
2327
keyForList: CONST.NETSUITE_CUSTOM_RECORD_TYPES.CUSTOM_RECORD,
24-
isSelected: customSegmentType === CONST.NETSUITE_CUSTOM_RECORD_TYPES.CUSTOM_RECORD,
28+
isSelected: selectedType === CONST.NETSUITE_CUSTOM_RECORD_TYPES.CUSTOM_RECORD,
2529
value: CONST.NETSUITE_CUSTOM_RECORD_TYPES.CUSTOM_RECORD,
2630
},
2731
];
2832

33+
const onConfirm = () => {
34+
if (!selectedType) {
35+
setIsError(true);
36+
} else {
37+
setCustomSegmentType?.(selectedType);
38+
onNext();
39+
}
40+
};
41+
2942
return (
3043
<>
3144
<Text style={[styles.ph5, styles.textHeadlineLineHeightXXL, styles.mb3]}>
@@ -35,12 +48,26 @@ function ChooseSegmentTypeStep({onNext, customSegmentType, setCustomSegmentType}
3548
<SelectionList
3649
sections={[{data: selectionData}]}
3750
ListItem={RadioListItem}
38-
initiallyFocusedOptionKey={customSegmentType}
51+
initiallyFocusedOptionKey={selectedType}
3952
onSelectRow={(selected) => {
40-
setCustomSegmentType?.(selected.value);
41-
onNext();
53+
setSelectedType(selected.value);
54+
setIsError(false);
4255
}}
43-
/>
56+
shouldSingleExecuteRowSelect
57+
shouldUpdateFocusedIndex
58+
showConfirmButton
59+
confirmButtonText={translate('common.next')}
60+
onConfirm={onConfirm}
61+
>
62+
{isError && (
63+
<View style={[styles.ph5, styles.mb5]}>
64+
<FormHelpMessage
65+
isError={isError}
66+
message={translate('common.error.pleaseSelectOne')}
67+
/>
68+
</View>
69+
)}
70+
</SelectionList>
4471
</>
4572
);
4673
}

src/pages/workspace/expensifyCard/WorkspaceEditCardLimitTypePage.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ function WorkspaceEditCardLimitTypePage({route}: WorkspaceEditCardLimitTypePageP
118118
onSelectRow={({value}) => setTypeSelected(value)}
119119
sections={[{data}]}
120120
shouldUpdateFocusedIndex
121+
shouldSingleExecuteRowSelect
121122
isAlternateTextMultilineSupported
122123
initiallyFocusedOptionKey={typeSelected}
123124
/>

0 commit comments

Comments
 (0)