Update for supported new date field

This commit is contained in:
schooltechx 2023-04-12 16:41:55 +07:00
parent 1b1c37510b
commit f8254e92c9
13 changed files with 135 additions and 178 deletions

View file

@ -13,32 +13,26 @@ export const load: PageServerLoad = async ({fetch}) => {
const events:CalendarEvent[]=[]
exams.forEach((ex)=>{
const {id,category,start} = ex
const {id,title,category,announcement_startDate} = ex
const backgroundColor = category? getBgColorDict(category,catColor):"n/a"
const url = "/qualifying/"+id
if(start){
ex.date = dayjs(start).format("DD MMM BBBB")
}
ex.date = dayjs(announcement_startDate).format("DD MMM BBBB")
if(!ex.announcementExam)
return
if(ex.exam_date){
const start = ex.exam_date
events.push({id,"title":"วันสอบคัดเลือก",start,url,backgroundColor})
}
if(ex.announcement_date){
const start = ex.announcement_date
const end = ex.announcement_endDate
events.push({id,"title":"ผลสอบคัดเลือก",start,end,url,backgroundColor})
}
return //ignore other date for normal post
if(ex.register_startDate){
const start = ex.register_startDate
const end = ex.register_endDate
events.push({id,"title":"ผลสอบคัดเลือก",start,end,url,backgroundColor})
events.push({id,"title":"สมัคร:"+title,start,end,url,backgroundColor})
}
if(ex.payment_startDate){
const start = ex.payment_startDate
const end = ex.payment_endDate
events.push({id,"title":"ผลสอบคัดเลือก",start,end,url,backgroundColor})
events.push({id,"title":"ชำระเงิน:"+title,start,end,url,backgroundColor})
}
if(ex.examDate){
const start = ex.examDate
events.push({id,"title":"วันสอบ:"+title,start,url,backgroundColor})
}
})
return {exams,events}

View file

@ -13,7 +13,7 @@ export const load: PageServerLoad = async ({params,fetch}) => {
throw error(500,{message:`พบข้อผิดพลาดเกี่ยวกับข้อมูลสอบคัดเลือก ${id}`})
}
const post:Exam = await res.json()
post.date= post.start? dayjs(post.start).format("DD MMM BBBB"):""
post.date=dayjs(post.announcement_startDate).format("DD MMM BBBB")
return post
}