import type { PersonalData } from '@/types' /** True when `member` is the signed-in user identified by `personalDataUuid`. */ export function isSelf(member: PersonalData, personalDataUuid: string | null): boolean { return personalDataUuid !== null && member.uuid === personalDataUuid } /** * Stable-sorts `members` so the signed-in user (if present among them) comes * first, leaving every other member in their original relative order. * * Used to put "your" `ParentBalanceForm` ahead of a partner's in any UI that * lists both — see `ParentBalanceForm.tsx`. */ export function orderSelfFirst( members: PersonalData[], personalDataUuid: string | null, ): PersonalData[] { const self = members.filter((m) => isSelf(m, personalDataUuid)) const others = members.filter((m) => !isSelf(m, personalDataUuid)) return [...self, ...others] }