This commit is contained in:
2026-02-10 17:11:24 +07:00
parent 87bddca6c3
commit 9851c311b3
60 changed files with 1127 additions and 89 deletions

View File

@@ -0,0 +1,14 @@
import { JobData } from "../../data/articles/Job";
export function resolveJobPage(slug: string) {
const job = JobData.list.find(
(item) => item.url.replace(/^\//, "") === slug
);
if (!job) return null;
return {
type: "job_detail",
data: job,
};
}

View File

@@ -1,9 +1,11 @@
import { resolveArticlePage } from "./resolveArticlePage";
import { resolveProductPage } from "./resolveProductPage";
import { resolveJobPage } from "./resolveJobPage";
export type SlugResult =
| ReturnType<typeof resolveArticlePage>
| ReturnType<typeof resolveProductPage>;
| ReturnType<typeof resolveProductPage>
| ReturnType<typeof resolveJobPage>;
export function findBySlug(slug?: string): SlugResult | null {
@@ -18,6 +20,10 @@ export function findBySlug(slug?: string): SlugResult | null {
const article = resolveArticlePage(slug);
if (article) return article;
// Job
const job = resolveJobPage(slug);
if (job) return job;
// 404
return null;
}

View File

@@ -52,4 +52,18 @@ export function getTimeLeft(endTime: number) {
minutes : String(Math.floor((distance % 3600) / 60)).padStart(2, '0'),
seconds : String(distance % 60).padStart(2, '0'),
};
}
}
// Đếm ngược theo thời gian hiện tại
export function getRemainingDays(dateStr: string): number {
const [day, month, year] = dateStr.split("-").map(Number);
// Hết hạn lúc 23:59:59 cho đúng logic tuyển dụng
const endDate = new Date(year, month - 1, day, 23, 59, 59);
const now = new Date();
const diffTime = endDate.getTime() - now.getTime();
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
return diffDays > 0 ? diffDays : 0;
}