Update and clean code
This commit is contained in:
parent
3edde43c25
commit
1c9b5877d6
29 changed files with 1179 additions and 838 deletions
8
cms/src/routes/competitive/+page.server.ts
Normal file
8
cms/src/routes/competitive/+page.server.ts
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
|
||||
import {getCompetitiveExams} from "$lib/data/info"
|
||||
import type { PageServerLoad } from './$types'
|
||||
export const load: PageServerLoad = async () => {
|
||||
const exams = await getCompetitiveExams()
|
||||
return {exams}
|
||||
}
|
||||
|
||||
|
|
@ -1,35 +1,28 @@
|
|||
<script lang="ts">
|
||||
import 'dayjs/locale/th.js';
|
||||
import 'dayjs/locale/zh-cn.js';
|
||||
import 'dayjs/locale/es.js';
|
||||
import 'dayjs/locale/ar-dz.js';
|
||||
// มันรองรับ พ.ศ. ใน dayjs แต่ใน velte-calendar ไม่ได้เอาไปใช้ ยังหาวิธีแก้หัวปฎิทินไม่ได้ยังเป็น พ.ศ.
|
||||
import buddhistEra from 'dayjs/plugin/buddhistEra'
|
||||
import dayjs from 'dayjs';
|
||||
dayjs.extend(buddhistEra)
|
||||
import { InlineCalendar, Swappable, themes } from 'svelte-calendar';
|
||||
import { onDestroy } from 'svelte';
|
||||
|
||||
const locales = ['th','en', 'es', 'zh-cn', 'ar-dz'];
|
||||
let format = 'DD/MM/BBBB'
|
||||
let locale = 'th';
|
||||
|
||||
$: dayjs.locale(locale);
|
||||
|
||||
onDestroy(() => dayjs.locale('en'));
|
||||
import type { PageData } from './$types'
|
||||
export let data: PageData;
|
||||
const exams = data.exams
|
||||
</script>
|
||||
|
||||
|
||||
<h1 class="text-4xl">การสอบแข่งขัน</h1>
|
||||
<!-- note: Locale is not reactive -->
|
||||
<Swappable value={{ locale }} vertical={false} >
|
||||
<InlineCalendar theme={themes.light} {format} />
|
||||
</Swappable>
|
||||
<h1 class="p-5">การสอบแข่งขัน</h1>
|
||||
|
||||
<div class="button-group">
|
||||
{#each locales as loc}
|
||||
<button on:click={() => (locale = loc)} class:selected={locale === loc}>
|
||||
{loc}
|
||||
</button> |
|
||||
{/each}
|
||||
<div class="p-5">
|
||||
<table class="table table-compact w-full">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>วันที่</th>
|
||||
<th>การสอบ</th>
|
||||
<th>หน่วยงาน</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{#each exams as exam}
|
||||
<tr>
|
||||
<th><a href={"/exams/"+exam.id}>{exam.date}</a></th>
|
||||
<td>{exam.detail}</td>
|
||||
<td>{exam.institute}</td>
|
||||
{/each}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue