Skip to content

Commit

Permalink
Allow sorting by more columns
Browse files Browse the repository at this point in the history
  • Loading branch information
Kicu committed May 21, 2024
1 parent 6e379da commit 7dab172
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/components/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ const columnNamesToPropertyMap = {
[CONST.SEARCH_TABLE_COLUMNS.MERCHANT]: 'merchant' as const,
[CONST.SEARCH_TABLE_COLUMNS.TOTAL]: 'formattedTotal' as const,
[CONST.SEARCH_TABLE_COLUMNS.CATEGORY]: 'category' as const,
[CONST.SEARCH_TABLE_COLUMNS.TYPE]: null,
[CONST.SEARCH_TABLE_COLUMNS.ACTION]: null,
[CONST.SEARCH_TABLE_COLUMNS.TYPE]: 'type' as const,
[CONST.SEARCH_TABLE_COLUMNS.ACTION]: 'action' as const,
[CONST.SEARCH_TABLE_COLUMNS.DESCRIPTION]: null,
[CONST.SEARCH_TABLE_COLUMNS.TAX_AMOUNT]: null,
};
Expand Down
3 changes: 1 addition & 2 deletions src/components/SelectionList/SearchTableHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,11 @@ const SearchColumns: SearchColumnConfig[] = [
{
columnName: CONST.SEARCH_TABLE_COLUMNS.TYPE,
translationKey: 'common.type',
isSortable: false,
shouldShowFn: () => true,
},
{
columnName: CONST.SEARCH_TABLE_COLUMNS.ACTION,
translationKey: 'common.action',
isSortable: false,
shouldShowFn: () => true,
},
];
Expand Down Expand Up @@ -104,6 +102,7 @@ function SearchTableHeader({data, sortBy, sortOrder, onSortPress}: SearchTableHe

return (
<SortableHeaderText
key={translationKey}
text={translate(translationKey)}
sortOrder={sortOrder ?? 'asc'}
isActive={isActive}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import ReportScreenWrapper from '@libs/Navigation/AppNavigator/ReportScreenWrapp
import getCurrentUrl from '@libs/Navigation/currentUrl';
import type {CentralPaneNavigatorParamList} from '@navigation/types';
import SearchPage from '@pages/Search/SearchPage';
import CONST from '@src/CONST';
import SCREENS from '@src/SCREENS';

const Stack = createStackNavigator<CentralPaneNavigatorParamList>();
Expand Down Expand Up @@ -44,7 +45,7 @@ function BaseCentralPaneNavigator() {
/>
<Stack.Screen
name={SCREENS.SEARCH.CENTRAL_PANE}
// We do it this way to avoid adding the url params to url
initialParams={{sortBy: CONST.SEARCH_TABLE_COLUMNS.DATE, sortOrder: 'asc'}}
component={SearchPage}
/>

Expand Down
5 changes: 0 additions & 5 deletions src/libs/SearchUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,6 @@ function getTransactionsSections(data: OnyxTypes.SearchResults['data']): Transac
shouldShowTax,
keyForList: transactionItem.transactionID,
};
})
.sort((a, b) => {
const createdA = a.modifiedCreated ? a.modifiedCreated : a.created;
const createdB = b.modifiedCreated ? b.modifiedCreated : b.created;
return createdB > createdA ? 1 : -1;
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/styles/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1582,7 +1582,7 @@ const createStyleUtils = (theme: ThemeColors, styles: ThemeStyles) => ({
columnWidth = {...getWidthStyle(variables.w28), ...styles.alignItemsCenter};
break;
case CONST.SEARCH_TABLE_COLUMNS.ACTION:
columnWidth = getWidthStyle(variables.w80);
columnWidth = {...getWidthStyle(variables.w80), ...styles.alignItemsCenter};
break;
default:
columnWidth = styles.flex1;
Expand Down

0 comments on commit 7dab172

Please sign in to comment.