Skip to content

Commit

Permalink
chore: specify types for useProgressForDownloads
Browse files Browse the repository at this point in the history
  • Loading branch information
stefl committed Dec 9, 2024
1 parent af9645d commit 9d1ac25
Showing 1 changed file with 20 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
import { useMemo } from "react";

import type { LooseLessonPlan } from "@oakai/aila/src/protocol/schema";
import type {
LessonPlanKeys,
LooseLessonPlan,
} from "@oakai/aila/src/protocol/schema";
import { lessonPlanSectionsSchema } from "@oakai/exports/src/schema/input.schema";
import type { ZodIssue } from "zod";

export type ProgressForDownloads = {
sections: ProgressSection[];
totalSections: number;
totalSectionsComplete: number;
};

export type ProgressSection = {
label: string;
key: LessonPlanKeys;
complete: boolean;
};

export type ProgressSections = ProgressSection[];

/**
* For a given list of Zod issues and lessonPlan fields, checks that none of
* the errors pertain to the fields.
Expand All @@ -16,16 +33,6 @@ function getCompleteness(errors: ZodIssue[], fields: string[]) {

return !hasErrorInSomeField;
}
export type ProgressSections = {
label: string;
key: string;
complete: boolean;
}[];
type ProgressForDownloads = {
sections: ProgressSections;
totalSections: number;
totalSectionsComplete: number;
};

export function useProgressForDownloads({
lessonPlan,
Expand Down Expand Up @@ -60,7 +67,8 @@ export function useProgressForDownloads({
return true;
}
}) ?? [];
const sections = [

const sections: ProgressSection[] = [
{
label: "Lesson details",
key: "title",
Expand Down

0 comments on commit 9d1ac25

Please sign in to comment.