Optimize code, rebase api path, fix typo
This commit is contained in:
parent
16917a088f
commit
d101d81763
13 changed files with 111 additions and 100 deletions
|
|
@ -30,3 +30,4 @@ export interface CMSInfo{
|
||||||
divisions:{title:string,url:string}[];
|
divisions:{title:string,url:string}[];
|
||||||
institutes:{title:string,url:string}[];
|
institutes:{title:string,url:string}[];
|
||||||
}
|
}
|
||||||
|
export const apibase="/api"
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
"start":"2023-04-24",
|
"start":"2023-04-24",
|
||||||
"detail":"<p><b>ประกาศรายชื่อผู้ผ่านภาค</b> ข. และมีสิทธิสอบภาค ค. ในการคัดเลือกคนพิการ ครั้งที่ 1/2565</p> <p> <img src='https://webportal.bangkok.go.th/public/user_files_editor/305/%E0%B8%9B%E0%B8%8F%E0%B8%B4%E0%B8%97%E0%B8%B4%E0%B8%99%E0%B8%A7%E0%B8%B1%E0%B8%99%E0%B8%A0%E0%B8%B2%E0%B8%84%E0%B8%84.%E0%B8%84%E0%B8%99%E0%B8%9E%E0%B8%B4%E0%B8%81%E0%B8%B2%E0%B8%A3.jpg'> </p>",
|
"detail":"<p><b>ประกาศรายชื่อผู้ผ่านภาค</b> ข. และมีสิทธิสอบภาค ค. ในการคัดเลือกคนพิการ ครั้งที่ 1/2565</p> <p> <img src='https://webportal.bangkok.go.th/public/user_files_editor/305/%E0%B8%9B%E0%B8%8F%E0%B8%B4%E0%B8%97%E0%B8%B4%E0%B8%99%E0%B8%A7%E0%B8%B1%E0%B8%99%E0%B8%A0%E0%B8%B2%E0%B8%84%E0%B8%84.%E0%B8%84%E0%B8%99%E0%B8%9E%E0%B8%B4%E0%B8%81%E0%B8%B2%E0%B8%A3.jpg'> </p>",
|
||||||
"title":"ประกาศรายชื่อผู้ผ่านภาค ข. และมีสิทธิสอบภาค ค. ในการคัดเลือกคนพิการ ครั้งที่ 1/2565",
|
"title":"ประกาศรายชื่อผู้ผ่านภาค ข. และมีสิทธิสอบภาค ค. ในการคัดเลือกคนพิการ ครั้งที่ 1/2565",
|
||||||
|
"category":"สำนักงาน ก.ก.","category_id":1,
|
||||||
"images":[
|
"images":[
|
||||||
{
|
{
|
||||||
"title":"topic",
|
"title":"topic",
|
||||||
|
|
@ -50,6 +51,7 @@
|
||||||
"start":"2023-04-20T09:00:00",
|
"start":"2023-04-20T09:00:00",
|
||||||
"detail":"ใครลืมส่งเอกสาร !! สำหรับการคัดเลือกคนพิการฯ ครั้งที่ 1/2565 ส่งเอกสารเพิ่มได้",
|
"detail":"ใครลืมส่งเอกสาร !! สำหรับการคัดเลือกคนพิการฯ ครั้งที่ 1/2565 ส่งเอกสารเพิ่มได้",
|
||||||
"title":"ใครลืมส่งเอกสาร !! สำหรับการคัดเลือกคนพิการฯ ครั้งที่ 1/2565 ส่งเอกสารเพิ่มได้",
|
"title":"ใครลืมส่งเอกสาร !! สำหรับการคัดเลือกคนพิการฯ ครั้งที่ 1/2565 ส่งเอกสารเพิ่มได้",
|
||||||
|
"category":"สำนักงาน ก.ก.","category_id":1,
|
||||||
"images":[
|
"images":[
|
||||||
{
|
{
|
||||||
"title":"topic",
|
"title":"topic",
|
||||||
|
|
@ -62,6 +64,7 @@
|
||||||
"start":"2023-03-28T09:00:00",
|
"start":"2023-03-28T09:00:00",
|
||||||
"detail":"แผนที่การเดินทางมาสนามสอบคนพิการฯ ครั้งที่ 1/2565",
|
"detail":"แผนที่การเดินทางมาสนามสอบคนพิการฯ ครั้งที่ 1/2565",
|
||||||
"title":"แผนที่การเดินทางมาสนามสอบคนพิการฯ ครั้งที่ 1/2565",
|
"title":"แผนที่การเดินทางมาสนามสอบคนพิการฯ ครั้งที่ 1/2565",
|
||||||
|
"category":"ประกาศทั่วไป","category_id":2,
|
||||||
"images":[
|
"images":[
|
||||||
{
|
{
|
||||||
"title":"topic",
|
"title":"topic",
|
||||||
|
|
@ -74,6 +77,7 @@
|
||||||
"start":"2023-03-28T09:00:00",
|
"start":"2023-03-28T09:00:00",
|
||||||
"detail":"การสอบแข่งขันเพื่อรรจุและแต่งตั้งบุคคลเข้ารับราชการเป็นข้าราชการกรุงเทพมหานครสามัญ ครั้งที่ 2/2566",
|
"detail":"การสอบแข่งขันเพื่อรรจุและแต่งตั้งบุคคลเข้ารับราชการเป็นข้าราชการกรุงเทพมหานครสามัญ ครั้งที่ 2/2566",
|
||||||
"title":"การสอบแข่งขันเพื่อรรจุและแต่งตั้งบุคคลเข้ารับราชการเป็นข้าราชการกรุงเทพมหานครสามัญ ครั้งที่ 2/2566",
|
"title":"การสอบแข่งขันเพื่อรรจุและแต่งตั้งบุคคลเข้ารับราชการเป็นข้าราชการกรุงเทพมหานครสามัญ ครั้งที่ 2/2566",
|
||||||
|
"category":"สำนักงาน ก.ก.","category_id":1,
|
||||||
"images":[
|
"images":[
|
||||||
{
|
{
|
||||||
"title":"topic",
|
"title":"topic",
|
||||||
|
|
@ -86,6 +90,7 @@
|
||||||
"start":"2023-03-10T09:00:00",
|
"start":"2023-03-10T09:00:00",
|
||||||
"detail":"การสอบแข่งขันเพื่อรรจุและแต่งตั้งบุคคลเข้ารับราชการเป็นข้าราชการกรุงเทพมหานครสามัญ ครั้งที่ 1/2565",
|
"detail":"การสอบแข่งขันเพื่อรรจุและแต่งตั้งบุคคลเข้ารับราชการเป็นข้าราชการกรุงเทพมหานครสามัญ ครั้งที่ 1/2565",
|
||||||
"title":"การสอบแข่งขันเพื่อรรจุและแต่งตั้งบุคคลเข้ารับราชการเป็นข้าราชการกรุงเทพมหานครสามัญ ครั้งที่ 1/2565",
|
"title":"การสอบแข่งขันเพื่อรรจุและแต่งตั้งบุคคลเข้ารับราชการเป็นข้าราชการกรุงเทพมหานครสามัญ ครั้งที่ 1/2565",
|
||||||
|
"category":"สำนักงาน ก.ก.","category_id":1,
|
||||||
"images":[
|
"images":[
|
||||||
{
|
{
|
||||||
"title":"topic",
|
"title":"topic",
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"id":"21",
|
"id":"21",
|
||||||
"catetory":"สำนักงาน ก.ก.","catetory_id":1,
|
"category":"สำนักงาน ก.ก.","category_id":1,
|
||||||
"start":"2023-04-24",
|
"start":"2023-04-24",
|
||||||
"title":"ด่วน !! ประกาศวัน เวลา สถานที่ และระเบียบการคัดเลือกลูกจ้างกทม.",
|
"title":"ด่วน !! ประกาศวัน เวลา สถานที่ และระเบียบการคัดเลือกลูกจ้างกทม.",
|
||||||
"detail":"<p><center><img src='https://webportal.bangkok.go.th/public/user_files_editor/305/bkkgovjob202303_12.jpg'></center></p><br/><center><h2>สำนักงานคณะกรรมการข้าราชการกรุงเทพมหานคร ประกาศกำหนดวัน เวลา สถานที่คัดเลือก และระเบียบ เกี่ยวกับการคัดเลือกบุคลากรกรุงเทพมหานครหรือผู้ปฏิบัติงานอื่นในกรุงเทพมหานครเพื่อบรรจุและแต่งตั้ง เป็นข้าราชการกรุงเทพมหานครสามัญ ครั้งที่ 1 / 2565</h2></center>",
|
"detail":"<p><center><img src='https://webportal.bangkok.go.th/public/user_files_editor/305/bkkgovjob202303_12.jpg'></center></p><br/><center><h2>สำนักงานคณะกรรมการข้าราชการกรุงเทพมหานคร ประกาศกำหนดวัน เวลา สถานที่คัดเลือก และระเบียบ เกี่ยวกับการคัดเลือกบุคลากรกรุงเทพมหานครหรือผู้ปฏิบัติงานอื่นในกรุงเทพมหานครเพื่อบรรจุและแต่งตั้ง เป็นข้าราชการกรุงเทพมหานครสามัญ ครั้งที่ 1 / 2565</h2></center>",
|
||||||
|
|
@ -42,7 +42,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id":"20",
|
"id":"20",
|
||||||
"catetory":"สำนักงาน ก.ก.","catetory_id":1,
|
"category":"สำนักงาน ก.ก.","category_id":1,
|
||||||
"start":"2023-04-03",
|
"start":"2023-04-03",
|
||||||
"title":"วัน เวลา สถานที่ และระเบียบการคัดเลือกลูกจ้างกทม.",
|
"title":"วัน เวลา สถานที่ และระเบียบการคัดเลือกลูกจ้างกทม.",
|
||||||
"detail":"ด่วน !! ประกาศวัน เวลา สถานที่ และระเบียบการคัดเลือกลูกจ้างกทม.",
|
"detail":"ด่วน !! ประกาศวัน เวลา สถานที่ และระเบียบการคัดเลือกลูกจ้างกทม.",
|
||||||
|
|
@ -55,10 +55,13 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id":"19",
|
"id":"19",
|
||||||
"catetory":"สำนักการแพทย์","catetory_id":3,
|
"category":"สำนักการแพทย์","category_id":3,
|
||||||
"start":"2003-12-20",
|
"start":"2023-04-01",
|
||||||
"title":"ประกาศรับสมัครคัดเลือกบุคลากรกทม. !!",
|
"end":"2023-04-02",
|
||||||
"detail":"ประกาศรับสมัครคัดเลือกบุคลากรกทม. !!",
|
"exam_date":"2023-04-12T09:00:00",
|
||||||
|
"announcement_date":"2023-04-08",
|
||||||
|
"title":"ประกาศรับสมัครคัดเลือกบุคลากรทางการแพทย์กทม. !!",
|
||||||
|
"detail":"ประกาศรับสมัครคัดเลือกบุคลากรทางการแพทย์กทม. !!",
|
||||||
"images":[
|
"images":[
|
||||||
{
|
{
|
||||||
"title":"topic",
|
"title":"topic",
|
||||||
|
|
@ -69,7 +72,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id":"18",
|
"id":"18",
|
||||||
"catetory":"สำนักอนามัย","catetory_id":2,
|
"category":"สำนักอนามัย","category_id":2,
|
||||||
"start":"2023-11-05T09:00:00",
|
"start":"2023-11-05T09:00:00",
|
||||||
"title":"สอบครั้งที่ 1/2565",
|
"title":"สอบครั้งที่ 1/2565",
|
||||||
"detail":"สอบเป็นลูกจ้างและผู้ปฎิบัติงานในกรุงเทพมหานคร เป็นข้าราชการกรุงเทพมหานคร",
|
"detail":"สอบเป็นลูกจ้างและผู้ปฎิบัติงานในกรุงเทพมหานคร เป็นข้าราชการกรุงเทพมหานคร",
|
||||||
|
|
@ -82,7 +85,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id":"17",
|
"id":"17",
|
||||||
"catetory":"สำนักงาน ก.ก.","catetory_id":1,
|
"category":"สำนักงาน ก.ก.","category_id":1,
|
||||||
"start":"2023-11-01",
|
"start":"2023-11-01",
|
||||||
"title":"รับสมัครสอบตำแหน่งลูกจ้างและผู้ปฎิบัติงาน 1/2565",
|
"title":"รับสมัครสอบตำแหน่งลูกจ้างและผู้ปฎิบัติงาน 1/2565",
|
||||||
"detail":"รับสมัครสอบตำแหน่ง ลูกจ้างและผู้ปฎิบัติงานในกรุงเทพมหานคร เป็นข้าราชการกรุงเทพมหานคร",
|
"detail":"รับสมัครสอบตำแหน่ง ลูกจ้างและผู้ปฎิบัติงานในกรุงเทพมหานคร เป็นข้าราชการกรุงเทพมหานคร",
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
|
import {apibase} from '$lib/data/CMSDataType'
|
||||||
import { error } from '@sveltejs/kit';
|
import { error } from '@sveltejs/kit';
|
||||||
import type { PageServerLoad } from './$types'
|
import type { PageServerLoad } from './$types'
|
||||||
export const load: PageServerLoad = async ({fetch}) => {
|
export const load: PageServerLoad = async ({fetch}) => {
|
||||||
const res = await fetch("/api/info")
|
const res = await fetch(apibase+"/info")
|
||||||
if(!res.ok)
|
if(!res.ok)
|
||||||
throw error(500, 'ไม่สามารถอ่านข้อมูลตั้งต้นของเวปได้');
|
throw error(500, 'ไม่สามารถอ่านข้อมูลตั้งต้นของเวปได้');
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,40 +1,36 @@
|
||||||
|
import {apibase} from '$lib/data/CMSDataType'
|
||||||
import { error } from '@sveltejs/kit';
|
import { error } from '@sveltejs/kit';
|
||||||
import type { PageServerLoad } from './$types';
|
import type { PageServerLoad } from './$types';
|
||||||
import type {Exam} from '$lib/data/CMSDataType'
|
import type {Exam} from '$lib/data/CMSDataType'
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
|
|
||||||
|
|
||||||
export const load: PageServerLoad = async ({fetch}) => {
|
export const load: PageServerLoad = async ({fetch}) => {
|
||||||
let qualify_exams: Exam[] = []
|
let res = await fetch(apibase+"/info")
|
||||||
let competitive_exams: Exam[] = []
|
|
||||||
let content = ""
|
|
||||||
let image = undefined
|
|
||||||
let res = await fetch("/api/info")
|
|
||||||
if(!res.ok)
|
if(!res.ok)
|
||||||
throw error(500, 'ไม่สามารถอ่านข้อมูลตั้งต้นของหน้าหลักได้');
|
throw error(500, 'ไม่สามารถอ่านข้อมูลตั้งต้นของหน้าหลักได้');
|
||||||
const {title,subtitle} = await res.json()
|
const {title,subtitle} = await res.json()
|
||||||
res = await fetch("/api/content?page=home")
|
|
||||||
if(res.ok){
|
res = await fetch(apibase+"/content?page=home")
|
||||||
const r = await res.json()
|
if(!res.ok)
|
||||||
content = r.content
|
throw error(500, 'ไม่สามารถอ่านเนื้อหาหน้าหลักได้');
|
||||||
image = r.image
|
const {content,image} = await res.json()
|
||||||
}
|
//Inner function reduce code and able to throw here
|
||||||
res = await fetch("/api/qualifying")
|
async function loadExam(api_path:string,err_msg:string){
|
||||||
if(res.ok){
|
const res = await fetch(api_path)
|
||||||
qualify_exams = await res.json()
|
if(!res.ok)
|
||||||
qualify_exams.forEach((e)=>{
|
throw error(500, err_msg);
|
||||||
|
const exams:Exam[] = await res.json()
|
||||||
|
exams.forEach((e)=>{
|
||||||
e.date = e.start? dayjs(e.start).format("DD MMM BBBB"):""
|
e.date = e.start? dayjs(e.start).format("DD MMM BBBB"):""
|
||||||
})
|
})
|
||||||
for(let i=qualify_exams.length;i<3;i++){
|
//This page layout require 3 item, patch with empty
|
||||||
qualify_exams.push({id:"0",title:"",date:"",image:""})
|
for(let i=exams.length;i<3;i++){
|
||||||
|
exams.push({id:"0",title:"",date:"",image:""})
|
||||||
}
|
}
|
||||||
|
return exams
|
||||||
|
|
||||||
}
|
}
|
||||||
res = await fetch("/api/competitive")
|
const qualify_exams = loadExam(apibase+"/qualifying",'ไม่สามารถอ่านรายการสอบคัดเลือกได้')
|
||||||
if(res.ok){
|
const competitive_exams = loadExam(apibase+"/competitive",'ไม่สามารถอ่านรายการสอบแข่งขันได้')
|
||||||
competitive_exams = await res.json()
|
|
||||||
competitive_exams.forEach((e)=>{
|
return {title,subtitle,content,image, qualify_exams,competitive_exams };
|
||||||
e.date = e.start? dayjs(e.start).format("DD MMM BBBB"):""
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return {title,subtitle,content,image, qualify_exams,competitive_exams };
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,10 @@
|
||||||
import content from "$lib/data/content/about.html?raw"
|
import {apibase} from '$lib/data/CMSDataType'
|
||||||
import type { PageServerLoad } from './$types';
|
import type { PageServerLoad } from './$types';
|
||||||
export const load = (async () => {
|
import { error } from '@sveltejs/kit';
|
||||||
|
export const load = (async ({fetch}) => {
|
||||||
|
const res = await fetch(apibase+"/content?page=about")
|
||||||
|
if(!res.ok)
|
||||||
|
throw error(500, 'ไม่สามารถอ่านเนื้อหาหน้าเกี่ยวกับได้');
|
||||||
|
const {content} = await res.json()
|
||||||
return {content};
|
return {content};
|
||||||
}) satisfies PageServerLoad;
|
}) satisfies PageServerLoad;
|
||||||
|
|
|
||||||
|
|
@ -1,37 +1,44 @@
|
||||||
|
import {apibase} from '$lib/data/CMSDataType'
|
||||||
import { error } from '@sveltejs/kit';
|
import { error } from '@sveltejs/kit';
|
||||||
import type {CalendarEvent,Exam} from '$lib/data/CMSDataType'
|
import type {CalendarEvent,Exam} from '$lib/data/CMSDataType'
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
import type { PageServerLoad } from './$types'
|
import type { PageServerLoad } from './$types'
|
||||||
export const load: PageServerLoad = async ({fetch}) => {
|
export const load: PageServerLoad = async ({fetch}) => {
|
||||||
let content = ""
|
|
||||||
let exams:Exam[] = []
|
let exams:Exam[] = []
|
||||||
let res = await fetch("/api/content?page=competitive")
|
const res = await fetch(apibase+"/competitive")
|
||||||
if(res.ok){
|
if(!res.ok)
|
||||||
content = (await res.json()).content
|
|
||||||
}
|
|
||||||
|
|
||||||
res = await fetch("/api/competitive")
|
|
||||||
if(!res.ok){
|
|
||||||
throw error(res.status, 'ไม่สามารถอ่านข้อมูลการสอบได้');
|
throw error(res.status, 'ไม่สามารถอ่านข้อมูลการสอบได้');
|
||||||
}
|
|
||||||
exams = await res.json()
|
exams = await res.json()
|
||||||
|
|
||||||
const events:CalendarEvent[]=[]
|
const events:CalendarEvent[]=[]
|
||||||
exams.forEach((e)=>{
|
exams.forEach((ex)=>{
|
||||||
if(!e.start){
|
const {id,title,start,end,category_id} = ex
|
||||||
e.date=""
|
let backgroundColor ="#23ccef"
|
||||||
return
|
switch (String(category_id)) {
|
||||||
|
case "1":
|
||||||
|
backgroundColor="rgba(251,64,75,.2)"
|
||||||
|
break;
|
||||||
|
case "2":
|
||||||
|
backgroundColor="#23ccef"
|
||||||
|
break;
|
||||||
|
case "3":
|
||||||
|
backgroundColor="rgba(68,125,247,.2)"
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
e.date= dayjs(e.start).format("DD MMM BBBB")
|
|
||||||
|
|
||||||
const {id,title,start,category_id} = e
|
|
||||||
|
|
||||||
let backgroundColor ="rgb(153 153 255 / 34%)"
|
|
||||||
if(category_id)
|
|
||||||
backgroundColor ="#99FFEE"
|
|
||||||
|
|
||||||
const url = "/competitive/"+id
|
const url = "/competitive/"+id
|
||||||
events.push({id,title,start,url,backgroundColor})
|
if(start){
|
||||||
|
ex.date = dayjs(start).format("DD MMM BBBB")
|
||||||
|
events.push({id,title,start,end,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 {content,exams,events}
|
return {exams,events}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,7 @@
|
||||||
import ActivityCalendar from '$lib/components/ActivityCalendar.svelte'
|
import ActivityCalendar from '$lib/components/ActivityCalendar.svelte'
|
||||||
import type { PageData } from './$types'
|
import type { PageData } from './$types'
|
||||||
export let data: PageData;
|
export let data: PageData;
|
||||||
const exams = data.exams
|
const {exams,events} = data
|
||||||
const events = data.events
|
|
||||||
</script>
|
</script>
|
||||||
<section>
|
<section>
|
||||||
<div class="p-one parallax-inner">
|
<div class="p-one parallax-inner">
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
|
import {apibase} from '$lib/data/CMSDataType'
|
||||||
import { error } from '@sveltejs/kit'
|
import { error } from '@sveltejs/kit'
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
import type { PageServerLoad } from './$types'
|
import type { PageServerLoad } from './$types'
|
||||||
export const load: PageServerLoad = async ({params,fetch}) => {
|
export const load: PageServerLoad = async ({params,fetch}) => {
|
||||||
const id = params.id+""
|
const id = params.id+""
|
||||||
const res = await fetch("/api/competitive/"+id)
|
const res = await fetch(apibase+"/competitive/"+id)
|
||||||
if(res.status==404){
|
if(res.status==404){
|
||||||
throw error(404,{message:`ค้นหาข้อมูลสอบคัดเลือก ${id}ไม่พบ`})
|
throw error(404,{message:`ค้นหาข้อมูลสอบคัดเลือก ${id}ไม่พบ`})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,31 +1,20 @@
|
||||||
|
import {apibase} from '$lib/data/CMSDataType'
|
||||||
import { error } from '@sveltejs/kit';
|
import { error } from '@sveltejs/kit';
|
||||||
import type {CalendarEvent,Exam} from '$lib/data/CMSDataType'
|
import type {CalendarEvent,Exam} from '$lib/data/CMSDataType'
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
import type { PageServerLoad } from './$types'
|
import type { PageServerLoad } from './$types'
|
||||||
export const load: PageServerLoad = async ({fetch}) => {
|
export const load: PageServerLoad = async ({fetch}) => {
|
||||||
let content = ""
|
|
||||||
let exams:Exam[] = []
|
let exams:Exam[] = []
|
||||||
let res = await fetch("/api/content?page=qualifying")
|
const res = await fetch(apibase+"/qualifying")
|
||||||
if(res.ok){
|
if(!res.ok)
|
||||||
content = (await res.json()).content
|
|
||||||
}
|
|
||||||
res = await fetch("/api/qualifying")
|
|
||||||
if(!res.ok){
|
|
||||||
throw error(res.status, 'ไม่สามารถอ่านข้อมูลการสอบได้');
|
throw error(res.status, 'ไม่สามารถอ่านข้อมูลการสอบได้');
|
||||||
}
|
|
||||||
exams = await res.json()
|
exams = await res.json()
|
||||||
|
|
||||||
const events:CalendarEvent[]=[]
|
const events:CalendarEvent[]=[]
|
||||||
exams.forEach((e)=>{
|
exams.forEach((ex)=>{
|
||||||
if(!e.start){
|
const {id,title,start,end,category_id} = ex
|
||||||
e.date=""
|
let backgroundColor ="#23ccef"
|
||||||
return
|
switch (String(category_id)) {
|
||||||
}
|
|
||||||
e.date = e.start? dayjs(e.start).format("DD MMM BBBB"):""
|
|
||||||
const {id,title,start,end,category_id} = e
|
|
||||||
let backgroundColor =""
|
|
||||||
switch (category_id) {
|
|
||||||
case "1":
|
case "1":
|
||||||
backgroundColor="rgba(251,64,75,.2)"
|
backgroundColor="rgba(251,64,75,.2)"
|
||||||
break;
|
break;
|
||||||
|
|
@ -39,15 +28,18 @@ export const load: PageServerLoad = async ({fetch}) => {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
const url = "/qualifying/"+id
|
const url = "/qualifying/"+id
|
||||||
events.push({id,title,start,end,url,backgroundColor})
|
if(start){
|
||||||
if(e.exam_date){
|
ex.date = dayjs(start).format("DD MMM BBBB")
|
||||||
events.push({id,"title":"สอบ","start":e.exam_date,url,backgroundColor})
|
events.push({id,title,start,end,url,backgroundColor})
|
||||||
}
|
}
|
||||||
if(e.announcement_date){
|
if(ex.exam_date){
|
||||||
events.push({id,"title":"ผลสอบสอบ","start":e.announcement_date,url,backgroundColor})
|
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}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,7 @@
|
||||||
import ActivityCalendar from '$lib/components/ActivityCalendar.svelte'
|
import ActivityCalendar from '$lib/components/ActivityCalendar.svelte'
|
||||||
import type { PageData } from './$types'
|
import type { PageData } from './$types'
|
||||||
export let data: PageData;
|
export let data: PageData;
|
||||||
const exams = data.exams
|
const {exams,events} = data
|
||||||
const events = data.events
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
|
|
@ -63,9 +62,13 @@
|
||||||
<tbody>
|
<tbody>
|
||||||
{#each exams as exam}
|
{#each exams as exam}
|
||||||
<tr>
|
<tr>
|
||||||
<th class="border-t-0 px-6 align-middle border-l-0 border-r-0 text-xs whitespace-nowrap p-4 text-left"><a href={"/qualifying/"+exam.id}>{exam.date}</a></th>
|
<th class="border-t-0 px-6 align-middle border-l-0 border-r-0 text-xs whitespace-nowrap p-4 text-left">
|
||||||
|
<a href={"/qualifying/"+exam.id}>
|
||||||
|
{exam.date??""}
|
||||||
|
</a>
|
||||||
|
</th>
|
||||||
<td class="border-t-0 px-6 align-middle border-l-0 border-r-0 text-xs whitespace-nowrap p-4 text-left"><a href={"/qualifying/"+exam.id}>{exam.title}</a></td>
|
<td class="border-t-0 px-6 align-middle border-l-0 border-r-0 text-xs whitespace-nowrap p-4 text-left"><a href={"/qualifying/"+exam.id}>{exam.title}</a></td>
|
||||||
<td class="border-t-0 px-6 align-middle border-l-0 border-r-0 text-xs whitespace-nowrap p-4 text-left">{exam.category}</td>
|
<td class="border-t-0 px-6 align-middle border-l-0 border-r-0 text-xs whitespace-nowrap p-4 text-left">{exam.category??""}</td>
|
||||||
{/each}
|
{/each}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
//import type {Exam} from '$lib/data/CMSDataType'
|
import {apibase} from '$lib/data/CMSDataType'
|
||||||
import { error } from '@sveltejs/kit'
|
import { error } from '@sveltejs/kit'
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
import type { PageServerLoad } from './$types'
|
import type { PageServerLoad } from './$types'
|
||||||
export const load: PageServerLoad = async ({params,fetch}) => {
|
export const load: PageServerLoad = async ({params,fetch}) => {
|
||||||
const id = params.id+""
|
const id = params.id+""
|
||||||
const res = await fetch("/api/qualifying/"+id)
|
const res = await fetch(apibase+"/qualifying/"+id)
|
||||||
if(res.status==404){
|
if(res.status==404){
|
||||||
throw error(404,{message:`ค้นหาข้อมูลสอบคัดเลือก ${id}ไม่พบ`})
|
throw error(404,{message:`ค้นหาข้อมูลสอบคัดเลือก ${id}ไม่พบ`})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<span class="breadTaxt">ประกาศเกี่ยวกับการคัดเลือกบุคลากรกทม.</span>
|
<span class="breadTaxt">ประกาศเกี่ยวกับการคัดเลือกบุคลากรของกทม.</span>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue