Checkpoint for implementing OH Schedule

This commit is contained in:
Antoine Phan
2025-07-08 17:47:54 -04:00
parent 0639f07bf7
commit 9c3e2fad64
7 changed files with 123 additions and 65 deletions

View File

@@ -1,39 +0,0 @@
import { getFromCMS } from 'utils/utils.js';
const homepageQuery = `*[_type == "homepage"]{
"description": description[],
"councilPhoto": councilPhoto.asset->url,
"faqs": faqs[]{ question, answer },
}[0]`;
const ohQuery = `*[_type=="oh"].schedule[]{
day,
startTime,
endTime,
"host": member->name
}`;
export const load = async () => {
/**
* @description Response data type based on the `homepageQuery` above.
* Note that `description` is a rich/portable text type
*
* @type {{
* description: import('@portabletext/svelte').InputValue,
* councilPhoto: string,
* faqs: [{
* question: string,
* answer: string
* }],
* }}
*
*/
let CMSresponse = await getFromCMS(homepageQuery);
return {
description: CMSresponse.description,
councilPhoto: CMSresponse.councilPhoto,
faqs: CMSresponse.faqs
// ohs: await getFromCMS(ohQuery),
};
};

View File

@@ -0,0 +1,34 @@
import { getFromCMS } from 'utils/utils.js';
import type { HomepageCMSResponse, OhCMSResponse } from '$lib/schemas';
const homepageQuery = `*[_type == "homepage"]{
"description": description[],
"councilPhoto": councilPhoto.asset->url,
"faqs": faqs[]{ question, answer },
}[0]`;
const ohQuery = `*[_type=="officeHours"]{
day,
startTime,
endTime,
"host": {
"name": member->name,
"position": member->position
}
}`;
export const load = async () => {
/**
* @description Response data type based on the `homepageQuery` above.
* Note that `description` is a rich/portable text type
*/
let homepageResp: HomepageCMSResponse = await getFromCMS(homepageQuery);
let officeHourResp: OhCMSResponse = await getFromCMS(ohQuery);
return {
description: homepageResp.description,
councilPhoto: homepageResp.councilPhoto,
faqs: homepageResp.faqs,
allOHs: officeHourResp
};
};

View File

@@ -2,6 +2,7 @@
import FaqAccordion from 'components/FAQAccordion.svelte';
import Section from 'components/Section.svelte';
import { PortableText } from '@portabletext/svelte';
import OhSchedule from 'components/OHSchedule.svelte';
/** loading things from the server side */
let { data } = $props();
@@ -34,6 +35,6 @@
<Section>
<div>
<h1 class="text-2xl">Office Hours</h1>
<p>Under development</p>
<OhSchedule allOhs={data.allOHs}/>
</div>
</Section>