hrms-exam/cms/src/routes/competitive/+page.server.ts

25 lines
737 B
TypeScript
Raw Normal View History

2023-04-04 12:39:11 +07:00
import type { PageServerLoad } from './$types'
2023-04-05 17:59:43 +07:00
import type {CalendarEvent} from '$lib/components/CalendarEvent'
import type {Exam} from '$lib/components/Exam'
export const load: PageServerLoad = async ({fetch}) => {
let content = ""
let exams:Exam[] = []
let res = await fetch("/api/content?page=competitive")
if(res.ok){
content = (await res.json()).content
}
res = await fetch("/api/competitive")
if(res.ok){
exams = await res.json()
}
2023-04-05 17:59:43 +07:00
const events:CalendarEvent[]=[]
exams.forEach(({id,title,start})=>{
2023-04-06 10:46:37 +07:00
const backgroundColor ="#9999FF"
2023-04-05 17:59:43 +07:00
const url = "/competitive/"+id
events.push({id,title,start,url,backgroundColor})
})
2023-04-05 19:35:08 +07:00
return {content,exams,events}
2023-04-06 10:46:37 +07:00
}