From a83fcc90448b9d56f0278c9a8c4622e61688c7f4 Mon Sep 17 00:00:00 2001 From: Heather Yu <35639529+hetd54@users.noreply.github.com> Date: Tue, 13 Aug 2024 15:25:52 -0400 Subject: [PATCH 1/4] chore: remove activity from navbar --- src/consts.ts | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/consts.ts b/src/consts.ts index 5d7956c..3850337 100644 --- a/src/consts.ts +++ b/src/consts.ts @@ -1,12 +1,4 @@ export const SITE_TITLE = "MMP" export const SITE_DESCRIPTION = "Mesoamerican Migration Project" -export const LINKS = [ - "people", - "news", - "publications", - "study-design", - "data", - "documentation", - "activity", -] +export const LINKS = ["people", "news", "publications", "study-design", "data", "documentation"] From dc7b751b2555e33698ee74a120856ab160e7c7f6 Mon Sep 17 00:00:00 2001 From: Heather Yu <35639529+hetd54@users.noreply.github.com> Date: Tue, 13 Aug 2024 15:27:41 -0400 Subject: [PATCH 2/4] chore: remove david's info from login error --- src/components/Login.tsx | 5 +---- src/pages/activity.astro | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/components/Login.tsx b/src/components/Login.tsx index 859b9fb..910cc06 100644 --- a/src/components/Login.tsx +++ b/src/components/Login.tsx @@ -13,10 +13,7 @@ const Login: React.FC = ({ currentUser, setUserFunction }) => { const login = async () => { await handleLogin().then((loggedUser) => { - if (!loggedUser) - setMessage( - "You must be an admin on this project in order to see this data. If you believe this to be an error, please reach out to David Lindstrom (david_lindstrom@brown.edu)." - ) + if (!loggedUser) setMessage("You must be an admin on this project in order to see this data.") setUserFunction(loggedUser) }) } diff --git a/src/pages/activity.astro b/src/pages/activity.astro index 80e4ba9..0b0af78 100644 --- a/src/pages/activity.astro +++ b/src/pages/activity.astro @@ -3,6 +3,6 @@ import Layout from "../layouts/Layout.astro" import ActivityPage from "../components/ActivityPage" --- - + From c130ce59426e8b2688fa7e74d7603a3e2f327e61 Mon Sep 17 00:00:00 2001 From: Heather Yu <35639529+hetd54@users.noreply.github.com> Date: Tue, 13 Aug 2024 16:02:16 -0400 Subject: [PATCH 3/4] chore: datefns to compare dates --- package-lock.json | 1 + package.json | 1 + 2 files changed, 2 insertions(+) diff --git a/package-lock.json b/package-lock.json index 2078229..21b2542 100644 --- a/package-lock.json +++ b/package-lock.json @@ -26,6 +26,7 @@ "@types/react": "^18.2.64", "@types/react-dom": "^18.2.21", "astro": "^4.3.6", + "date-fns": "^3.6.0", "firebase": "^9.23.0", "i": "^0.3.7", "react": "^18.2.0", diff --git a/package.json b/package.json index b201a3b..c069dc4 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "@types/react": "^18.2.64", "@types/react-dom": "^18.2.21", "astro": "^4.3.6", + "date-fns": "^3.6.0", "firebase": "^9.23.0", "i": "^0.3.7", "react": "^18.2.0", From b47fd770d2ca7a81f2f496803e43a977f60657e5 Mon Sep 17 00:00:00 2001 From: Heather Yu <35639529+hetd54@users.noreply.github.com> Date: Tue, 13 Aug 2024 16:02:36 -0400 Subject: [PATCH 4/4] feat: show number of downloads in the past year --- src/components/ActivityPage.tsx | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/components/ActivityPage.tsx b/src/components/ActivityPage.tsx index 7cca99e..6c0be34 100644 --- a/src/components/ActivityPage.tsx +++ b/src/components/ActivityPage.tsx @@ -1,5 +1,6 @@ import { useState } from "react" import type { UserInfo } from "firebase/auth" +import { isAfter, subYears, toDate } from "date-fns" import Login from "../components/Login" import { useActivityData } from "../hooks/activity.ts" import ActivityTable from "./ActivityTable.tsx" @@ -10,6 +11,9 @@ const ActivityPage = () => { setUser(loggedUser) } const activityData = useActivityData(user) + const yearlyActivityData = activityData?.filter((data) => + isAfter(toDate(data.date.toDate()), subYears(new Date(), 1)) + ) return (
@@ -22,10 +26,18 @@ const ActivityPage = () => { )} {user && activityData && ( -
-

- {activityData.length} download(s) -

+
+
+

+ {activityData.length} total download(s) +

+ {yearlyActivityData && ( +

+ {yearlyActivityData.length} download(s) in + the past year +

+ )} +
)}