File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -219,6 +219,19 @@ function AddUnreportedExpense({route}: AddUnreportedExpensePageType) {
219219 [ errorMessage ] ,
220220 ) ;
221221
222+ const onSelectAll = ( ) => {
223+ setSelectedIds ( ( prevSelectedIDs ) => {
224+ const availableUnreportedExpenses = unreportedExpenses . filter ( ( { isDisabled} ) => ! isDisabled ) ;
225+ if ( availableUnreportedExpenses . some ( ( { transactionID} ) => prevSelectedIDs . has ( transactionID ) ) ) {
226+ return new Set ( ) ;
227+ }
228+ if ( errorMessage ) {
229+ setErrorMessage ( '' ) ;
230+ }
231+ return new Set ( availableUnreportedExpenses . map ( ( { transactionID} ) => transactionID ) ) ;
232+ } ) ;
233+ } ;
234+
222235 const hasSearchTerm = debouncedSearchValue . trim ( ) . length > 0 ;
223236 const isShowingEmptyState = ! hasSearchTerm && transactions . length === 0 ;
224237
@@ -300,6 +313,8 @@ function AddUnreportedExpense({route}: AddUnreportedExpensePageType) {
300313 data = { unreportedExpenses }
301314 ref = { selectionListRef }
302315 onSelectRow = { onSelectRow }
316+ onSelectAll = { onSelectAll }
317+ style = { { listHeaderWrapperStyle : styles . ph8 } }
303318 textInputOptions = { textInputOptions }
304319 shouldShowTextInput = { shouldShowTextInput }
305320 canSelectMultiple
You can’t perform that action at this time.
0 commit comments