Relation picker module (#335)

- Created a relation picker module
- Added a CustomeEntityForSelect type
This commit is contained in:
Lucas Bordeau
2023-06-20 11:06:53 +02:00
committed by GitHub
parent c120903a45
commit e2eb40c1ea
9 changed files with 64 additions and 50 deletions

View File

@ -1,10 +1,9 @@
import { EntityForSelect } from '@/comments/components/MultipleEntitySelect';
import { EntityForSelect } from '@/relation-picker/types/EntityForSelect';
export function flatMapAndSortEntityForSelectArrayOfArrayByName(
entityForSelectArray: EntityForSelect[][],
) {
const sortByName = (a: EntityForSelect, b: EntityForSelect) =>
a.name.localeCompare(b.name);
export function flatMapAndSortEntityForSelectArrayOfArrayByName<
T extends EntityForSelect,
>(entityForSelectArray: T[][]) {
const sortByName = (a: T, b: T) => a.name.localeCompare(b.name);
return entityForSelectArray.flatMap((entity) => entity).sort(sortByName);
}