Fix sticker seeder.

This commit is contained in:
Lucid Kobold
2022-01-03 14:07:03 -06:00
parent 71eaedea9d
commit 454ef47837
3 changed files with 21 additions and 10 deletions

View File

@@ -11,6 +11,7 @@ import {
isBefore,
compareAsc
} from "date-fns";
import stickersSeeder from "../data/stickerSeeder";
const CalenderContext = createContext({} as CalenderContextState);
@@ -40,8 +41,6 @@ const CalenderContextProvider = ({
]
};
//TODO Add a function that will populate the "MONTH" layout for the context. It should take in the start of the week (Sunday, Monday) and output the appropriate layout based on that preference.
/**
* Using date-fns, this function checks if currDate is within the month of selectedDate or not.
* @param {Date} selectedDate The current month.
@@ -74,6 +73,10 @@ const CalenderContextProvider = ({
return { isOverflow: flag, overflowDirection: direction };
};
const [stickersMonth, setStickersMonth] = useState<StickerDays>(
stickersSeeder()
);
/**
* A function that will return a month layout when given a date. It produces
* an object with 6 weeks that include overflow from the previous and next month
@@ -84,6 +87,9 @@ const CalenderContextProvider = ({
const endLastMonth = getDate(endOfMonth(sub(selectedDate, { months: 1 })));
const startOfSelectedMonth = format(startOfMonth(selectedDate), "iii");
// console.log(stickersMonth);
console.log(stickersSeeder());
const ISOToIndex = {
sunday: {
Sun: 0,
@@ -129,8 +135,10 @@ const CalenderContextProvider = ({
const day: MonthDay = {
...overflowInfo,
date: sunCurrDate
date: sunCurrDate,
// sticker: stickersMonth[getDate(sunCurrDate)].sticker
};
sunCurrDate = add(sunCurrDate, {
days: 1
});
@@ -162,8 +170,10 @@ const CalenderContextProvider = ({
const day: MonthDay = {
...overflowInfo,
date: monCurrDate
date: monCurrDate,
// sticker: stickersMonth[getDate(monCurrDate)].sticker
};
monCurrDate = add(monCurrDate, {
days: 1
});