Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions apps/web/src/app/(site)/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import Link from 'next/link';
import { CategorySection } from '@/components/landing/category-section';
import { Hero } from '@/components/landing/hero';
import { JobCard } from '@/components/landing/job-card';
import { FeaturedJobs } from '@/components/landing/featured-jobs';
import { TrustNotice } from '@/components/landing/trust-notice';
import { MOCK_JOBS } from '@/lib/mock-landing';

/** หน้าแรกเป็นชุด Tile เต็มความกว้างสลับพื้นขาว / Parchment / เข้ม (DESIGN-apple) — สีพื้นที่เปลี่ยนทำหน้าที่แบ่งส่วน */
export default function HomePage() {
Expand All @@ -16,14 +15,10 @@ export default function HomePage() {
<div className="flex flex-wrap items-end justify-between gap-3">
<div>
<h2 id="jobs-title" className="text-3xl font-semibold sm:text-[40px] sm:leading-[1.1]">งานฝึกงานที่เปิดรับ</h2>
{/* MOCK: เปลี่ยนเป็นผลจาก Job Search เมื่อเปิดให้เรียกโดยไม่ต้องล็อกอิน (ดู src/lib/mock-landing.ts) */}
<p className="mt-2 text-ink-soft">ตัวอย่างประกาศ (ข้อมูลจำลอง)</p>
</div>
<Link href="/jobs" className="text-primary hover:underline">ดูทั้งหมด ›</Link>
</div>
<div className="mt-8 grid gap-5 md:grid-cols-3">
{MOCK_JOBS.map((item) => <JobCard key={item.job.id} item={item} />)}
</div>
<FeaturedJobs />
</div>
</section>
<TrustNotice />
Expand Down
6 changes: 2 additions & 4 deletions apps/web/src/components/jobs/job-detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { ReportPanel } from '@/components/reports/report-panel';
import { getJob } from '@/lib/job-search';
import type { JobDetailResult } from '@/lib/job-search';
import { StatusBadge } from '@/components/ui/status-badge';
import { CATEGORIES } from '@/lib/mock-landing';
import { CATEGORIES } from '@/lib/categories';
import { JOB_STATUS, statusView } from '@/lib/status-map';

const workModeLabel: Record<WorkMode, string> = { ONSITE: 'On-Site', HYBRID: 'Hybrid', REMOTE: 'Remote' };
Expand Down Expand Up @@ -95,10 +95,8 @@ export function JobDetail() {
return (
<main className="mx-auto max-w-4xl px-4 py-10 sm:px-6">
<Link href="/jobs" className="text-sm font-medium text-primary hover:underline">← กลับไปค้นหางาน</Link>
{/* MOCK: ข้อมูลตัวอย่าง จนกว่า GET /jobs/{id} จะเปิดให้เรียกโดยไม่ต้องล็อกอิน (ดู src/lib/job-search.ts) */}
<p className="mt-3 text-xs text-warning-text">ข้อมูลในหน้านี้เป็นข้อมูลจำลอง</p>

<header className="mt-2">
<header className="mt-4">
<div className="flex flex-wrap items-center gap-2">
<Badge tone="neutral">{category}</Badge>
{job.featured && <Badge tone="accent">Featured</Badge>}
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/jobs/job-result-card.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Link from 'next/link';
import type { SearchJobItem, WorkMode } from '@internpath/contracts';
import { CATEGORIES } from '@/lib/mock-landing';
import { CATEGORIES } from '@/lib/categories';
import type { CompanyRating } from '@/lib/job-search';

const workModeLabel: Record<WorkMode, string> = { ONSITE: 'On-Site', HYBRID: 'Hybrid', REMOTE: 'Remote' };
Expand Down
29 changes: 20 additions & 9 deletions apps/web/src/components/jobs/job-search-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

import { usePathname, useRouter, useSearchParams } from 'next/navigation';
import { useEffect, useState } from 'react';
import type { JobCategory, SearchJobsQuery, StudentProfile, WorkMode } from '@internpath/contracts';
import type { JobCategory, JobTag, SearchJobsQuery, StudentProfile, WorkMode } from '@internpath/contracts';
import { useAuth } from '@/auth/session';
import { FilterSelect } from '@/components/admin/filter-fields';
import { JobResultCard } from '@/components/jobs/job-result-card';
import { CATEGORIES } from '@/lib/mock-landing';
import { MOCK_TAG_NAMES } from '@/lib/mock-jobs';
import { PAGE_SIZE, searchJobs } from '@/lib/job-search';
import { CATEGORIES } from '@/lib/categories';
import { PAGE_SIZE, listTags, searchJobs } from '@/lib/job-search';
import type { JobSearchResult } from '@/lib/job-search';

const CATEGORY_IDS = CATEGORIES.map((entry) => entry.id);
Expand All @@ -31,8 +30,7 @@ function readQuery(params: URLSearchParams): { query: SearchJobsQuery; page: num
tags: (params.get('tags') ?? '').split(',').map((slug) => slug.trim().toLowerCase()).filter((slug) => /^[a-z0-9-]{1,50}$/.test(slug)).join(',') || undefined,
allowance: params.get('allowance') === 'true' ? true : undefined,
// ลิงก์จากหน้าบริษัท — ต้องเป็น UUID เท่านั้น (URL เป็นข้อมูลจากภายนอก)
company_id: /^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$/i.test(params.get('company_id') ?? '') || /^mock-co-\d+$/.test(params.get('company_id') ?? '')
? (params.get('company_id') as string) : undefined,
company_id: /^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$/i.test(params.get('company_id') ?? '') ? (params.get('company_id') as string) : undefined,
sort: SORTS.includes(sort as (typeof SORTS)[number]) ? (sort as (typeof SORTS)[number]) : 'newest',
},
page: Number.isInteger(page) && page >= 1 ? page : 1,
Expand All @@ -52,6 +50,18 @@ export function JobSearchPage() {
const [major, setMajor] = useState(query.major ?? '');
const { user, request } = useAuth();
const [profileMajor, setProfileMajor] = useState<string | undefined>(undefined);
const [tags, setTags] = useState<JobTag[] | null>(null);
const [tagsFailed, setTagsFailed] = useState(false);

// Tag ทักษะที่เปิดใช้งาน — โหลดครั้งเดียว; โหลดไม่ได้ก็ยังค้นหาด้วยตัวกรองอื่นได้
useEffect(() => {
let cancelled = false;
listTags().then(
(next) => { if (!cancelled) setTags(next); },
() => { if (!cancelled) setTagsFailed(true); },
);
return () => { cancelled = true; };
}, []);

// นักศึกษาที่ล็อกอิน: ใช้สาขาจากโปรไฟล์เทียบกับประกาศโดยอัตโนมัติ (เทียบแบบตรงทั้งค่า จึงไม่ให้เดาจากการพิมพ์)
// เก็บเป็น state ไม่ใส่ใน URL เพื่อไม่ให้ข้อมูลส่วนตัวไปอยู่ในลิงก์ที่แชร์ได้
Expand Down Expand Up @@ -101,8 +111,6 @@ export function JobSearchPage() {
<main className="mx-auto max-w-6xl px-4 py-10 sm:px-6">
<h1 className="text-3xl font-semibold">ค้นหางานฝึกงาน</h1>
<p className="mt-2 text-sm text-ink-soft">เลือกจากประกาศที่ผ่านการตรวจสอบแล้ว กรองตามสายงาน รูปแบบการทำงาน และสาขาของคุณ</p>
{/* MOCK: ข้อมูลจากไฟล์ตัวอย่าง จนกว่า GET /search/jobs จะเปิดให้เรียกโดยไม่ต้องล็อกอิน (ดู src/lib/job-search.ts) */}
<p className="mt-1 text-xs text-warning-text">ข้อมูลในหน้านี้เป็นข้อมูลจำลอง</p>

<form
role="search"
Expand Down Expand Up @@ -136,7 +144,10 @@ export function JobSearchPage() {
<div className="mt-4" role="group" aria-label="กรองตาม Tag ทักษะ">
<span className="mb-1 block text-xs font-medium text-ink-soft">Tag ทักษะ (เลือกได้หลายรายการ — แสดงประกาศที่มี Tag ใดก็ได้)</span>
<div className="flex flex-wrap gap-2">
{Object.entries(MOCK_TAG_NAMES).map(([slug, name]) => {
{tagsFailed && <span className="text-sm text-ink-soft">โหลดรายการ Tag ไม่สำเร็จ</span>}
{!tags && !tagsFailed && <span className="text-sm text-ink-soft">กำลังโหลด…</span>}
{tags?.length === 0 && <span className="text-sm text-ink-soft">ยังไม่มี Tag ทักษะ</span>}
{tags?.map(({ slug, name }) => {
const selected = (query.tags ?? '').split(',').filter(Boolean);
const on = selected.includes(slug);
return (
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/landing/category-section.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Link from 'next/link';
import type { JobCategory } from '@internpath/contracts';
import { CATEGORIES } from '@/lib/mock-landing';
import { CATEGORIES } from '@/lib/categories';

const icons: Record<JobCategory, React.ReactNode> = {
TECH_IT: <><rect x="4" y="5" width="16" height="11" rx="1.5" /><path d="M2 19h20" /></>,
Expand Down
34 changes: 34 additions & 0 deletions apps/web/src/components/landing/featured-jobs.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
'use client';

import { useEffect, useState } from 'react';
import { JobResultCard } from '@/components/jobs/job-result-card';
import { searchJobs } from '@/lib/job-search';
import type { JobSearchResult } from '@/lib/job-search';

/** "งานเด่น" ของหน้าแรก = `GET /search/jobs?page_size=3` (api-contract §5.2: `featured` ขึ้นก่อนเสมอ แล้วตามประกาศใหม่ล่าสุด) */
const LANDING_SIZE = 3;

export function FeaturedJobs() {
const [result, setResult] = useState<JobSearchResult | null>(null);
const [failed, setFailed] = useState(false);

useEffect(() => {
let cancelled = false;
searchJobs({ sort: 'newest' }, 1, LANDING_SIZE).then(
(next) => { if (!cancelled) setResult(next); },
() => { if (!cancelled) setFailed(true); },
);
return () => { cancelled = true; };
}, []);

if (failed) return <p className="mt-8 text-sm text-ink-soft">โหลดประกาศไม่สำเร็จ กรุณาลองใหม่ภายหลัง</p>;
if (!result) return <p className="mt-8 text-sm text-ink-soft" aria-busy="true">กำลังโหลด…</p>;
if (result.jobs.length === 0) return <p className="mt-8 text-sm text-ink-soft">ยังไม่มีประกาศที่เปิดรับ</p>;
return (
<ul className="mt-8 grid gap-5 md:grid-cols-3">
{result.jobs.map((job) => (
<li key={job.id} className="contents"><JobResultCard job={job} rating={result.ratings[job.company.id]} /></li>
))}
</ul>
);
}
48 changes: 0 additions & 48 deletions apps/web/src/components/landing/job-card.tsx

This file was deleted.

8 changes: 8 additions & 0 deletions apps/web/src/lib/categories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import type { JobCategory } from '@internpath/contracts';

/** สายงาน 3 หมวดของประกาศ (README 5.1) — ใช้ทั้งตัวกรองค้นหา หน้าแรก และฝั่ง HR */
export const CATEGORIES: Array<{ id: JobCategory; label: string; description: string }> = [
{ id: 'TECH_IT', label: 'Tech & IT', description: 'ซอฟต์แวร์ · ข้อมูล · UX' },
{ id: 'BUSINESS_MARKETING', label: 'Business & Marketing', description: 'การตลาด · คอนเทนต์ · ธุรกิจ' },
{ id: 'CORPORATE_SERVICES', label: 'Corporate Services', description: 'บุคคล · บริการ · ธุรการ' },
];
Loading
Loading