From 28e57da2668182cc19b7dc3dd691823208ecbfbf Mon Sep 17 00:00:00 2001 From: Alex Frantz Date: Sun, 13 Oct 2024 01:48:09 -0400 Subject: [PATCH] fix broken date on book stuff --- src/components/ProjectComponents/RecentBook.tsx | 14 ++++++++++---- src/components/ProjectComponents/RecentPhoto.tsx | 2 -- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/components/ProjectComponents/RecentBook.tsx b/src/components/ProjectComponents/RecentBook.tsx index 7f054a0..27282cb 100644 --- a/src/components/ProjectComponents/RecentBook.tsx +++ b/src/components/ProjectComponents/RecentBook.tsx @@ -43,9 +43,15 @@ export default function RecentBook() { }) }, []); - const parseDate = (date: Date) => { - const jsDate = new Date(date); - return `${jsDate.getFullYear()}/${jsDate.getMonth() + 1}/${jsDate.getDate()}`; + const getDateString = (startedOn: Date, finished: boolean) => { + if (startedOn && !finished) { + const startedOnDate = new Date(startedOn); + return "Started on " + startedOnDate.toLocaleDateString(); + } else if (finished) { + return "Finished!" + } else { + return "Just Added" + } } if (data && !loading) { @@ -53,7 +59,7 @@ export default function RecentBook() { { if (res.ok) { - console.log("ok!") const json = await res.json() setData(json.data[0]); setLoading(false) } else { - console.log("not ok :(") setErrorState("Failed to fetch data!"); setLoading(false); }