diff --git a/cms/src/routes/competitive/[id]/+page.server.ts b/cms/src/routes/competitive/[id]/+page.server.ts
index 778712e..0e6601f 100644
--- a/cms/src/routes/competitive/[id]/+page.server.ts
+++ b/cms/src/routes/competitive/[id]/+page.server.ts
@@ -1,9 +1,10 @@
+import {apibase} from '$lib/data/CMSDataType'
import { error } from '@sveltejs/kit'
import dayjs from 'dayjs'
import type { PageServerLoad } from './$types'
export const load: PageServerLoad = async ({params,fetch}) => {
const id = params.id+""
- const res = await fetch("/api/competitive/"+id)
+ const res = await fetch(apibase+"/competitive/"+id)
if(res.status==404){
throw error(404,{message:`ค้นหาข้อมูลสอบคัดเลือก ${id}ไม่พบ`})
}
diff --git a/cms/src/routes/qualifying/+page.server.ts b/cms/src/routes/qualifying/+page.server.ts
index ed0f363..a985fe8 100644
--- a/cms/src/routes/qualifying/+page.server.ts
+++ b/cms/src/routes/qualifying/+page.server.ts
@@ -1,31 +1,20 @@
-
+import {apibase} from '$lib/data/CMSDataType'
import { error } from '@sveltejs/kit';
import type {CalendarEvent,Exam} from '$lib/data/CMSDataType'
import dayjs from 'dayjs'
import type { PageServerLoad } from './$types'
export const load: PageServerLoad = async ({fetch}) => {
- let content = ""
let exams:Exam[] = []
- let res = await fetch("/api/content?page=qualifying")
- if(res.ok){
- content = (await res.json()).content
- }
- res = await fetch("/api/qualifying")
- if(!res.ok){
+ const res = await fetch(apibase+"/qualifying")
+ 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 = e.start? dayjs(e.start).format("DD MMM BBBB"):""
- const {id,title,start,end,category_id} = e
- let backgroundColor =""
- switch (category_id) {
+ exams.forEach((ex)=>{
+ const {id,title,start,end,category_id} = ex
+ let backgroundColor ="#23ccef"
+ switch (String(category_id)) {
case "1":
backgroundColor="rgba(251,64,75,.2)"
break;
@@ -39,15 +28,18 @@ export const load: PageServerLoad = async ({fetch}) => {
break;
}
const url = "/qualifying/"+id
- events.push({id,title,start,end,url,backgroundColor})
- if(e.exam_date){
- events.push({id,"title":"สอบ","start":e.exam_date,url,backgroundColor})
+ if(start){
+ ex.date = dayjs(start).format("DD MMM BBBB")
+ events.push({id,title,start,end,url,backgroundColor})
}
- if(e.announcement_date){
- events.push({id,"title":"ผลสอบสอบ","start":e.announcement_date,url,backgroundColor})
+ if(ex.exam_date){
+ events.push({id,"title":"วันสอบคัดเลือก","start":ex.exam_date,url,backgroundColor})
+ }
+ if(ex.announcement_date){
+ events.push({id,"title":"ผลสอบคัดเลือก","start":ex.announcement_date,url,backgroundColor})
}
})
- return {exams,events,content}
+ return {exams,events}
}
diff --git a/cms/src/routes/qualifying/+page.svelte b/cms/src/routes/qualifying/+page.svelte
index 97eb40e..14a6029 100644
--- a/cms/src/routes/qualifying/+page.svelte
+++ b/cms/src/routes/qualifying/+page.svelte
@@ -2,8 +2,7 @@
import ActivityCalendar from '$lib/components/ActivityCalendar.svelte'
import type { PageData } from './$types'
export let data: PageData;
- const exams = data.exams
- const events = data.events
+ const {exams,events} = data
@@ -63,9 +62,13 @@
{#each exams as exam}
- | {exam.date} |
+
+
+ {exam.date??""}
+
+ |
{exam.title} |
- {exam.category} |
+ {exam.category??""} |
{/each}
diff --git a/cms/src/routes/qualifying/[id]/+page.server.ts b/cms/src/routes/qualifying/[id]/+page.server.ts
index f25cfaf..fbd9445 100644
--- a/cms/src/routes/qualifying/[id]/+page.server.ts
+++ b/cms/src/routes/qualifying/[id]/+page.server.ts
@@ -1,10 +1,10 @@
-//import type {Exam} from '$lib/data/CMSDataType'
+import {apibase} from '$lib/data/CMSDataType'
import { error } from '@sveltejs/kit'
import dayjs from 'dayjs'
import type { PageServerLoad } from './$types'
export const load: PageServerLoad = async ({params,fetch}) => {
const id = params.id+""
- const res = await fetch("/api/qualifying/"+id)
+ const res = await fetch(apibase+"/qualifying/"+id)
if(res.status==404){
throw error(404,{message:`ค้นหาข้อมูลสอบคัดเลือก ${id}ไม่พบ`})
}
diff --git a/cms/src/routes/qualifying/[id]/+page.svelte b/cms/src/routes/qualifying/[id]/+page.svelte
index 266b20f..699cc18 100644
--- a/cms/src/routes/qualifying/[id]/+page.svelte
+++ b/cms/src/routes/qualifying/[id]/+page.svelte
@@ -18,7 +18,7 @@
- ประกาศเกี่ยวกับการคัดเลือกบุคลากรกทม.
+ ประกาศเกี่ยวกับการคัดเลือกบุคลากรของกทม.