Files
adventure/apps/web/src/lib/reflection-utils.ts
Zaine 3b37368e7d
Some checks failed
CI / test (push) Has been cancelled
initial 2
2026-06-26 09:26:50 +01:00

21 lines
562 B
TypeScript
Executable File

export type ReflectionData = {
wentWell: string;
learned: string;
improveTomorrow: string;
};
export function hasMeaningfulReflectionContent(data: ReflectionData): boolean {
return [data.wentWell, data.learned, data.improveTomorrow].some(
(field) => field.trim().length > 0
);
}
export function shouldAwardReflectionXp(
existing: ReflectionData | null | undefined,
data: ReflectionData
): boolean {
if (!hasMeaningfulReflectionContent(data)) return false;
if (!existing) return true;
return !hasMeaningfulReflectionContent(existing);
}