14 lines
576 B
TypeScript
14 lines
576 B
TypeScript
import type { Group } from "@/lib/types";
|
|
|
|
/** The seeded group every client falls back to; the API forbids renaming or deleting it. */
|
|
export const DEFAULT_GROUP_ID = 1;
|
|
|
|
/**
|
|
* The group a form preselects. The list arrives ordered by name
|
|
* (groups_repo.zig), so `groups[0]` is the alphabetically first group, not the
|
|
* default — it is only the fallback for a list that lost the seeded group.
|
|
*/
|
|
export function defaultGroupId(groups: readonly Group[]): number {
|
|
return groups.find((group) => group.id === DEFAULT_GROUP_ID)?.id ?? groups[0]?.id ?? DEFAULT_GROUP_ID;
|
|
}
|