diff --git a/client/src/components/AmountMissing.js b/client/src/components/AmountMissing.js index a7c51b8..aad6d13 100644 --- a/client/src/components/AmountMissing.js +++ b/client/src/components/AmountMissing.js @@ -1,5 +1,6 @@ import styles from "./AmountMissing.module.css"; import getClientLocalTime from "../lib/getClientLocalTime"; +import formatTimeString from "../lib/formatTimeString"; import { ReactComponent as Checkmark } from "../icons/AmountMissingIcon.svg"; import SkeletonText from "../skeletons/SkeletonText"; @@ -18,11 +19,8 @@ const AmountMissing = ({ data, showSkeleton }) => { ? Math.floor((new Date(now) - new Date(lastChecked)) / 60000) : 0; + const lastCheckedString = formatTimeString(lastCheckedMinutes); const lastCheckedDate = getClientLocalTime(lastChecked, "PP HH:mm"); - const lastCheckedString = - lastCheckedMinutes === 0 - ? "less than a minute ago" - : `${lastCheckedMinutes} minute${lastCheckedMinutes != 1 ? "s" : ""} ago`; const dateTime = getClientLocalTime(lastChecked, "yyyy-MM-dd HH:mm:ss.sss"); diff --git a/client/src/components/App.css b/client/src/components/App.css index f10d305..ec239f2 100644 --- a/client/src/components/App.css +++ b/client/src/components/App.css @@ -12,6 +12,7 @@ .right { display: flex; + align-items: flex-start; margin: 11rem 0rem 9rem 56vw; } diff --git a/client/src/components/Sort.module.css b/client/src/components/Sort.module.css index fce29f2..36a517c 100644 --- a/client/src/components/Sort.module.css +++ b/client/src/components/Sort.module.css @@ -1,3 +1,13 @@ +.sort { + position: fixed; + display: flex; + height: min-content; +} + +.option { + cursor: pointer; +} + .option .selected { border: 1px solid var(--color-white); } diff --git a/client/src/lib/formatTimeString.js b/client/src/lib/formatTimeString.js new file mode 100644 index 0000000..1204428 --- /dev/null +++ b/client/src/lib/formatTimeString.js @@ -0,0 +1,24 @@ +export default function formatTimeString(time) { + if (time < 1) { + return "less than a minute ago"; + } + + if (time < 60) { + const minutesString = time === 1 ? "minute" : "minutes"; + return `${time} ${minutesString} ago`; + } + if (time >= 60 && time < 1440) { + const hours = Math.floor(time / 60); + const hoursString = hours === 1 ? "hour" : "hours"; + const minutes = time % 60; + const minutesString = minutes === 1 ? "minute" : "minutes"; + + return `${hours} ${hoursString} ${ + minutes === 0 ? "" : `and ${minutes} ${minutesString} ` + }ago`; + } + + const days = Math.floor(time / (60 * 60 * 24)); + const daysString = days === 1 ? "day" : "days"; + return `${days} ${daysString} ago`; +} diff --git a/server/lib/getSpotifyEpisodeNames.js b/server/lib/getSpotifyEpisodeNames.js index 9729920..f31abf8 100644 --- a/server/lib/getSpotifyEpisodeNames.js +++ b/server/lib/getSpotifyEpisodeNames.js @@ -3,6 +3,7 @@ const SpotifyWebApi = require("spotify-web-api-node"); require("dotenv").config(); const JRE_SHOW_ID = "4rOoJ6Egrf8K2IrywzwOMk"; + async function getSpotifyEpisodeNames() { try { const spotifyApi = new SpotifyWebApi({