Update for supported new date field
This commit is contained in:
parent
1b1c37510b
commit
f8254e92c9
13 changed files with 135 additions and 178 deletions
|
|
@ -34,7 +34,7 @@ export const load: PageServerLoad = async ({fetch}) => {
|
|||
}
|
||||
const exams:Exam[] = await res.json()
|
||||
exams.forEach((e)=>{
|
||||
e.date = e.start? dayjs(e.start).format("DD MMM BBBB"):""
|
||||
e.date = dayjs(e.announcement_startDate).format("DD MMM BBBB")
|
||||
e.image = e.image?e.image:"/images/exam_place_holder.png"
|
||||
})
|
||||
//This page layout require 3 item, patch with empty
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import type { RequestEvent,RequestHandler } from './$types'
|
|||
export const GET: RequestHandler = async ({url}: RequestEvent) => {
|
||||
const limit= Number(url.searchParams.get("limit"))
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
let ex:Exam[] = exams.map(({files,images,detail,...minimal})=>{
|
||||
let ex:Exam[] = exams.map(({files,images,positions,detail,...minimal})=>{
|
||||
if(images && images[0]){
|
||||
const image = images[0].url
|
||||
return {...minimal,image}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import type { RequestEvent,RequestHandler } from './$types'
|
|||
export const GET: RequestHandler = async ({url}: RequestEvent) => {
|
||||
const limit= Number(url.searchParams.get("limit"))
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
let ex:Exam[] = exams.map(({files,images,detail,...minimal})=>{
|
||||
let ex:Exam[] = exams.map(({files,images,positions,detail,...minimal})=>{
|
||||
if(images && images[0]){
|
||||
const image = images[0].url
|
||||
return {...minimal,image}
|
||||
|
|
|
|||
|
|
@ -8,27 +8,32 @@ export const load: PageServerLoad = async ({fetch}) => {
|
|||
const res = await fetch(env.API_COMPETITIVE_URL+"/competitive")
|
||||
if(!res.ok)
|
||||
throw error(res.status, 'ไม่สามารถอ่านข้อมูลการสอบได้');
|
||||
|
||||
const exams:Exam[] = await res.json()
|
||||
const events:CalendarEvent[]=[]
|
||||
const catColor = {};
|
||||
const events:CalendarEvent[]=[]
|
||||
|
||||
exams.forEach((ex)=>{
|
||||
const {id,title,start,end,category} = ex
|
||||
if(!category)
|
||||
return
|
||||
const backgroundColor = getBgColorDict(category,catColor)
|
||||
const url = "/competitive/"+id
|
||||
if(start){
|
||||
ex.date = dayjs(start).format("DD MMM BBBB")
|
||||
events.push({id,title,start,end,url,backgroundColor})
|
||||
const {id,title,category,announcement_startDate} = ex
|
||||
const backgroundColor = category? getBgColorDict(category,catColor):"n/a"
|
||||
const url = "/qualifying/"+id
|
||||
ex.date = dayjs(announcement_startDate).format("DD MMM BBBB")
|
||||
if(!ex.announcementExam)
|
||||
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":"สมัคร:"+title,start,end,url,backgroundColor})
|
||||
}
|
||||
if(ex.exam_date){
|
||||
events.push({id,"title":"วันสอบแข่งขัน","start":ex.exam_date,url,backgroundColor})
|
||||
if(ex.payment_startDate){
|
||||
const start = ex.payment_startDate
|
||||
const end = ex.payment_endDate
|
||||
events.push({id,"title":"ชำระเงิน:"+title,start,end,url,backgroundColor})
|
||||
}
|
||||
if(ex.announcement_date){
|
||||
events.push({id,"title":"ผลสอบแข่งขัน","start":ex.announcement_date,url,backgroundColor})
|
||||
if(ex.examDate){
|
||||
const start = ex.examDate
|
||||
events.push({id,"title":"วันสอบ:"+title,start,url,backgroundColor})
|
||||
}
|
||||
})
|
||||
return {exams,events}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue