Skip to content

Commit 680a6a6

Browse files
authored
Added last updated time for OH (#100)
* Added last updated time for OH * Added lastUpdated field for OH * Added formatting date function for last updated
2 parents 10f0609 + 5228f4d commit 680a6a6

3 files changed

Lines changed: 23 additions & 6 deletions

File tree

src/components/homepage/Sponsors.svelte

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
import Link from 'components/Link.svelte';
44
import Button from 'components/Button.svelte';
55
6-
let { sponsors } = $props<{ sponsors: Sponsors[] }>();
6+
let { sponsors, lastUpdated } = $props<{
7+
sponsors: Sponsors[];
8+
lastUpdated?: string | null;
9+
}>();
710
</script>
811

912
<div class="container mx-auto px-4">
@@ -17,7 +20,7 @@
1720
and our community.
1821
</p>
1922
<div
20-
class="via-ecsess-150/40 mx-auto mt-6 h-px w-32 bg-linear-to-r from-transparent to-transparent"
23+
class="via-ecsess-150/40 mx-auto mt-2 h-px w-32 bg-linear-to-r from-transparent to-transparent"
2124
aria-hidden="true"
2225
></div>
2326
<div class="mt-6">

src/routes/+page.server.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,19 @@ const homepageQuery = `{
1515
"position": member->position
1616
}
1717
},
18+
"ohLastUpdated": *[_type=="officeHours"] | order(_updatedAt desc)[0]._updatedAt,
1819
"sponsors": *[_type=="sponsors"]{
1920
name,
2021
url,
2122
"logo": logo.asset->url+"?h=100&fm=webp"
22-
}
23+
},
24+
"sponsorsLastUpdated": *[_type=="sponsors"] | order(_updatedAt desc)[0]._updatedAt
2325
}`;
2426

27+
function formattingDate(date: Date) {
28+
return date.toISOString().slice(0, 10).replaceAll('-', '/');
29+
}
30+
2531
export const load = async ({ url }) => {
2632
/**
2733
* @description Response data type based on the combined query above.
@@ -36,6 +42,8 @@ export const load = async ({ url }) => {
3642
councilPhoto: councilPhotoUrl,
3743
allOHs: officeHourResp,
3844
sponsors: sponsorsResp,
39-
canonical: url.href
45+
canonical: url.href,
46+
ohLastUpdated: formattingDate(new Date(homePageResp.ohLastUpdated)),
47+
sponsorsLastUpdated: formattingDate(new Date(homePageResp.sponsorsLastUpdated))
4048
};
4149
};

src/routes/+page.svelte

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,23 @@
6969
<Section from="from-ecsess-900" to="to-ecsess-700" via="via-ecsess-650">
7070
<div class="w-full">
7171
<h2 class="text-2xl font-bold" id="office-hours">Lounge Office Hours</h2>
72-
<p class="text-ecsess-200 mb-8">
72+
<p class="text-ecsess-200">
7373
Come visit us in our student lounge at ENGTR 1060 to grab a coffee (free), play Mario Kart, or
7474
just chat about anything!
75+
{#if data.ohLastUpdated}
76+
<br />
77+
<span class="text-ecsess-200/70 mb-4 inline-block italic">
78+
Last updated: {data.ohLastUpdated}
79+
</span>
80+
{/if}
7581
</p>
7682
<OhSchedule allOhs={data.allOHs} />
7783
</div>
7884
</Section>
7985

8086
<!-- Sponsors -->
8187
<Section from="from-ecsess-700" to="to-ecsess-800" via="via-ecsess-750">
82-
<Sponsors sponsors={data.sponsors} />
88+
<Sponsors sponsors={data.sponsors} lastUpdated={data.sponsorsLastUpdated} />
8389
</Section>
8490

8591
<!-- Affiliated Clubs -->

0 commit comments

Comments
 (0)