Heb er een PWA van gemaakt en layout gecorrigeerd

This commit is contained in:
LogJurgenR
2026-08-19 16:46:29 +02:00
parent d3cab99d86
commit 686339325e
21 changed files with 1629 additions and 103 deletions
+109 -62
View File
@@ -1,69 +1,116 @@
import Image from "next/image";
import LogoutButton from "@/app/logout-button";
import LanguageSwitcher from "@/app/language-switcher";
import { getItems } from "@/lib/items";
import { cookies } from "next/headers";
import { getLocale, LOCALE_COOKIE, t } from "@/lib/i18n";
export const dynamic = "force-dynamic";
export default async function ItemsPage() {
const { items, error } = await getItems();
const locale = getLocale((await cookies()).get(LOCALE_COOKIE)?.value);
export default function Home() {
return (
<div className="flex flex-col flex-1 items-center justify-center bg-zinc-50 font-sans dark:bg-black">
<main className="flex flex-1 w-full max-w-3xl flex-col items-center justify-between py-32 px-16 bg-white dark:bg-black sm:items-start">
<Image
className="dark:invert h-5 w-[100px]"
src="/next.svg"
alt="Next.js logo"
width={100}
height={20}
priority
/>
<div className="flex flex-col items-center gap-6 text-center sm:items-start sm:text-left">
<h1 className="max-w-xs text-3xl font-semibold leading-10 tracking-tight text-black dark:text-zinc-50">
To get started, edit the{" "}
<code className="rounded bg-black/[.06] px-1.5 py-0.5 font-mono text-[0.9em] dark:bg-white/[.08]">
page.tsx
</code>{" "}
file.
<main className="min-h-screen bg-slate-50">
{/* Header */}
<div className="bg-gradient-to-r from-sky-900 via-cyan-800 to-cyan-600 text-white shadow-lg">
<div className="mx-auto max-w-7xl px-6 py-12">
<h1 className="text-4xl font-bold tracking-tight">
{t(locale, "articles.title")}
</h1>
<p className="max-w-md text-lg leading-8 text-zinc-600 dark:text-zinc-400">
Looking for a starting point or more instructions? Head over to{" "}
<a
href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
className="font-medium text-zinc-950 dark:text-zinc-50"
>
Templates
</a>{" "}
or the{" "}
<a
href="https://nextjs.org/learn?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
className="font-medium text-zinc-950 dark:text-zinc-50"
>
Learning
</a>{" "}
center.
<p className="mt-3 max-w-2xl text-sky-100">
{t(locale, "articles.description")}
</p>
<div className="mt-6 flex flex-wrap items-center gap-3">
<LogoutButton locale={locale} />
<LanguageSwitcher locale={locale} label={t(locale, "language.label")} />
</div>
</div>
<div className="flex flex-col gap-4 text-base font-medium sm:flex-row">
<a
className="flex h-12 w-full items-center justify-center gap-2 rounded-full bg-foreground px-5 text-background transition-colors hover:bg-[#383838] dark:hover:bg-[#ccc] md:w-[158px]"
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
<Image
className="dark:invert h-[14px] w-4"
src="/vercel.svg"
alt="Vercel logomark"
width={16}
height={14}
/>
Deploy Now
</a>
<a
className="flex h-12 w-full items-center justify-center rounded-full border border-solid border-black/[.08] px-5 transition-colors hover:border-transparent hover:bg-black/[.04] dark:border-white/[.145] dark:hover:bg-[#1a1a1a] md:w-[158px]"
href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
Documentation
</a>
</div>
<div className="mx-auto max-w-7xl px-6 py-10">
{/* KPI Card */}
<div className="mb-6">
<div className="inline-flex rounded-2xl bg-white p-6 shadow-md ring-1 ring-slate-200">
<div>
<p className="text-sm text-slate-500">{t(locale, "articles.count")}</p>
<p className="mt-1 text-3xl font-bold text-cyan-700">
{items.length}
</p>
</div>
</div>
</div>
</main>
</div>
{/* Main Card */}
<div className="overflow-hidden rounded-2xl bg-white shadow-lg ring-1 ring-slate-200">
<div className="border-b border-slate-200 px-6 py-4">
<h2 className="text-lg font-semibold text-slate-800">
{t(locale, "articles.heading")}
</h2>
</div>
{/* Error */}
{error && (
<div className="m-6 rounded-lg border border-red-200 bg-red-50 p-4 text-red-700">
{t(locale, "articles.error")}
</div>
)}
{/* Table */}
{items.length > 0 && (
<div className="overflow-x-auto">
<table className="w-full">
<thead>
<tr className="bg-slate-100">
<th className="px-6 py-4 text-left text-sm font-semibold text-slate-700">
{t(locale, "articles.code")}
</th>
<th className="px-6 py-4 text-left text-sm font-semibold text-slate-700">
{t(locale, "articles.descriptionColumn")}
</th>
</tr>
</thead>
<tbody>
{items.map((item) => (
<tr
key={item.ItemCode}
className="border-t border-slate-100 transition-colors hover:bg-cyan-50"
>
<td className="px-6 py-4 font-mono text-sm font-medium text-cyan-700">
{item.ItemCode}
</td>
<td className="px-6 py-4 text-slate-700">
{item.ItemName}
</td>
</tr>
))}
</tbody>
</table>
</div>
)}
{/* Empty State */}
{items.length === 0 && !error && (
<div className="py-20 text-center">
<div className="mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-slate-100">
📦
</div>
<h3 className="text-lg font-semibold text-slate-700">
{t(locale, "articles.emptyTitle")}
</h3>
<p className="mt-2 text-slate-500">
{t(locale, "articles.emptyDescription")}
</p>
</div>
)}
</div>
</div>
</main>
);
}
}