Fix order by (#2646)

* Order by createdAt desc if no sort provided

* Fix '0' currency amounts

* Code review returns
This commit is contained in:
martmull
2023-11-22 16:19:04 +01:00
committed by GitHub
parent 0af4be0d24
commit 713eada9ef
4 changed files with 10 additions and 5 deletions

View File

@ -123,7 +123,7 @@ export const HooksCompanyBoardEffect = () => {
objectNamePlural: 'companies',
filter: {
id: {
in: opportunities.map((opportuntiy) => opportuntiy.companyId || ''),
in: opportunities.map((opportunity) => opportunity.companyId || ''),
},
},
onCompleted: useCallback((data: PaginatedObjectTypeResults<Company>) => {

View File

@ -35,7 +35,6 @@ export const useObjectRecordTable = () => {
tableFilters,
foundObjectMetadataItem?.fields ?? [],
);
const orderBy = turnSortsIntoOrderByV2(
tableSorts,
foundObjectMetadataItem?.fields ?? [],

View File

@ -7,6 +7,11 @@ export const turnSortsIntoOrderByV2 = (
fields: Pick<Field, 'id' | 'name'>[],
) => {
const sortsObject: Record<string, 'AscNullsFirst' | 'DescNullsLast'> = {};
if (!sorts.length) {
return {
createdAt: 'DescNullsFirst',
};
}
sorts.forEach((sort) => {
const correspondingField = fields.find(
(field) => field.id === sort.fieldMetadataId,