@@ -4,7 +4,8 @@ import { getSectionsByCourseId } from "@/lib/dal/sections";
44import { getTrackedSectionIds } from "@/lib/dal/trackers" ;
55import { ExpandableDescription } from "@/components/catalog/ExpandableDescription" ;
66import { Separator } from "@/components/ui/separator" ;
7- import { ExternalLink , Globe , GlobeLock } from "lucide-react" ;
7+ import { ExternalLink } from "lucide-react" ;
8+ import { TermLastUpdated } from "@/components/catalog/TermLastUpdated" ;
89import { Suspense } from "react" ;
910import { unstable_cache } from "next/cache" ;
1011import { type Requisite } from "@sneu/scraper/types" ;
@@ -91,29 +92,10 @@ export default async function Page(props: {
9192 >
9293 { formatCreditRangeString ( course . minCredits , course . maxCredits ) }
9394 </ h2 >
94- < span className = "text-neu6 flex max-w-20 items-center gap-1 sm:max-w-full" >
95- { isTermActive ? (
96- < >
97- < Globe className = "size-4" />
98- < h2
99- style = { { lineHeight : 1.3 } }
100- className = "text-neu6 text-xs italic md:text-sm"
101- >
102- { formatLastUpdatedString ( term ?. updatedAt ) }
103- </ h2 >
104- </ >
105- ) : (
106- < >
107- < GlobeLock className = "size-4" />
108- < h2
109- style = { { lineHeight : 1.3 } }
110- className = "text-neu6 text-xs italic md:text-sm"
111- >
112- { "Last updated " + term . updatedAt . toLocaleDateString ( ) }
113- </ h2 >
114- </ >
115- ) }
116- </ span >
95+ < TermLastUpdated
96+ updatedAt = { term . updatedAt }
97+ isTermActive = { isTermActive }
98+ />
11799 </ div >
118100 </ div >
119101
@@ -236,37 +218,6 @@ function formatCreditRangeString(minCredits: string, maxCredits: string) {
236218 return creditRange + " " + creditLabel ;
237219}
238220
239- function formatLastUpdatedString ( date : Date ) {
240- const seconds = Math . floor ( ( new Date ( ) . getTime ( ) - date . getTime ( ) ) / 1000 ) ;
241- let str = "Updated " ;
242-
243- if ( seconds < 0 ) {
244- str += "in the future???" ;
245- return str ;
246- }
247-
248- if ( seconds < 60 ) {
249- str += "less than a minute ago" ;
250- return str ;
251- }
252-
253- const minutes = Math . floor ( seconds / 60 ) ;
254- if ( minutes < 60 ) {
255- str += minutes === 1 ? "1 minute ago" : `${ minutes } minutes ago` ;
256- return str ;
257- }
258-
259- const hours = Math . floor ( minutes / 60 ) ;
260- if ( hours < 24 ) {
261- str += hours === 1 ? "1 hour ago" : `${ hours } hours ago` ;
262- return str ;
263- }
264-
265- const days = Math . floor ( hours / 24 ) ;
266- str += days === 1 ? "1 day ago" : `${ days } days ago` ;
267- return str ;
268- }
269-
270221function SectionsTableSkeleton ( ) {
271222 return (
272223 < div className = "bg-neu2 flex w-full flex-col gap-1 rounded-lg p-1" >
0 commit comments