Clean data and update mockup api spec

This commit is contained in:
schooltechx 2023-04-08 11:27:09 +07:00
parent aaff6c92b8
commit 9012d03515
13 changed files with 171 additions and 77 deletions

View file

@ -1,4 +1,5 @@
import { error } from '@sveltejs/kit';
import type {CalendarEvent,Exam} from '$lib/data/CMSDataType'
import dayjs from 'dayjs'
import type { PageServerLoad } from './$types'
@ -10,16 +11,18 @@ export const load: PageServerLoad = async ({fetch}) => {
content = (await res.json()).content
}
res = await fetch("/api/qualifying")
if(res.ok){
exams = await res.json()
if(!res.ok){
throw error(res.status, 'ไม่สามารถอ่านข้อมูลการสอบได้');
}
exams = await res.json()
const events:CalendarEvent[]=[]
exams.forEach((e)=>{
if(!e.start){
e.date=""
return
}
e.date= dayjs(e.start).format("DD MMM BBBB")
e.date = e.start? dayjs(e.start).format("DD MMM BBBB"):""
const {id,title,start,end,category_id} = e
let backgroundColor =""
switch (category_id) {