Skip to content

Commit 4e090fe

Browse files
authored
Fixed vercel update (#358)
2 parents 1ed798f + 3fb7e83 commit 4e090fe

3 files changed

Lines changed: 75 additions & 56 deletions

File tree

apps/searchneu/app/catalog/[term]/[course]/page.tsx

Lines changed: 6 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import { getSectionsByCourseId } from "@/lib/dal/sections";
44
import { getTrackedSectionIds } from "@/lib/dal/trackers";
55
import { ExpandableDescription } from "@/components/catalog/ExpandableDescription";
66
import { 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";
89
import { Suspense } from "react";
910
import { unstable_cache } from "next/cache";
1011
import { 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-
270221
function SectionsTableSkeleton() {
271222
return (
272223
<div className="bg-neu2 flex w-full flex-col gap-1 rounded-lg p-1">
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
"use client";
2+
3+
import { Globe, GlobeLock } from "lucide-react";
4+
5+
export function TermLastUpdated({
6+
updatedAt,
7+
isTermActive,
8+
}: {
9+
updatedAt: Date;
10+
isTermActive: boolean;
11+
}) {
12+
return (
13+
<span className="text-neu6 flex max-w-20 items-center gap-1 sm:max-w-full">
14+
{isTermActive ? (
15+
<>
16+
<Globe className="size-4" />
17+
<h2
18+
style={{ lineHeight: 1.3 }}
19+
className="text-neu6 text-xs italic md:text-sm"
20+
>
21+
{formatLastUpdatedString(updatedAt)}
22+
</h2>
23+
</>
24+
) : (
25+
<>
26+
<GlobeLock className="size-4" />
27+
<h2
28+
style={{ lineHeight: 1.3 }}
29+
className="text-neu6 text-xs italic md:text-sm"
30+
>
31+
{"Last updated " + updatedAt.toLocaleDateString()}
32+
</h2>
33+
</>
34+
)}
35+
</span>
36+
);
37+
}
38+
39+
function formatLastUpdatedString(date: Date) {
40+
const seconds = Math.floor((new Date().getTime() - date.getTime()) / 1000);
41+
let str = "Updated ";
42+
43+
if (seconds < 0) {
44+
str += "in the future???";
45+
return str;
46+
}
47+
48+
if (seconds < 60) {
49+
str += "less than a minute ago";
50+
return str;
51+
}
52+
53+
const minutes = Math.floor(seconds / 60);
54+
if (minutes < 60) {
55+
str += minutes === 1 ? "1 minute ago" : `${minutes} minutes ago`;
56+
return str;
57+
}
58+
59+
const hours = Math.floor(minutes / 60);
60+
if (hours < 24) {
61+
str += hours === 1 ? "1 hour ago" : `${hours} hours ago`;
62+
return str;
63+
}
64+
65+
const days = Math.floor(hours / 24);
66+
str += days === 1 ? "1 day ago" : `${days} days ago`;
67+
return str;
68+
}

apps/searchneu/vercel.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"functions": {
3-
"src/app/(app)/api/update/route.ts": {
3+
"app/api/update/route.ts": {
44
"maxDuration": 800
55
}
66
},

0 commit comments

Comments
 (0)