fix: fixed shortcuts population (#7016)
This PR fixes #6776 Screenshots: <img width="1728" alt="image" src="https://github.com/user-attachments/assets/ca061c30-ddb7-40ff-8c54-8b0d85d40864"> --------- Co-authored-by: sid0-0 <a@b.com> Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
This commit is contained in:
18
packages/twenty-front/src/utils/array/sortByProperty.ts
Normal file
18
packages/twenty-front/src/utils/array/sortByProperty.ts
Normal file
@ -0,0 +1,18 @@
|
||||
export const sortByProperty =
|
||||
<T, K extends keyof T>(propertyName: K, sortBy: 'asc' | 'desc' = 'asc') =>
|
||||
(objectA: T, objectB: T) => {
|
||||
const a = sortBy === 'asc' ? objectA : objectB;
|
||||
const b = sortBy === 'asc' ? objectB : objectA;
|
||||
|
||||
if (typeof a[propertyName] === 'string') {
|
||||
return (a[propertyName] as string).localeCompare(
|
||||
b[propertyName] as string,
|
||||
);
|
||||
} else if (typeof a[propertyName] === 'number') {
|
||||
return (a[propertyName] as number) - (b[propertyName] as number);
|
||||
} else {
|
||||
throw new Error(
|
||||
'Property type not supported in sortByProperty, only string and number are supported',
|
||||
);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user