diff --git a/contexts/CalenderContext.tsx b/contexts/CalenderContext.tsx index 7e38c43..eccfd82 100644 --- a/contexts/CalenderContext.tsx +++ b/contexts/CalenderContext.tsx @@ -11,80 +11,6 @@ import { isBefore, compareAsc } from "date-fns"; -// TODO: import types - -type Days = - | "Sunday" - | "Monday" - | "Tuesday" - | "Wednesday" - | "Thursday" - | "Friday" - | "Saturday"; - -type DaysOfWeek = Days[]; - -interface WeekDays { - sunday: DaysOfWeek; - monday: DaysOfWeek; -} - -interface Sticker { - date: Date; - sticker: -2 | -1 | 0 | 1 | 2 | null; -} - -interface MonthSticker { - date: Date; - month: Sticker[]; -} - -interface MonthDay extends Sticker { - isOverflow: boolean; - overflowDirection: "prev" | "next" | null; -} - -interface Month { - week1: MonthDay[]; - week2: MonthDay[]; - week3: MonthDay[]; - week4: MonthDay[]; - week5: MonthDay[]; - week6: MonthDay[]; -} - -interface MonthInfo { - date: Date; - title: string; -} - -interface MonthLayout { - sunday: { - weekdays: DaysOfWeek; - month: Month; - }; - monday: { - weekdays: DaysOfWeek; - month: Month; - }; -} - -interface MonthContext extends MonthInfo { - layout: MonthLayout; -} - -interface UpdateCalendarProps { - year: number; - month: number; - day: number; -} - -interface CalenderContextState { - selectedDate: Date; - title: string; - layout: MonthLayout; - updateDate: (input: UpdateCalendarProps) => void; -} const CalenderContext = createContext({} as CalenderContextState); diff --git a/data/stickerSeeder.ts b/data/stickerSeeder.ts index 7dbbb0d..2fa46b4 100644 --- a/data/stickerSeeder.ts +++ b/data/stickerSeeder.ts @@ -6,11 +6,6 @@ import { getDaysInMonth, getYear, getMonth, isBefore } from "date-fns"; * the day before the current date, leaving the rest of the month empty. */ -interface Sticker { - date: Date; - sticker: -2 | -1 | 0 | 1 | 2 | null; -} - const generateSticker = (): -2 | -1 | 0 | 1 | 2 => { const stickerPossibility = [-2, -1, 0, 1, 2]; const sticker = Math.floor(Math.random() * stickerPossibility.length); diff --git a/types/CalenderContext.d.ts b/types/CalenderContext.d.ts new file mode 100644 index 0000000..2943bd5 --- /dev/null +++ b/types/CalenderContext.d.ts @@ -0,0 +1,72 @@ +type Days = + | "Sunday" + | "Monday" + | "Tuesday" + | "Wednesday" + | "Thursday" + | "Friday" + | "Saturday"; + +type DaysOfWeek = Days[]; + +interface WeekDays { + sunday: DaysOfWeek; + monday: DaysOfWeek; +} + +interface Sticker { + date: Date; + sticker: -2 | -1 | 0 | 1 | 2 | null; +} + +interface MonthSticker { + date: Date; + month: Sticker[]; +} + +interface MonthDay extends Sticker { + isOverflow: boolean; + overflowDirection: "prev" | "next" | null; +} + +interface Month { + week1: MonthDay[]; + week2: MonthDay[]; + week3: MonthDay[]; + week4: MonthDay[]; + week5: MonthDay[]; + week6: MonthDay[]; +} + +interface MonthInfo { + date: Date; + title: string; +} + +interface MonthLayout { + sunday: { + weekdays: DaysOfWeek; + month: Month; + }; + monday: { + weekdays: DaysOfWeek; + month: Month; + }; +} + +interface MonthContext extends MonthInfo { + layout: MonthLayout; +} + +interface UpdateCalendarProps { + year: number; + month: number; + day: number; +} + +interface CalenderContextState { + selectedDate: Date; + title: string; + layout: MonthLayout; + updateDate: (input: UpdateCalendarProps) => void; +} \ No newline at end of file