Updated logic using a more effecient method to check if the dates are the same.

This commit is contained in:
Lucid Kobold
2022-04-11 17:07:58 -05:00
parent b1c84c0922
commit 5ec57ff698
3 changed files with 20 additions and 18 deletions

View File

@@ -1,5 +1,5 @@
import React, { createContext, useState, ReactNode } from "react";
import { format, getDate, isBefore, startOfDay } from "date-fns";
import { format, getDate, isSameDay } from "date-fns";
import stickersSeeder from "../data/stickerSeeder";
const StickersContext = createContext({} as StickersContextState);
@@ -21,9 +21,9 @@ const StickersContextProvider = ({
const edited = currDate.edited
? true
: isBefore(currDate.date, startOfDay(new Date()))
? true
: false;
: isSameDay(currDate.date, new Date())
? false
: true;
currDate.edited = edited;
// Add manual here when necessary.

View File

@@ -20,8 +20,6 @@
"@emotion/react": "^11.9.0",
"@emotion/styled": "^11.8.1",
"@iconify/react": "^3.2.1",
"@types/react": "<=17.0.2",
"@types/react-redux": "^7.1.23",
"date-fns": "^2.28.0",
"formik": "^2.2.9",
"framer-motion": "^6.2.9",
@@ -33,6 +31,8 @@
},
"devDependencies": {
"@types/node": "^17.0.23",
"@types/react": "<=17.0.2",
"@types/react-redux": "^7.1.23",
"@typescript-eslint/eslint-plugin": "^5.18.0",
"eslint": "^8.13.0",
"eslint-config-next": "^12.1.4",

View File

@@ -7,18 +7,20 @@ import Head from "next/head";
function LCMPottyChart({ Component, pageProps }: AppProps): JSX.Element {
return (
<ChakraProvider theme={AppTheme}>
<Layout {...pageProps}>
<Head>
<title>{"LCM Potty Chart"}</title>
<meta
name="viewport"
content="width=device-width, user-scalable=yes, initial-scale=1.0"
/>
</Head>
<Component {...pageProps} />
</Layout>
</ChakraProvider>
<React.StrictMode>
<ChakraProvider theme={AppTheme}>
<Layout {...pageProps}>
<Head>
<title>{"LCM Potty Chart"}</title>
<meta
name="viewport"
content="width=device-width, user-scalable=yes, initial-scale=1.0"
/>
</Head>
<Component {...pageProps} />
</Layout>
</ChakraProvider>
</React.StrictMode>
);
}