Checkpoint for implementing OH Schedule
This commit is contained in:
@@ -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),
|
||||
};
|
||||
};
|
||||
34
src/routes/+page.server.ts
Normal file
34
src/routes/+page.server.ts
Normal 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
|
||||
};
|
||||
};
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user