Upgrades #54
@@ -21,6 +21,7 @@ interface DayProps {
|
|||||||
sticker: StickerVal;
|
sticker: StickerVal;
|
||||||
date: Date;
|
date: Date;
|
||||||
selectedDate: Date;
|
selectedDate: Date;
|
||||||
|
currDate: Date;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -37,7 +38,8 @@ const Day = ({
|
|||||||
overflowDirection,
|
overflowDirection,
|
||||||
sticker,
|
sticker,
|
||||||
date,
|
date,
|
||||||
selectedDate
|
selectedDate,
|
||||||
|
currDate
|
||||||
}: DayProps): JSX.Element => {
|
}: DayProps): JSX.Element => {
|
||||||
const handleNav = (direction: "next" | "prev") => {
|
const handleNav = (direction: "next" | "prev") => {
|
||||||
if (direction === "next") {
|
if (direction === "next") {
|
||||||
@@ -90,7 +92,7 @@ const Day = ({
|
|||||||
w="100%"
|
w="100%"
|
||||||
h="100%"
|
h="100%"
|
||||||
_hover={{
|
_hover={{
|
||||||
cursor: isBefore(date, endOfDay(new Date()))
|
cursor: isBefore(date, endOfDay(currDate))
|
||||||
? "pointer"
|
? "pointer"
|
||||||
: "default",
|
: "default",
|
||||||
background: "gray.700",
|
background: "gray.700",
|
||||||
@@ -131,7 +133,7 @@ const Day = ({
|
|||||||
justifyContent="flex-start"
|
justifyContent="flex-start"
|
||||||
pt={2}
|
pt={2}
|
||||||
_hover={{
|
_hover={{
|
||||||
cursor: isBefore(date, endOfDay(new Date()))
|
cursor: isBefore(date, endOfDay(currDate))
|
||||||
? "pointer"
|
? "pointer"
|
||||||
: "default",
|
: "default",
|
||||||
background: "gray.700",
|
background: "gray.700",
|
||||||
@@ -140,7 +142,7 @@ const Day = ({
|
|||||||
>
|
>
|
||||||
<Text
|
<Text
|
||||||
p={
|
p={
|
||||||
isSameDay(new Date(), date)
|
isSameDay(currDate, date)
|
||||||
? getDate(date) > 10
|
? getDate(date) > 10
|
||||||
? "0px 6px 3px 6px"
|
? "0px 6px 3px 6px"
|
||||||
: "0px 9px 3px 9px"
|
: "0px 9px 3px 9px"
|
||||||
@@ -148,8 +150,8 @@ const Day = ({
|
|||||||
}
|
}
|
||||||
h="auto"
|
h="auto"
|
||||||
w="auto"
|
w="auto"
|
||||||
border={isSameDay(new Date(), date) ? "1px solid #0068ff" : "0px"}
|
border={isSameDay(currDate, date) ? "1px solid #0068ff" : "0px"}
|
||||||
borderRadius={isSameDay(new Date(), date) ? "100px" : "0px"}
|
borderRadius={isSameDay(currDate, date) ? "100px" : "0px"}
|
||||||
>
|
>
|
||||||
{`${getDate(date)}`}
|
{`${getDate(date)}`}
|
||||||
</Text>
|
</Text>
|
||||||
@@ -162,7 +164,7 @@ const Day = ({
|
|||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
<StickersContextProvider>
|
<StickersContextProvider>
|
||||||
{isBefore(date, endOfDay(new Date())) && (
|
{isBefore(date, endOfDay(currDate)) && (
|
||||||
<AddUpdateSticker
|
<AddUpdateSticker
|
||||||
date={date}
|
date={date}
|
||||||
isOpen={isOpen}
|
isOpen={isOpen}
|
||||||
@@ -173,6 +175,7 @@ const Day = ({
|
|||||||
updateStep={setStep}
|
updateStep={setStep}
|
||||||
selectedSticker={selectedSticker}
|
selectedSticker={selectedSticker}
|
||||||
updateSelectedSticker={setSelectedSticker}
|
updateSelectedSticker={setSelectedSticker}
|
||||||
|
currDate={currDate}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</StickersContextProvider>
|
</StickersContextProvider>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import CalenderNav from "./CalenderNav";
|
|||||||
import Day from "./Day";
|
import Day from "./Day";
|
||||||
|
|
||||||
const Calender = (newDate?: UpdateCalendarProps): JSX.Element => {
|
const Calender = (newDate?: UpdateCalendarProps): JSX.Element => {
|
||||||
const { selectedDate, layout, updateDate } = useContext(CalenderContext);
|
const { selectedDate, layout, updateDate, currDate } = useContext(CalenderContext);
|
||||||
const { stickersMonth } = useContext(StickersContext);
|
const { stickersMonth } = useContext(StickersContext);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -91,6 +91,7 @@ const Calender = (newDate?: UpdateCalendarProps): JSX.Element => {
|
|||||||
sticker={sticker}
|
sticker={sticker}
|
||||||
date={date}
|
date={date}
|
||||||
selectedDate={selectedDate}
|
selectedDate={selectedDate}
|
||||||
|
currDate={currDate}
|
||||||
key={
|
key={
|
||||||
id.length
|
id.length
|
||||||
? id
|
? id
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ interface AddStickerProps {
|
|||||||
updateStep: React.Dispatch<React.SetStateAction<number>>;
|
updateStep: React.Dispatch<React.SetStateAction<number>>;
|
||||||
selectedSticker: StickerVal;
|
selectedSticker: StickerVal;
|
||||||
updateSelectedSticker: React.Dispatch<React.SetStateAction<StickerVal>>;
|
updateSelectedSticker: React.Dispatch<React.SetStateAction<StickerVal>>;
|
||||||
|
currDate: Date;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -52,7 +53,8 @@ const AddUpdateSticker = ({
|
|||||||
step,
|
step,
|
||||||
updateStep,
|
updateStep,
|
||||||
selectedSticker,
|
selectedSticker,
|
||||||
updateSelectedSticker
|
updateSelectedSticker,
|
||||||
|
currDate
|
||||||
}: AddStickerProps): JSX.Element => {
|
}: AddStickerProps): JSX.Element => {
|
||||||
// TODO: Import the stickers array from the calender context.
|
// TODO: Import the stickers array from the calender context.
|
||||||
|
|
||||||
@@ -61,7 +63,7 @@ const AddUpdateSticker = ({
|
|||||||
// ! Update these states to say "add" and "edit" for easier reading.
|
// ! Update these states to say "add" and "edit" for easier reading.
|
||||||
|
|
||||||
const [modalVariant] = useState<"currDate" | "notCurrDate">(
|
const [modalVariant] = useState<"currDate" | "notCurrDate">(
|
||||||
isSameDay(date, new Date()) ? "currDate" : "notCurrDate"
|
isSameDay(date, currDate) ? "currDate" : "notCurrDate"
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleClose = () => {
|
const handleClose = () => {
|
||||||
|
|||||||
@@ -240,7 +240,11 @@ const CalenderContextProvider = ({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const calenderContextValues = {
|
// * Attempting to fix an issue with static generation where the date does not appear to be updating after initial generation.
|
||||||
|
const [currDate] = useState<Date>(new Date);
|
||||||
|
|
||||||
|
const calenderContextValues: CalenderContextState = {
|
||||||
|
currDate,
|
||||||
selectedDate,
|
selectedDate,
|
||||||
title: selectedDateInfo.title,
|
title: selectedDateInfo.title,
|
||||||
layout: selectedDateInfo.layout,
|
layout: selectedDateInfo.layout,
|
||||||
|
|||||||
1
types/CalenderContext.d.ts
vendored
1
types/CalenderContext.d.ts
vendored
@@ -55,6 +55,7 @@ interface UpdateCalendarProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface CalenderContextState {
|
interface CalenderContextState {
|
||||||
|
currDate: Date;
|
||||||
selectedDate: Date;
|
selectedDate: Date;
|
||||||
title: string;
|
title: string;
|
||||||
layout: MonthLayout;
|
layout: MonthLayout;
|
||||||
|
|||||||
Reference in New Issue
Block a user