แก้ให้สีของ event calendar จากเดิมใช้ category ไปเป็น
This commit is contained in:
parent
daa8263c0c
commit
c4ca7ad81c
3 changed files with 12 additions and 18 deletions
|
|
@ -1,7 +1,6 @@
|
|||
import { env } from '$env/dynamic/private'
|
||||
import { error } from '@sveltejs/kit';
|
||||
import type {CalendarEvent,Exam} from '$lib/data/CMSDataType'
|
||||
import {getBgColorDict} from '$lib/utils'
|
||||
import dayjs from 'dayjs'
|
||||
import type { PageServerLoad } from './$types'
|
||||
export const load: PageServerLoad = async ({fetch}) => {
|
||||
|
|
@ -9,12 +8,10 @@ export const load: PageServerLoad = async ({fetch}) => {
|
|||
if(!res.ok)
|
||||
throw error(res.status, 'ไม่สามารถอ่านข้อมูลการสอบได้');
|
||||
const exams:Exam[] = await res.json()
|
||||
const catColor = {};
|
||||
const events:CalendarEvent[]=[]
|
||||
|
||||
exams.forEach((ex)=>{
|
||||
const {id,title,category,announcement_startDate} = ex
|
||||
const backgroundColor = category? getBgColorDict(category,catColor):"n/a"
|
||||
const {id,title,announcement_startDate} = ex
|
||||
const url = "/qualifying/"+id
|
||||
ex.date = dayjs(announcement_startDate).format("DD MMM BBBB")
|
||||
ex.image = ex.image?ex.image:"/images/exam_place_holder.png"
|
||||
|
|
@ -24,16 +21,16 @@ export const load: PageServerLoad = async ({fetch}) => {
|
|||
if(ex.register_startDate){
|
||||
const start = ex.register_startDate
|
||||
const end = ex.register_endDate
|
||||
events.push({id,"title":"สมัคร:"+title,start,end,url,backgroundColor})
|
||||
events.push({id,"title":"สมัคร:"+title,start,end,url,backgroundColor:'#67a1ff4a'})
|
||||
}
|
||||
if(ex.payment_startDate){
|
||||
const start = ex.payment_startDate
|
||||
const end = ex.payment_endDate
|
||||
events.push({id,"title":"ชำระเงิน:"+title,start,end,url,backgroundColor})
|
||||
events.push({id,"title":"ชำระเงิน:"+title,start,end,url,backgroundColor:'#D2B4DE'})
|
||||
}
|
||||
if(ex.examDate){
|
||||
const start = ex.examDate
|
||||
events.push({id,"title":"วันสอบ:"+title,start,url,backgroundColor})
|
||||
events.push({id,"title":"วันสอบ:"+title,start,url,backgroundColor:'#a2d9ce8f'})
|
||||
}
|
||||
})
|
||||
return {exams,events}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import { env } from '$env/dynamic/private'
|
||||
import { error } from '@sveltejs/kit';
|
||||
import type {CalendarEvent,Exam} from '$lib/data/CMSDataType'
|
||||
import {getBgColorDict} from '$lib/utils'
|
||||
import dayjs from 'dayjs'
|
||||
import type { PageServerLoad } from './$types'
|
||||
export const load: PageServerLoad = async ({fetch}) => {
|
||||
|
|
@ -9,12 +8,10 @@ export const load: PageServerLoad = async ({fetch}) => {
|
|||
if(!res.ok)
|
||||
throw error(res.status, 'ไม่สามารถอ่านข้อมูลการสอบได้');
|
||||
const exams:Exam[] = await res.json()
|
||||
const catColor = {};
|
||||
const events:CalendarEvent[]=[]
|
||||
|
||||
exams.forEach((ex)=>{
|
||||
const {id,title,category,announcement_startDate} = ex
|
||||
const backgroundColor = category? getBgColorDict(category,catColor):"n/a"
|
||||
const {id,title,announcement_startDate} = ex
|
||||
const url = "/qualifying/"+id
|
||||
ex.date = dayjs(announcement_startDate).format("DD MMM BBBB")
|
||||
ex.image = ex.image?ex.image:"/images/exam_place_holder.png"
|
||||
|
|
@ -24,16 +21,16 @@ export const load: PageServerLoad = async ({fetch}) => {
|
|||
if(ex.register_startDate){
|
||||
const start = ex.register_startDate
|
||||
const end = ex.register_endDate
|
||||
events.push({id,"title":"สมัคร:"+title,start,end,url,backgroundColor})
|
||||
events.push({id,"title":"สมัคร:"+title,start,end,url, backgroundColor:'#67a1ff4a'})
|
||||
}
|
||||
if(ex.payment_startDate){
|
||||
const start = ex.payment_startDate
|
||||
const end = ex.payment_endDate
|
||||
events.push({id,"title":"ชำระเงิน:"+title,start,end,url,backgroundColor})
|
||||
events.push({id,"title":"ชำระเงิน:"+title,start,end,url,backgroundColor:'#D2B4DE'})
|
||||
}
|
||||
if(ex.examDate){
|
||||
const start = ex.examDate
|
||||
events.push({id,"title":"วันสอบ:"+title,start,url,backgroundColor})
|
||||
events.push({id,"title":"วันสอบ:"+title,start,url,backgroundColor:'#a2d9ce8f'})
|
||||
}
|
||||
})
|
||||
return {exams,events}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue