export const LESSON_APPARATUS = ['M', 'R', 'TT', 'Chair', 'ARC', 'SC', 'LB'] as const export type LessonApparatus = typeof LESSON_APPARATUS[number] export type ApparatusNotes = Partial> export const LESSON_NOTE_MAX_LENGTH = 1000 export function isApparatusNotes(value: unknown): value is ApparatusNotes { if (!value || typeof value !== 'object' || Array.isArray(value)) return false return Object.entries(value).every(([key, content]) => LESSON_APPARATUS.includes(key as LessonApparatus) && typeof content === 'string' && content.length <= LESSON_NOTE_MAX_LENGTH, ) } // Keep a stable apparatus order and omit fields the coach left blank. export function filledApparatusNotes(notes?: ApparatusNotes | null) { return LESSON_APPARATUS.flatMap(apparatus => { const content = notes?.[apparatus]?.trim() return content ? [{ apparatus, content }] : [] }) }