diff --git a/src/LastUpdated.tsx b/src/LastUpdated.tsx index 03c9a06..d2f3ce0 100644 --- a/src/LastUpdated.tsx +++ b/src/LastUpdated.tsx @@ -1,5 +1,5 @@ import { useEffect, useState } from "react"; -import { formatDistanceToNow, parseISO, formatISO } from "date-fns"; +import { formatDistanceToNow, differenceInSeconds, parseISO, formatISO } from "date-fns"; import { API_ENDPOINT } from "./Common"; const LastUpdated = () => { @@ -17,9 +17,12 @@ const LastUpdated = () => { // Loading state return ...; } + + const chipColor = differenceInSeconds(new Date(), updatedTimestamp) > (15 * 60) + ? "chip-yellow" : "chip-green"; return ( - + {"Data updated "}