diff --git a/components/search/Blurb.tsx b/components/search/Blurb.tsx index 2d09cc8..12b8eef 100644 --- a/components/search/Blurb.tsx +++ b/components/search/Blurb.tsx @@ -1,6 +1,6 @@ -import React, { useEffect, useState } from 'react'; -import { CourseObject, FilterValues } from './Search'; -import { formatDistanceToNow } from 'date-fns'; +import React, { useEffect, useState } from "react"; +import { CourseObject, FilterValues } from "./Search"; +import { formatDistanceToNow } from "date-fns"; interface BlurbProps { filterData: ( @@ -15,20 +15,22 @@ interface BlurbProps { const Blurb = (props: BlurbProps) => { const { filterData, courses, lastUpdated, filterValues } = props; - const [timeAgo, setTimeAgo] = useState(''); + const [timeAgo, setTimeAgo] = useState(""); useEffect(() => { const updateRelativeTime = () => { if (lastUpdated) { - const formattedTimeAgo = formatDistanceToNow(new Date(lastUpdated)); + const formattedTimeAgo = formatDistanceToNow( + new Date(lastUpdated), + ); setTimeAgo(`${formattedTimeAgo} ago`); } }; - updateRelativeTime(); // Update initially - const intervalId = setInterval(updateRelativeTime, 1000); // Update every second + updateRelativeTime(); + const intervalId = setInterval(updateRelativeTime, 1000); - return () => clearInterval(intervalId); // Cleanup on unmount + return () => clearInterval(intervalId); }, [lastUpdated]); return ( @@ -48,7 +50,8 @@ const Blurb = (props: BlurbProps) => {
- {"GE-Z's"} data was updated {lastUpdated ? timeAgo : '[oopsie, time not available :(]'} + {"GE-Z's"} data was updated{" "} + {lastUpdated ? timeAgo : "x"}