Clean data and update mockup api spec
This commit is contained in:
parent
aaff6c92b8
commit
9012d03515
13 changed files with 171 additions and 77 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue