20
apps/web/src/lib/reflection-utils.ts
Executable file
20
apps/web/src/lib/reflection-utils.ts
Executable file
@@ -0,0 +1,20 @@
|
||||
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);
|
||||
}
|
||||
Reference in New Issue
Block a user