Init project
This commit is contained in:
parent
050fdb4f64
commit
e5d6c890a8
46 changed files with 7856 additions and 0 deletions
12
cms/src/app.d.ts
vendored
Normal file
12
cms/src/app.d.ts
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
// See https://kit.svelte.dev/docs/types#app
|
||||
// for information about these interfaces
|
||||
declare global {
|
||||
namespace App {
|
||||
// interface Error {}
|
||||
// interface Locals {}
|
||||
// interface PageData {}
|
||||
// interface Platform {}
|
||||
}
|
||||
}
|
||||
|
||||
export {};
|
||||
13
cms/src/app.html
Normal file
13
cms/src/app.html
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
<link rel="manifest" href="manifest.json" />
|
||||
%sveltekit.head%
|
||||
</head>
|
||||
<body data-sveltekit-preload-data="hover">
|
||||
<div style="display: contents">%sveltekit.body%</div>
|
||||
</body>
|
||||
</html>
|
||||
4
cms/src/app.postcss
Normal file
4
cms/src/app.postcss
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
/* Write your global styles here, in PostCSS syntax */
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
7
cms/src/index.test.ts
Normal file
7
cms/src/index.test.ts
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import { describe, it, expect } from 'vitest';
|
||||
|
||||
describe('sum test', () => {
|
||||
it('adds 1 + 2 to equal 3', () => {
|
||||
expect(1 + 2).toBe(3);
|
||||
});
|
||||
});
|
||||
33
cms/src/lib/components/Header.svelte
Normal file
33
cms/src/lib/components/Header.svelte
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
<div class="navbar bg-base-100">
|
||||
<div class="navbar-start">
|
||||
<div class="dropdown">
|
||||
<!-- svelte-ignore a11y-label-has-associated-control -->
|
||||
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
|
||||
<label tabindex="0" class="btn btn-ghost lg:hidden">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h8m-8 6h16" /></svg>
|
||||
</label>
|
||||
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
|
||||
<ul tabindex="0" class="menu menu-compact dropdown-content mt-3 p-2 shadow bg-base-100 rounded-box w-52">
|
||||
<li><a href="/">หน้าหลัก</a></li>
|
||||
<li><a href="/qualifying">การสอบคัดเลือก</a></li>
|
||||
<li><a href="/competitive">การสอบแข่งขัน</a></li>
|
||||
<li><a href="/about">เกี่ยวกับเรา</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<a class="btn btn-ghost normal-case text-xl"
|
||||
href="https://webportal.bangkok.go.th/KSB/page/top/1119/%E0%B8%81%E0%B8%AD%E0%B8%87%E0%B8%AA%E0%B8%A3%E0%B8%A3%E0%B8%AB%E0%B8%B2%E0%B8%9A%E0%B8%B8%E0%B8%84%E0%B8%84%E0%B8%A5">
|
||||
กองสรรหา
|
||||
</a>
|
||||
</div>
|
||||
<div class="navbar-center hidden lg:flex">
|
||||
<ul class="menu menu-horizontal px-1">
|
||||
<li><a href="/">หน้าหลัก</a></li>
|
||||
<li><a href="/qualifying">การสอบคัดเลือก</a></li>
|
||||
<li><a href="/competitive">การสอบแข่งขัน</a></li>
|
||||
<li><a href="/about">เกี่ยวกับเรา</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="navbar-end">
|
||||
<a class="btn" href="/">เข้าสู่ระบบ</a>
|
||||
</div>
|
||||
</div>
|
||||
13
cms/src/lib/data/info.json
Normal file
13
cms/src/lib/data/info.json
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"contact":{
|
||||
"company_name": "กองสรรหาบุคคล",
|
||||
"description":
|
||||
"มีหน้าที่รับผิดชอบเกี่ยวกับการสรรหาและเลือกสรรบุคคลเข้ารับราบการเป็นข้าราขการกรุงเทพมหานคร สามัญและข้าราชการครูกรุงเทพมหานครเฉพาะสังกัดสำนักพัฒนาชุมชน ....",
|
||||
"contact_email_address": "sale@frappet.com",
|
||||
"phone": "(662) xxx xxx",
|
||||
"address": "123 Example Street, xxx, 9876, yyy",
|
||||
"zip": "10510",
|
||||
"Country": "Thailand"
|
||||
}
|
||||
|
||||
}
|
||||
8
cms/src/lib/data/info.test.ts
Normal file
8
cms/src/lib/data/info.test.ts
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
//TDD
|
||||
import {it,expect } from 'vitest'
|
||||
import {getContact} from './info'
|
||||
it('test getContact() ',async ()=>{
|
||||
const result = await getContact()
|
||||
expect(result.company_name).toBe("กองสรรหาบุคคล")
|
||||
expect(result.Country).toBe("Thailand")
|
||||
})
|
||||
4
cms/src/lib/data/info.ts
Normal file
4
cms/src/lib/data/info.ts
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
import info from "./info.json"
|
||||
export async function getContact(){
|
||||
return info.contact
|
||||
}
|
||||
72
cms/src/lib/data/users.json
Normal file
72
cms/src/lib/data/users.json
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
[
|
||||
{
|
||||
"id": 1,
|
||||
"name": "Leanne Graham",
|
||||
"username": "Bret",
|
||||
"email": "Sincere@april.biz",
|
||||
"phone": "1-770-736-8031 x56442"
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"name": "Ervin Howell",
|
||||
"username": "Antonette",
|
||||
"email": "Shanna@melissa.tv",
|
||||
"phone": "010-692-6593 x09125"
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"name": "Clementine Bauch",
|
||||
"username": "Samantha",
|
||||
"email": "Nathan@yesenia.net",
|
||||
"phone": "1-463-123-4447"
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"name": "Patricia Lebsack",
|
||||
"username": "Karianne",
|
||||
"email": "Julianne.OConner@kory.org",
|
||||
"phone": "493-170-9623 x156"
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"name": "Chelsey Dietrich",
|
||||
"username": "Kamren",
|
||||
"email": "Lucio_Hettinger@annie.ca",
|
||||
"phone": "(254)954-1289"
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
"name": "Mrs. Dennis Schulist",
|
||||
"username": "Leopoldo_Corkery",
|
||||
"email": "Karley_Dach@jasper.info",
|
||||
"phone": "1-477-935-8478 x6430"
|
||||
},
|
||||
{
|
||||
"id": 7,
|
||||
"name": "Kurtis Weissnat",
|
||||
"username": "Elwyn.Skiles",
|
||||
"email": "Telly.Hoeger@billy.biz",
|
||||
"phone": "210.067.6132"
|
||||
},
|
||||
{
|
||||
"id": 8,
|
||||
"name": "Nicholas Runolfsdottir V",
|
||||
"username": "Maxime_Nienow",
|
||||
"email": "Sherwood@rosamond.me",
|
||||
"phone": "586.493.6943 x140"
|
||||
},
|
||||
{
|
||||
"id": 9,
|
||||
"name": "Glenna Reichert",
|
||||
"username": "Delphine",
|
||||
"email": "Chaim_McDermott@dana.io",
|
||||
"phone": "(775)976-6794 x41206"
|
||||
},
|
||||
{
|
||||
"id": 10,
|
||||
"name": "Clementina DuBuque",
|
||||
"username": "Moriah.Stanton",
|
||||
"email": "Rey.Padberg@karina.biz",
|
||||
"phone": "024-648-3804"
|
||||
}
|
||||
]
|
||||
28
cms/src/lib/data/users.ts
Normal file
28
cms/src/lib/data/users.ts
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import users from "./users.json"
|
||||
let userid =100
|
||||
|
||||
export interface User {
|
||||
id: number;
|
||||
email: string;
|
||||
username: string;
|
||||
name:string;
|
||||
last_name: string;
|
||||
phone:string
|
||||
}
|
||||
export async function getUser(id:number){
|
||||
return users.find(u=>u.id===id)
|
||||
}
|
||||
export async function getUsers(){
|
||||
return users
|
||||
}
|
||||
export async function createUser(u:User){
|
||||
u.id= userid++
|
||||
return users.push(u)
|
||||
}
|
||||
export async function updateUser(u:User){
|
||||
const user = await getUser(u.id)
|
||||
if(!user)
|
||||
return user
|
||||
user.phone = u.phone
|
||||
return user
|
||||
}
|
||||
9
cms/src/routes/+error.svelte
Normal file
9
cms/src/routes/+error.svelte
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<script>
|
||||
import { page } from '$app/stores';
|
||||
</script>
|
||||
|
||||
<h1>{$page.error?.message}</h1>
|
||||
|
||||
<div>
|
||||
มีบางอย่างไม่ถูกต้องกรุณาติดต่อ 02-xxxxxxxx
|
||||
</div>
|
||||
11
cms/src/routes/+layout.svelte
Normal file
11
cms/src/routes/+layout.svelte
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<script>
|
||||
import '../app.postcss';
|
||||
import Header from '$lib/components/Header.svelte';
|
||||
</script>
|
||||
|
||||
<Header />
|
||||
<div class="p-10 max-w-4xl place-content-center ">
|
||||
<div>
|
||||
<slot />
|
||||
</div>
|
||||
</div>
|
||||
14
cms/src/routes/+page.svelte
Normal file
14
cms/src/routes/+page.svelte
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<h1 class="text-4xl">กองสรรหาบุคคล (Recruitment Division)</h1>
|
||||
|
||||
|
||||
|
||||
<h2 class="text-2xl">ประกาศเกี่ยวกับการคัดเลือกบุคลากรกทม</h2>
|
||||
<div>xxxx</div>
|
||||
<div>xxxx</div>
|
||||
<div>xxxx</div>
|
||||
<div>xxxx</div>
|
||||
<h2 class="text-2xl">ประกาศเกี่ยวกับการสอบแข่งขัน</h2>
|
||||
<div>xxxx</div>
|
||||
<div>xxxx</div>
|
||||
<div>xxxx</div>
|
||||
<div>xxxx</div>
|
||||
12
cms/src/routes/about/+page.server.ts
Normal file
12
cms/src/routes/about/+page.server.ts
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
|
||||
import {getContact} from "$lib/data/info"
|
||||
|
||||
import type { PageServerLoad } from './$types'
|
||||
/*
|
||||
export const load: PageServerLoad = async () => {
|
||||
return getContact()
|
||||
}*/
|
||||
|
||||
export const load = (async () => {
|
||||
return getContact()
|
||||
}) satisfies PageServerLoad
|
||||
10
cms/src/routes/about/+page.svelte
Normal file
10
cms/src/routes/about/+page.svelte
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<script lang="ts">
|
||||
import type { PageData } from './$types'
|
||||
export let data: PageData;
|
||||
</script>
|
||||
|
||||
<h1 class="text-4xl">{data.company_name}</h1>
|
||||
|
||||
<div>{data.description}</div>
|
||||
|
||||
|
||||
12
cms/src/routes/api/users/+server.ts
Normal file
12
cms/src/routes/api/users/+server.ts
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import type { RequestEvent, RequestHandler } from './$types'
|
||||
import {json} from '@sveltejs/kit'
|
||||
import { createUser, getUsers } from '$lib/data/users'
|
||||
|
||||
//api/users
|
||||
export const POST: RequestHandler = async ({ request }: RequestEvent) => {
|
||||
const data = await request.json()
|
||||
return json(await createUser( data))
|
||||
}
|
||||
export const GET: RequestHandler = async () => {
|
||||
return json(await getUsers())
|
||||
}
|
||||
19
cms/src/routes/api/users/[id]/+server.ts
Normal file
19
cms/src/routes/api/users/[id]/+server.ts
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import type { RequestEvent, RequestHandler } from './$types'
|
||||
import {json} from '@sveltejs/kit'
|
||||
import { getUser, updateUser } from '$lib/data/users'
|
||||
|
||||
//api/users/1
|
||||
export const PUT: RequestHandler = async ({ request }: RequestEvent) => {
|
||||
const o = await request.json()
|
||||
if(!updateUser(o))
|
||||
return json({message:"call updateUser fail "},{status:400})
|
||||
return json({message:"Update Success"})
|
||||
}
|
||||
export const GET: RequestHandler = async ({params}: RequestEvent) => {
|
||||
const id = Number(params.id)
|
||||
const u = await getUser(id)
|
||||
if(!u)
|
||||
return json({message:`User ${id} not found`},{status:404})
|
||||
return json(u)
|
||||
}
|
||||
|
||||
7
cms/src/routes/competitive/+page.svelte
Normal file
7
cms/src/routes/competitive/+page.svelte
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<h1 class="text-4xl">การสอบแข่งขัน</h1>
|
||||
|
||||
fdsafda
|
||||
fdsafda sdaf
|
||||
sdaffsdasaf rfffffffffffffffff fffffffffffffffffffffffff ffffffffffff fgedfgfdgfdsg
|
||||
fedsddddddddddddd ddddddddddddddd ddddddddd d d d d d d d d d d d d xxxx
|
||||
|
||||
6
cms/src/routes/qualifying/+page.svelte
Normal file
6
cms/src/routes/qualifying/+page.svelte
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<h1 class="text-4xl">การสอบคัดเลือก</h1>
|
||||
|
||||
<button class="btn btn-outline">Button</button>
|
||||
<button class="btn btn-outline btn-primary">Button</button>
|
||||
<button class="btn btn-outline btn-secondary">Button</button>
|
||||
|
||||
66
cms/src/service-worker.ts
Normal file
66
cms/src/service-worker.ts
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
/// <reference types="@sveltejs/kit" />
|
||||
/// <reference no-default-lib="true"/>
|
||||
/// <reference lib="esnext" />
|
||||
/// <reference lib="webworker" />
|
||||
|
||||
import { build, files, version } from '$service-worker';
|
||||
|
||||
// Create a unique cache name for this deployment
|
||||
const CACHE = `cache-${version}`;
|
||||
|
||||
const ASSETS = [
|
||||
...build, // the app itself
|
||||
...files // everything in `static`
|
||||
];
|
||||
|
||||
self.addEventListener('install', (event) => {
|
||||
// Create a new cache and add all files to it
|
||||
async function addFilesToCache() {
|
||||
const cache = await caches.open(CACHE);
|
||||
await cache.addAll(ASSETS);
|
||||
}
|
||||
|
||||
event.waitUntil(addFilesToCache());
|
||||
});
|
||||
|
||||
self.addEventListener('activate', (event) => {
|
||||
// Remove previous cached data from disk
|
||||
async function deleteOldCaches() {
|
||||
for (const key of await caches.keys()) {
|
||||
if (key !== CACHE) await caches.delete(key);
|
||||
}
|
||||
}
|
||||
|
||||
event.waitUntil(deleteOldCaches());
|
||||
});
|
||||
|
||||
self.addEventListener('fetch', (event) => {
|
||||
// ignore POST requests etc
|
||||
if (event.request.method !== 'GET') return;
|
||||
|
||||
async function respond() {
|
||||
const url = new URL(event.request.url);
|
||||
const cache = await caches.open(CACHE);
|
||||
|
||||
// `build`/`files` can always be served from the cache
|
||||
if (ASSETS.includes(url.pathname)) {
|
||||
return cache.match(event.request);
|
||||
}
|
||||
|
||||
// for everything else, try the network first, but
|
||||
// fall back to the cache if we're offline
|
||||
try {
|
||||
const response = await fetch(event.request);
|
||||
|
||||
if (response.status === 200) {
|
||||
cache.put(event.request, response.clone());
|
||||
}
|
||||
|
||||
return response;
|
||||
} catch {
|
||||
return cache.match(event.request);
|
||||
}
|
||||
}
|
||||
|
||||
event.respondWith(respond());
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue