This commit is contained in:
Ivan Rezchikov
2026-07-11 21:20:57 +03:00
parent e192717466
commit 18161f4604
57 changed files with 1211 additions and 615 deletions
+75
View File
@@ -0,0 +1,75 @@
kind: pipeline
type: docker
name: default
steps:
- name: lint frontend
image: node:20-alpine
commands:
- npm install
- npm run lint
- name: build and push frontend
image: docker:24
volumes:
- name: dockersock
path: /var/run/docker.sock
commands:
- docker build
-t localhost:5000/eu:latest
-f ./Dockerfile
eu
- docker push localhost:5000/eu:latest
- name: deploy
image: docker:24
volumes:
- name: dockersock
path: /var/run/docker.sock
- name: appdir
path: /opt/app
environment:
PUBLIC_URL:
from_secret: PUBLIC_URL
DATABASE_URL:
from_secret: DATABASE_URL
KOTOSOFT_ID_API_URL:
from_secret: KOTOSOFT_ID_API_URL
KOTOSOFT_CLIENT_ID:
from_secret: KOTOSOFT_CLIENT_ID
KOTOSOFT_CLIENT_SECRET:
from_secret: KOTOSOFT_CLIENT_SECRET
JWT_SECRET:
from_secret: JWT_SECRET
MINIO_URL:
from_secret: MINIO_URL
MINIO_ACCESS_KEY:
from_secret: MINIO_ACCESS_KEY
MINIO_SECRET_KEY:
from_secret: MINIO_SECRET_KEY
MINIO_PUBLIC_URL:
from_secret: MINIO_PUBLIC_URL
VIRTUAL_HOST:
from_secret: API_DOMAIN
LETSENCRYPT_HOST:
from_secret: API_DOMAIN
LETSENCRYPT_EMAIL:
from_secret: LETSENCRYPT_EMAIL
commands:
- apk add --no-cache docker-cli-compose
- cp docker-compose.yml /opt/app/docker-compose.yml
- cd /opt/app
- docker compose pull
- docker compose up -d --remove-orphans
volumes:
- name: dockersock
host:
path: /var/run/docker.sock
- name: appdir
host:
path: /opt/drone/eu
trigger:
branch:
- main
+19
View File
@@ -0,0 +1,19 @@
FROM node:20 AS builder
WORKDIR /app
COPY package.json package-lock.json* ./
RUN npm install --include=dev
COPY . .
RUN npm run build
FROM node:20 AS production
WORKDIR /app
COPY package.json package-lock.json* ./
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/public ./public
COPY --from=builder /app/messages ./messages
RUN npm prune --omit=dev
EXPOSE 80
CMD ["npm", "start", "--", "-p", "3000", "-H", "0.0.0.0"]
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD wget -q --spider http://localhost:3000/ || exit 1
+5 -3
View File
@@ -1,21 +1,23 @@
"use client";
import { useTransition } from "react";
import { Button } from "@/components/ui/button";
import { ArchiveIcon } from "lucide-react";
import { Spinner } from "@/components/ui/spinner";
import { archivePageAction } from "@/lib/pages/actions";
import { PageType } from "@/lib/pages/types";
import { useAction } from "@/hooks/useAction";
export function ArchiveButton({ pageId, slug, type }: { pageId: string, slug: string, type: PageType }) {
const [isPending, startTransition] = useTransition();
const { run, isPending } = useAction(archivePageAction, {
successMessage: "Page archived",
});
return (
<Button
variant="secondary"
size="icon-sm"
disabled={isPending}
onClick={() => startTransition(() => archivePageAction(pageId, slug, type))}
onClick={() => run(pageId, slug, type)}
>
{isPending ? <Spinner /> : <ArchiveIcon />}
</Button>
+10 -38
View File
@@ -1,14 +1,13 @@
"use client";
import { useRef, useState, useTransition } from "react";
import { useRef } from "react";
import { useRouter } from "next/navigation";
import { Button } from "@/components/ui/button";
import Editor, { EditorData } from "@/components/editor";
import { savePageAction } from "@/lib/pages/actions";
import { validatePage } from "@/lib/pages/validation";
import { Block, Page, PageMeta, PageType } from "@/lib/pages/types";
import { Loader2 } from "lucide-react";
import { toast } from "sonner";
import { Spinner } from "@/components/ui/spinner";
import { useAction } from "@/hooks/useAction";
type Props = {
page: Page | null;
@@ -18,8 +17,10 @@ type Props = {
export default function EditPageClient({ page, pageType, initialBlocks = [] }: Props) {
const router = useRouter();
const [isPending, startTransition] = useTransition();
const [fieldErrors, setFieldErrors] = useState<{ title?: string[]; slug?: string[] }>({});
const { run, isPending } = useAction(savePageAction, {
successMessage: "Page saved",
onSuccess: () => router.push(`/${pageType.toLowerCase()}/${dataRef.current.slug}`),
});
const dataRef = useRef<EditorData>({
title: page?.title ?? "",
@@ -31,9 +32,8 @@ export default function EditPageClient({ page, pageType, initialBlocks = [] }: P
});
function handleSave(status: "DRAFT" | "PUBLISHED") {
startTransition(async () => {
const data = dataRef.current;
const payload = {
run({
id: page?.id ?? null,
slug: data.slug || data.title.toLowerCase().replace(/\s+/g, "-"),
title: data.title,
@@ -41,37 +41,11 @@ export default function EditPageClient({ page, pageType, initialBlocks = [] }: P
status,
blocks: data.blocks,
meta: { location: data.location, tags: data.tags },
};
const parsed = validatePage(payload);
if (!parsed.success) {
const errors: { title?: string[]; slug?: string[] } = {};
for (const msg of parsed.errors) {
if (msg.toLowerCase().includes("title")) {
(errors.title ??= []).push(msg);
} else if (msg.toLowerCase().includes("slug")) {
(errors.slug ??= []).push(msg);
}
}
setFieldErrors(errors);
toast.error(parsed.errors.join(", "));
return;
}
setFieldErrors({});
try {
await savePageAction(payload);
toast.success("Page saved");
router.push(`/${pageType.toLowerCase()}/${data.slug}`);
} catch (e) {
toast.error(e instanceof Error ? e.message : "Failed to save page");
}
});
}
return (
<div className="flex flex-col p-16 gap-12">
<div className="flex flex-col p-4 md:p-16 gap-6 md:gap-12 mb-4 md:mb-0">
<div className="flex flex-row items-center justify-between">
<h1>Edit page</h1>
<div className="flex flex-row gap-3">
@@ -79,7 +53,7 @@ export default function EditPageClient({ page, pageType, initialBlocks = [] }: P
disabled={isPending}
onClick={() => handleSave("PUBLISHED")}
>
{isPending && <Loader2 size={14} className="animate-spin mr-1" />}
{isPending && <Spinner />}
Save
</Button>
</div>
@@ -88,10 +62,8 @@ export default function EditPageClient({ page, pageType, initialBlocks = [] }: P
page={page}
type={pageType}
initialBlocks={initialBlocks}
errors={fieldErrors}
onChange={(data) => {
dataRef.current = data;
setFieldErrors({});
}}
/>
</div>
-6
View File
@@ -1,5 +1,3 @@
import Header from "@/components/header";
import Footer from "@/components/footer";
import { getPageBySlug, getBlocksByPageId } from "@/lib/pages/repository";
import { getCurrentUser } from "@/lib/user";
import { redirect, notFound } from "next/navigation";
@@ -20,10 +18,6 @@ export default async function EditPage({ params }: { params: Promise<{ type: str
const blocks = page ? await getBlocksByPageId(page.id) : [];
return (
<>
<Header />
<EditPageClient page={page ?? null} pageType={pageType} initialBlocks={blocks} />
<Footer />
</>
);
}
+12 -16
View File
@@ -53,7 +53,7 @@ function BlockRenderer({ block }: { block: Block }) {
case "CALLOUT":
return (
<Alert className="w-max">
<Alert className="md:w-max">
<InfoIcon />
<AlertTitle>{b.title}</AlertTitle>
<AlertDescription>{b.text}</AlertDescription>
@@ -68,11 +68,11 @@ function BlockRenderer({ block }: { block: Block }) {
alt={b.caption || "Image"}
width={1200}
height={800}
className="rounded-md border max-w-200 h-auto object-contain"
className="w-full md:w-auto md:max-w-200 h-auto rounded-md border object-contain"
/>
{b.caption && (
<figcaption className="text-sm text-muted-foreground">
<figcaption className="text-xs md:text-sm text-muted-foreground">
{b.caption}
</figcaption>
)}
@@ -83,13 +83,13 @@ function BlockRenderer({ block }: { block: Block }) {
return b.style === "ORDERED" ? (
<div className="flex flex-col gap-2">
{b.items.map((item: string, index: number) => (
<p className="flex flex-row gap-1 items-center" key={index}><span className="text-muted-foreground">{index+1}.</span> {item}</p>
<p className="flex flex-row gap-2 md:items-center" key={index}><span className="text-muted-foreground">{index+1}.</span> {item}</p>
))}
</div>
) : (
<div className="flex flex-col gap-2">
{b.items.map((item: string, index: number) => (
<p className="flex flex-row gap-1 items-center" key={index}><DotIcon className="text-muted-foreground" /> {item}</p>
<div className="flex flex-row gap-0.5 md:gap-1 md:items-center" key={index}><div><DotIcon className="text-muted-foreground" /></div><p>{item}</p></div>
))}
</div>
);
@@ -124,7 +124,7 @@ function BlockRenderer({ block }: { block: Block }) {
case "LINK":
return <Link href={b.href} target="_blank">
<Button variant="secondary" className="w-max">{b.label}</Button>
<Button variant="secondary" className="max-w-full">{b.label}</Button>
</Link>
default:
@@ -166,11 +166,9 @@ export default async function Page({ params }: { params: Promise<{ type: string;
};
return (
<>
<Header />
<div className="flex flex-col p-16 gap-12">
<div className={cn("flex flex-col gap-4 justify-center", isNews && "items-center")}>
<div className="flex flex-row items-center gap-6">
<div className="flex flex-col p-4 md:p-16 gap-6 md:gap-12 mb-4 md:mb-0">
<div className={cn("flex flex-col gap-8 md:gap-4 justify-center", isNews && "md:items-center")}>
<div className="flex flex-col md:flex-row items-center gap-2 md:gap-6">
<h1>{page?.title}</h1>
{user?.isAdmin && (
<div className="flex flex-row gap-2 items-center">
@@ -178,11 +176,11 @@ export default async function Page({ params }: { params: Promise<{ type: string;
<Button variant="secondary" size="icon-sm"><PencilIcon /></Button>
</Link>
{!isArchived && <ArchiveButton pageId={page.id} slug={page.slug} type={page.type} />}
{!isArchived && <PinToggleButton label={page.title} pageId={page.id} isPinned={!!navlink} />}
{!isArchived && <PinToggleButton pageId={page.id} isPinned={!!navlink} />}
</div>
)}
</div>
<div className="flex flex-row gap-6 items-center">
<div className="flex flex-col md:flex-row gap-2 md:gap-6 md:items-center">
{meta.publishedAt && <p className="flex gap-1.5 items-center"><CalendarIcon size={16} />{meta.publishedAt}</p>}
{meta.updatedAt && <p className="flex gap-1.5 items-center"><CalendarIcon size={16} />Updated on {meta.updatedAt}</p>}
{meta.location && <p className="flex gap-1.5 items-center"><Globe2Icon size={16} />{meta.location}</p>}
@@ -192,7 +190,7 @@ export default async function Page({ params }: { params: Promise<{ type: string;
</div>
<div className="flex flex-col gap-6">
{isArchived && (
<Alert className="w-max">
<Alert className="md:w-max">
<InfoIcon />
<AlertTitle>This page is archived</AlertTitle>
<AlertDescription>It can be seen only by administrators. Make any edits to make it visible again.</AlertDescription>
@@ -203,7 +201,5 @@ export default async function Page({ params }: { params: Promise<{ type: string;
))}
</div>
</div>
<Footer />
</>
);
}
+7 -11
View File
@@ -1,22 +1,18 @@
"use client";
import { useTransition } from "react";
import { Button } from "@/components/ui/button";
import { PinIcon, PinOffIcon } from "lucide-react";
import { Spinner } from "@/components/ui/spinner";
import { pinPageAction, unpinPageAction } from "@/lib/navlinks/actions";
import { togglePinAction } from "@/lib/navlinks/actions";
import { useAction } from "@/hooks/useAction";
export function PinToggleButton({ label, pageId, isPinned }: { label: string; pageId: string; isPinned: boolean }) {
const [isPending, startTransition] = useTransition();
const handleClick = () => {
startTransition(() =>
isPinned ? unpinPageAction(pageId) : pinPageAction(pageId)
);
};
export function PinToggleButton({ pageId, isPinned }: { pageId: string; isPinned: boolean }) {
const { run, isPending } = useAction(togglePinAction, {
successMessage: isPinned ? "Page unpinned" : "Page pinned",
});
return (
<Button variant={isPinned ? "secondary" : "secondary"} size="icon-sm" disabled={isPending} onClick={handleClick}>
<Button variant="secondary" size="icon-sm" disabled={isPending} onClick={() => run(pageId, isPinned)}>
{isPending ? <Spinner /> : isPinned ? <PinOffIcon /> : <PinIcon />}
</Button>
);
+1 -1
View File
@@ -22,7 +22,7 @@ export function AccountMenu() {
const pathname = usePathname();
return (
<div className="flex flex-col w-56 gap-2 mx-16 shrink-0">
<div className="flex flex-col md:w-56 gap-2 md:mx-16 shrink-0">
{menuItems.map((item) => {
const Icon = item.icon;
const active = pathname === item.href;
+5 -2
View File
@@ -64,7 +64,7 @@ export function CitizenshipApplicationForm({ firstName, secondName, sex, birthDa
<FieldGroup>
<FieldSet>
<FieldLegend>Personal information</FieldLegend>
<Alert variant="warning">
<Alert className="mt-2" variant="warning">
<InfoIcon />
<AlertTitle>Important notice</AlertTitle>
<AlertDescription>
@@ -251,7 +251,7 @@ export function CitizenshipApplicationForm({ firstName, secondName, sex, birthDa
<FieldLegend>Additional information</FieldLegend>
<FieldDescription>Provide details required for your identity document.</FieldDescription>
<FieldGroup>
<div className="grid grid-cols-2 gap-4">
<div className="grid md:grid-cols-2 gap-4">
<Field data-invalid={!!errors.height?.length}>
<FieldLabel htmlFor="height">Height (in cm)</FieldLabel>
<Input
@@ -293,6 +293,8 @@ export function CitizenshipApplicationForm({ firstName, secondName, sex, birthDa
label="Profile"
description="Select a profile image to upload. The image should be taken on a neutral background."
error={errors.profile?.[0]}
previewClassName="aspect-4/5"
removeBg
/>
<ImageUploadField
id="signature"
@@ -300,6 +302,7 @@ export function CitizenshipApplicationForm({ firstName, secondName, sex, birthDa
label="Signature"
description="Select a signature to upload."
error={errors.signature?.[0]}
previewClassName="aspect-5/2"
/>
</FieldGroup>
</FieldSet>
@@ -1,9 +1,13 @@
"use client";
import { useState } from "react";
import { useRef, useState } from "react";
import { Field, FieldDescription, FieldError, FieldLabel } from "@/components/ui/field";
import { Input } from "@/components/ui/input";
import { Button } from "@/components/ui/button";
import { XIcon, ImageIcon } from "lucide-react";
import { cn } from "@/lib/utils";
import { removeBackground } from "@imgly/background-removal";
import { Spinner } from "@/components/ui/spinner";
type Props = {
id: string;
@@ -11,41 +15,74 @@ type Props = {
label: string;
description: string;
error?: string;
previewClassName?: string;
removeBg?: boolean;
};
export function ImageUploadField({ id, name, label, description, error }: Props) {
const MAX_SIZE = 5 * 1024 * 1024;
const ACCEPTED_TYPES = ["image/jpeg", "image/png", "image/webp"];
function formatFileSize(bytes: number): string {
return bytes < 1024 * 1024 ? `${Math.round(bytes / 1024)} KB` : `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
}
export function ImageUploadField({ id, name, label, description, error, previewClassName, removeBg }: Props) {
const inputRef = useRef<HTMLInputElement>(null);
const [previewUrl, setPreviewUrl] = useState<string | null>(null);
const [fileInfo, setFileInfo] = useState<{ name: string; size: number } | null>(null);
const [clientError, setClientError] = useState<string | null>(null);
const [isProcessing, setIsProcessing] = useState(false);
const MAX_SIZE = 5 * 1024 * 1024;
const ACCEPTED_TYPES = ["image/jpeg", "image/png", "image/webp"];
function handleChange(e: React.ChangeEvent<HTMLInputElement>) {
const file = e.target.files?.[0];
function reset() {
if (previewUrl) URL.revokeObjectURL(previewUrl);
if (!file) {
setPreviewUrl(null);
setClientError(null);
return;
setFileInfo(null);
if (inputRef.current) inputRef.current.value = "";
}
async function handleChange(e: React.ChangeEvent<HTMLInputElement>) {
const file = e.target.files?.[0];
if (!file) { reset(); setClientError(null); return; }
if (!ACCEPTED_TYPES.includes(file.type)) {
setClientError("Only JPEG, PNG, or WEBP images are allowed.");
setPreviewUrl(null);
e.target.value = "";
reset();
return;
}
if (file.size > MAX_SIZE) {
setClientError("Image must be smaller than 5MB.");
setPreviewUrl(null);
e.target.value = "";
reset();
return;
}
setClientError(null);
if (!removeBg) {
if (previewUrl) URL.revokeObjectURL(previewUrl);
setPreviewUrl(URL.createObjectURL(file));
setFileInfo({ name: file.name, size: file.size });
return;
}
setIsProcessing(true);
try {
const resultBlob = await removeBackground(file);
const processedFile = new File([resultBlob], file.name, { type: "image/png" });
const dt = new DataTransfer();
dt.items.add(processedFile);
if (inputRef.current) inputRef.current.files = dt.files;
if (previewUrl) URL.revokeObjectURL(previewUrl);
setPreviewUrl(URL.createObjectURL(processedFile));
setFileInfo({ name: processedFile.name, size: processedFile.size });
} catch {
if (previewUrl) URL.revokeObjectURL(previewUrl);
setPreviewUrl(URL.createObjectURL(file));
setFileInfo({ name: file.name, size: file.size });
} finally {
setIsProcessing(false);
}
}
const displayedError = clientError ?? error;
@@ -53,27 +90,47 @@ export function ImageUploadField({ id, name, label, description, error }: Props)
return (
<Field data-invalid={!!displayedError}>
<FieldLabel htmlFor={id}>{label}</FieldLabel>
<div className="flex items-center gap-4">
{previewUrl && (
<img
src={previewUrl}
alt=""
<div className="flex flex-col md:flex-row items-start gap-4">
<div
className={cn(
"w-16 h-16 rounded-md object-cover ring-1 ring-foreground/10 shrink-0"
"w-28 rounded-md border border-dashed border-foreground/15 bg-muted flex items-center justify-center overflow-hidden shrink-0",
previewClassName ?? "aspect-4/5"
)}
/>
>
{isProcessing ? (
<Spinner className="text-muted-foreground" />
) : previewUrl ? (
<img src={previewUrl} alt="" className="w-full h-full object-cover" />
) : (
<ImageIcon className="text-muted-foreground" size={24} />
)}
</div>
<div className="flex flex-col gap-1 flex-1 min-w-0">
<Input
ref={inputRef}
id={id}
name={name}
type="file"
accept="image/jpeg,image/png,image/webp"
aria-invalid={!!displayedError}
onChange={handleChange}
required
disabled={isProcessing}
required={!fileInfo}
/>
{fileInfo && (
<div className="flex items-center gap-2 text-sm text-muted-foreground w-full min-w-0">
<span className="flex-1 min-w-0 truncate">
{fileInfo.name} ({formatFileSize(fileInfo.size)})
</span>
<Button type="button" variant="ghost" size="icon" className="h-6 w-6" onClick={reset} disabled={isProcessing}>
<XIcon size={14} />
</Button>
</div>
)}
<FieldDescription className="mt-1">{description}</FieldDescription>
</div>
</div>
<FieldDescription>{description}</FieldDescription>
{displayedError && <FieldError>{displayedError}</FieldError>}
</Field>
);
+3 -9
View File
@@ -1,5 +1,3 @@
import Footer from "@/components/footer";
import Header from "@/components/header";
import { getCurrentUser } from "@/lib/user";
import { redirect } from "next/navigation";
import { AccountMenu } from "../../account-menu";
@@ -17,14 +15,12 @@ export default async function CitizenshipApplication() {
const regions = await prisma.region.findMany({ orderBy: { name: "asc" } });
return (
<>
<Header />
<div className="flex flex-row py-16 gap-8">
<div className="flex flex-col md:flex-row p-4 md:p-16 gap-8 md:gap-16 mb-4 md:mb-0">
<AccountMenu />
<div className="flex flex-col gap-8">
<div className="flex flex-col gap-8 w-full">
<div className="flex flex-col gap-6">
<h2>Citizenship application</h2>
<div className="w-96 flex flex-col gap-6">
<div className="max-w-96 w-full flex flex-col gap-6">
{!eligibility.eligible ? (
<Alert variant="warning">
<InfoIcon />
@@ -44,7 +40,5 @@ export default async function CitizenshipApplication() {
</div>
</div>
</div>
<Footer />
</>
);
}
+1 -3
View File
@@ -34,11 +34,9 @@ export async function HasCitizenship({ userId }: { userId: string }) {
}
return (
<div className="flex flex-col gap-8">
<div className="flex flex-col gap-6 md:gap-8">
<IdentityCard data={identityDocument} />
<div className="flex flex-col gap-2">
<RenunciationDialog citizenship={citizenship} />
</div>
</div>
);
}
+4 -4
View File
@@ -25,13 +25,13 @@ export async function NoCitizenship({ userId }: { userId: string }) {
</AlertDescription>
</Alert>
<div className="flex flex-col gap-3">
<div className="flex flex-row gap-3 w-max">
<div className="flex flex-col gap-3 w-full">
<div className="flex flex-col md:flex-row gap-3">
<Link href="/page/citizenship">
<Button variant="secondary">Learn more about citizenship</Button>
<Button variant="secondary" className="w-full">Learn more about citizenship</Button>
</Link>
<Link href="/account/citizenship/apply">
<Button>Apply for citizenship</Button>
<Button className="w-full">Apply for citizenship</Button>
</Link>
</div>
{applications.length > 0 && <ApplicationsDialog applications={applications} />}
+2 -8
View File
@@ -1,5 +1,3 @@
import Footer from "@/components/footer";
import Header from "@/components/header";
import { getCurrentUser } from "@/lib/user";
import { redirect } from "next/navigation";
import { AccountMenu } from "../account-menu";
@@ -17,12 +15,10 @@ export default async function Citizenship() {
const pendingCount = user.isAdmin ? await getPendingApplicationsCount() : 0
return (
<>
<Header />
<div className="flex flex-row py-16 gap-8">
<div className="flex flex-col md:flex-row p-4 md:p-16 gap-8 md:gap-16 mb-4 md:mb-0">
<AccountMenu />
<div className="flex flex-col gap-8 max-w-lg">
<div className="flex flex-col gap-6 w-min">
<div className="flex flex-col gap-6 md:w-min">
<h2>Citizenship</h2>
{citizenship ? <HasCitizenship userId={user.id} /> : <NoCitizenship userId={user.id} />}
@@ -40,7 +36,5 @@ export default async function Citizenship() {
</div>
</div>
</div>
<Footer />
</>
)
}
@@ -45,7 +45,7 @@ export function RenunciationDialog({ citizenship }: { citizenship: Citizenship }
<DialogClose asChild>
<Button variant="secondary">Cancel</Button>
</DialogClose>
<Button variant="destructive" disabled={isPending} onClick={() => run()}>
<Button disabled={isPending} onClick={() => run()}>
{isPending && <Spinner />}Renounce citizenship
</Button>
</DialogFooter>
@@ -7,6 +7,7 @@ import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, D
import { Separator } from "@/components/ui/separator";
import { Spinner } from "@/components/ui/spinner";
import { Textarea } from "@/components/ui/textarea";
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
import { approveApplication, rejectApplication } from "@/lib/citizenship/actions";
import { CitizenshipApplicationWithWarning } from "@/lib/citizenship/types";
import { formatDate } from "@/lib/utils";
@@ -22,7 +23,7 @@ export default function ApplicationCard({ application, onClose }: { application:
if (!application?.id) {
return (
<div className="w-sm flex items-center justify-center ring-1 ring-foreground/10 rounded-xl text-muted-foreground px-4">
<div className="max-w-sm w-full flex items-center justify-center ring-1 ring-foreground/10 rounded-xl text-muted-foreground px-4 py-1">
Click on a row to see the application
</div>
)
@@ -64,17 +65,13 @@ export default function ApplicationCard({ application, onClose }: { application:
<CardDescription>{application.applicationType === "PREVIOUS_CITIZENSHIP" ? "Previous citizenship application" : "Naturalization application"}</CardDescription>
</CardHeader>
<CardContent className="max-w-sm">
<div className="flex flex-row gap-2 mb-2">
<img
src={application.profileUrl}
alt="Profile"
className={"w-18 h-24 rounded-md object-cover ring-1 ring-foreground/10 shrink-0"}
/>
<img
src={application.signatureUrl}
alt="Profile"
className={"w-36 h-18 rounded-md object-cover ring-1 ring-foreground/10 shrink-0"}
/>
<div className="flex flex-row gap-3 mb-4">
<div className="w-20 aspect-4/5 rounded-md overflow-hidden ring-1 ring-foreground/10 shrink-0">
<img src={application.profileUrl} alt="Profile photo" className="w-full h-full object-cover" />
</div>
<div className="w-40 px-2 aspect-5/2 rounded-md overflow-hidden ring-1 ring-foreground/10 shrink-0 bg-white">
<img src={application.signatureUrl} alt="Signature" className="w-full h-full object-contain" />
</div>
</div>
<div className="flex flex-col gap-1">
<h4 className="mb-1">Personal information</h4>
@@ -110,7 +107,14 @@ export default function ApplicationCard({ application, onClose }: { application:
</div>
<div className="flex flex-col gap-0.5">
<p className="text-muted-foreground">Address</p>
<p className="truncate">{application.address}</p>
<Tooltip>
<TooltipTrigger>
<p className="text-start truncate">{application.address}</p>
</TooltipTrigger>
<TooltipContent>
<p>{application.address}</p>
</TooltipContent>
</Tooltip>
</div>
<div className="flex flex-row gap-4 items-center">
<p className="text-muted-foreground">Height</p>
@@ -169,7 +173,7 @@ export default function ApplicationCard({ application, onClose }: { application:
/>
<DialogFooter>
<Button variant="outline" onClick={() => setRejectOpen(false)}>Cancel</Button>
<Button variant="destructive" onClick={handleReject} disabled={!reason.trim() || isloading}>
<Button onClick={handleReject} disabled={!reason.trim() || isloading}>
{isloading && <Spinner />}Confirm rejection
</Button>
</DialogFooter>
+1 -1
View File
@@ -12,7 +12,7 @@ export default function ReviewPageClient({ applications }: { applications: Citiz
return (
<>
<div className="flex flex-row gap-16">
<div className="flex flex-col-reverse md:flex-row gap-8 md:gap-16">
<div className="flex flex-col gap-8">
<div className="flex flex-col gap-6">
<h2>Review citizenship applications</h2>
+1 -7
View File
@@ -1,5 +1,3 @@
import Header from "@/components/header";
import Footer from "@/components/footer";
import ReviewPageClient from "./client";
import { getCurrentUser } from "@/lib/user";
import { redirect } from "next/navigation";
@@ -29,13 +27,9 @@ export default async function ReviewPage() {
);
return (
<>
<Header />
<div className="flex flex-row py-16 gap-8">
<div className="flex flex-col md:flex-row p-4 md:p-16 gap-8 md:gap-16 mb-4 md:mb-0">
<AccountMenu />
<ReviewPageClient applications={applicationsWithWarning} />
</div>
<Footer />
</>
);
}
+4 -11
View File
@@ -1,9 +1,6 @@
import Footer from "@/components/footer";
import Header from "@/components/header";
import { Separator } from "@/components/ui/separator";
import { getCurrentUser } from "@/lib/user";
import { formatDate } from "@/lib/utils";
import { BookOpenTextIcon, SignatureIcon, UserIcon } from "lucide-react";
import { redirect } from "next/navigation";
import { DeleteDialog } from "./delete-dialog";
import { LogoutButton } from "./logout-button";
@@ -24,9 +21,7 @@ export default async function Account() {
if (!user) redirect("/");
return (
<>
<Header />
<div className="flex flex-row py-16 gap-8">
<div className="flex flex-col md:flex-row p-4 md:p-16 gap-8 md:gap-16 mb-4 md:mb-0">
<AccountMenu />
<div className="flex flex-col gap-8 max-w-lg">
<div className="flex flex-col gap-6">
@@ -44,14 +39,14 @@ export default async function Account() {
{user.isAdmin && <ProfileField label="Role" value="Administrator" />}
</div>
<Separator />
<div className="flex flex-row items-center justify-between">
<div className="flex flex-row items-center justify-between gap-2">
<div className="flex flex-col">
<h4>Update personal details</h4>
<p className="text-muted-foreground">Syncs your name, email, and birthday from Kotosoft ID</p>
</div>
<UpdateButton />
</div>
<div className="flex flex-row items-center justify-between">
<div className="flex flex-row items-center justify-between gap-2">
<div className="flex flex-col">
<h4>Log out</h4>
<p className="text-muted-foreground">Log out from your account on this device</p>
@@ -59,7 +54,7 @@ export default async function Account() {
<LogoutButton />
</div>
<Separator />
<div className="flex flex-row items-center justify-between">
<div className="flex flex-row items-center justify-between gap-2">
<div className="flex flex-col">
<h4>Delete account</h4>
<p className="text-muted-foreground">Permanently delete your account and all associated data</p>
@@ -69,7 +64,5 @@ export default async function Account() {
</div>
</div>
</div>
<Footer />
</>
);
}
+12 -39
View File
@@ -1,18 +1,20 @@
"use client";
import { useRef, useState, useTransition } from "react";
import { useRef } from "react";
import { useRouter } from "next/navigation";
import { Button } from "@/components/ui/button";
import Editor, { EditorData } from "@/components/editor";
import { savePageAction } from "@/lib/pages/actions";
import { validatePage } from "@/lib/pages/validation";
import { Loader2 } from "lucide-react";
import { toast } from "sonner";
import { Spinner } from "@/components/ui/spinner";
import { useAction } from "@/hooks/useAction";
export default function CreatePageClient() {
const router = useRouter();
const [isPending, startTransition] = useTransition();
const [fieldErrors, setFieldErrors] = useState<{ title?: string[]; slug?: string[] }>({});
const { run, isPending } = useAction(savePageAction, {
successMessage: "Page saved",
onSuccess: () => router.push("/news"),
});
const dataRef = useRef<EditorData>({
title: "",
type: "NEWS",
@@ -23,9 +25,8 @@ export default function CreatePageClient() {
});
function handleSave(status: "DRAFT" | "PUBLISHED") {
startTransition(async () => {
const data = dataRef.current;
const payload = {
run({
id: null,
slug: data.slug || data.title.toLowerCase().replace(/\s+/g, "-"),
title: data.title,
@@ -33,37 +34,11 @@ export default function CreatePageClient() {
status,
blocks: data.blocks,
meta: { location: data.location, tags: data.tags },
};
const parsed = validatePage(payload);
if (!parsed.success) {
const errors: { title?: string[]; slug?: string[] } = {};
for (const msg of parsed.errors) {
if (msg.toLowerCase().includes("title")) {
(errors.title ??= []).push(msg);
} else if (msg.toLowerCase().includes("slug")) {
(errors.slug ??= []).push(msg);
}
}
setFieldErrors(errors);
toast.error(parsed.errors.join(", "));
return;
}
setFieldErrors({});
try {
await savePageAction(payload);
toast.success("Page saved");
router.push("/news");
} catch (e) {
toast.error(e instanceof Error ? e.message : "Failed to save page");
}
});
}
return (
<div className="flex flex-col p-16 gap-12">
<div className="flex flex-col p-4 md:p-16 gap-6 md:gap-12 mb-4 md:mb-0">
<div className="flex flex-row items-center justify-between">
<h1>Create page</h1>
<div className="flex flex-row gap-3">
@@ -72,11 +47,11 @@ export default function CreatePageClient() {
disabled={isPending}
onClick={() => handleSave("DRAFT")}
>
{isPending && <Loader2 size={14} className="animate-spin mr-1" />}
{isPending && <Spinner />}
Save as draft
</Button>
<Button disabled={isPending} onClick={() => handleSave("PUBLISHED")}>
{isPending && <Loader2 size={14} className="animate-spin mr-1" />}
{isPending && <Spinner />}
Publish
</Button>
</div>
@@ -84,9 +59,7 @@ export default function CreatePageClient() {
<Editor
onChange={(data) => {
dataRef.current = data;
setFieldErrors({});
}}
errors={fieldErrors}
/>
</div>
);
-6
View File
@@ -1,5 +1,3 @@
import Header from "@/components/header";
import Footer from "@/components/footer";
import { getCurrentUser } from "@/lib/user";
import { redirect } from "next/navigation";
import CreatePageClient from "./client";
@@ -9,10 +7,6 @@ export default async function CreatePage() {
if (!user?.isAdmin) redirect("/");
return (
<>
<Header />
<CreatePageClient />
<Footer />
</>
);
}
+16
View File
@@ -0,0 +1,16 @@
"use client"
import { Button } from "@/components/ui/button";
import Link from "next/link";
export default function NotFound() {
return (
<div className="flex flex-col items-center justify-center w-full h-full p-4 md:p-16 gap-8 md:gap-16 mb-4 md:mb-0">
<div className="flex flex-col gap-4">
<h1>Oops...</h1>
<h2>Something went wrong!</h2>
</div>
<Link href="/"><Button>Go back to main page</Button></Link>
</div>
)
}
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

+35 -10
View File
@@ -4,6 +4,16 @@
@custom-variant dark (&:is(.dark *));
@theme {
--text-xs--line-height: 1.5;
--text-sm--line-height: 1.45;
--text-base--line-height: 1.5;
--text-lg--line-height: 1.4;
--text-xl--line-height: 1.35;
--text-2xl--line-height: 1.3;
--text-3xl--line-height: 1.25;
}
@theme inline {
--color-background: var(--background);
--color-foreground: var(--foreground);
@@ -133,29 +143,44 @@
}
h1 {
@apply text-3xl tracking-tight underline underline-offset-8 decoration-2
font-size: clamp(1.5rem, 1.3446rem + 0.663vw, 1.875rem);
line-height: 1.15;
letter-spacing: -0.03em;
@apply underline underline-offset-4 sm:underline-offset-8 decoration-2;
}
h2 {
@apply text-2xl tracking-tight
font-size: clamp(1.25rem, 1.1464rem + 0.442vw, 1.5rem);
line-height: 1.2;
letter-spacing: -0.025em;
}
h3 {
@apply text-xl tracking-tight
font-size: clamp(1.125rem, 1.0732rem + 0.221vw, 1.25rem);
line-height: 1.3;
letter-spacing: -0.02em;
}
h4 {
@apply text-lg tracking-tight
}
p {
@apply text-base tracking-tight
font-size: clamp(1rem, 0.9482rem + 0.221vw, 1.125rem);
line-height: 1.35;
letter-spacing: -0.02em;
}
h5 {
@apply text-sm tracking-tight
font-size: clamp(0.875rem, 0.6982rem + 0.221vw, 0.875rem);
line-height: 1.4;
letter-spacing: -0.015em;
}
h6 {
@apply text-xs tracking-tight
font-size: clamp(0.6875rem, 0.6616rem + 0.111vw, 0.75rem);
line-height: 1.4;
letter-spacing: -0.01em;
}
p {
font-size: 1rem;
line-height: 1.5;
letter-spacing: -0.011em;
}
+8 -1
View File
@@ -3,6 +3,9 @@ import localFont from "next/font/local"
import "./globals.css";
import { cn } from "@/lib/utils";
import { Toaster } from "@/components/ui/sonner";
import { TooltipProvider } from "@/components/ui/tooltip";
import Header from "@/components/header";
import Footer from "@/components/footer";
const helvetica = localFont({
src: "../public/fonts/HelveticaNeue-Medium.otf",
@@ -25,7 +28,11 @@ export default function RootLayout({
className={cn("h-full", "antialiased", helvetica.className, "font-sans")}
>
<body className="min-h-full flex flex-col">
{children}
<TooltipProvider>
<Header />
<div className="flex-1">{children}</div>
<Footer />
</TooltipProvider>
<Toaster />
</body>
</html>
+2 -8
View File
@@ -1,6 +1,4 @@
import DraftsDialog from "@/components/drafts-dialog";
import Footer from "@/components/footer";
import Header from "@/components/header";
import { NewsCard } from "@/components/news-card";
import { Button } from "@/components/ui/button";
import { getPages } from "@/lib/pages/repository";
@@ -17,10 +15,8 @@ export default async function News() {
const drafts = [...newsDrafts, ...pageDrafts];
return (
<>
<Header />
<div className="flex flex-col p-16 gap-16">
<div className="flex flex-row items-center justify-between">
<div className="flex flex-col p-4 md:p-16 gap-8 md:gap-16 mb-4 md:mb-0">
<div className="flex flex-col gap-4 md:flex-row md:items-center justify-between">
<h1>News</h1>
<div className="flex flex-row items-center gap-4">
{user?.isAdmin && (
@@ -39,7 +35,5 @@ export default async function News() {
}
</div>
</div>
<Footer />
</>
);
}
+14
View File
@@ -0,0 +1,14 @@
import { Button } from "@/components/ui/button";
import Link from "next/link";
export default function NotFound() {
return (
<div className="flex flex-col items-center justify-center w-full h-full p-4 md:p-16 gap-8 md:gap-16 mb-4 md:mb-0">
<div className="flex flex-col gap-4">
<h1>Oops...</h1>
<h2>Could not find requested resource!</h2>
</div>
<Link href="/"><Button>Go back to main page</Button></Link>
</div>
)
}
+49 -14
View File
@@ -1,5 +1,3 @@
import Footer from "@/components/footer";
import Header from "@/components/header";
import { NewsCard } from "@/components/news-card";
import { getPages } from "@/lib/pages/repository";
import { ArrowRightIcon } from "lucide-react";
@@ -9,36 +7,75 @@ export default async function Home() {
const news = await getPages("NEWS", "PUBLISHED", 5);
return (
<>
<Header />
<div className="flex flex-col p-16 gap-16">
<div className="flex flex-col p-4 md:p-16 gap-8 md:gap-16 mb-4 md:mb-0">
<h1>Welcome to the European Federation!</h1>
<div className="grid grid-cols-[2fr_1fr_1fr_1fr] gap-8">
<div className="grid grid-cols-2 gap-4 md:hidden">
<Link href="/page/citizenship" className="col-span-2">
<div className="flex items-end h-64 p-4 rounded-lg bg-primary text-primary-foreground">
<h1 className="flex flex-row items-center gap-2 hover:gap-4 hover:duration-200 cursor-pointer">
Become a citizen<ArrowRightIcon size={30} />
</h1>
</div>
</Link>
<Link href="/page/president">
<div className="flex items-end h-28 p-2.5 rounded-lg bg-muted">
<h2 className="flex flex-row items-center gap-2 hover:gap-4 hover:duration-200 cursor-pointer">
Learn more about the President
</h2>
</div>
</Link>
<div className="flex items-end h-28 p-2.5 rounded-lg bg-muted">
<h2 className="flex flex-row items-center gap-2 hover:gap-4 hover:duration-200 cursor-pointer">
Acknowledge with the Federal Government
</h2>
</div>
<div className="flex items-end h-28 p-2.5 rounded-lg bg-muted">
<h2 className="flex flex-row items-center gap-2 hover:gap-4 hover:duration-200 cursor-pointer">
Regions of the Federation
</h2>
</div>
<div className="flex items-end h-28 p-2.5 rounded-lg bg-muted">
<h2 className="flex flex-row items-center gap-2 hover:gap-4 hover:duration-200 cursor-pointer">
Receive consular services abroad
</h2>
</div>
</div>
<div className="hidden md:grid grid-cols-[2fr_1fr_1fr_1fr] gap-8">
<Link href="/page/citizenship">
<div className="flex items-end h-64 p-4 rounded-lg bg-primary text-primary-foreground">
<h1 className="flex flex-row items-center gap-2 hover:gap-4 hover:duration-200 cursor-pointer">Become a citizen<ArrowRightIcon size={30} /></h1>
<h1 className="flex flex-row items-center gap-2 hover:gap-4 hover:duration-200 cursor-pointer">
Become a citizen<ArrowRightIcon size={30} />
</h1>
</div>
</Link>
<div className="grid grid-rows-2 gap-8">
<Link href="/page/president">
<div className="flex items-end h-28 p-2.5 rounded-lg bg-muted">
<h2 className="flex flex-row items-center gap-2 hover:gap-4 hover:duration-200 cursor-pointer">Learn more about the President</h2>
<h2 className="flex flex-row items-center gap-2 hover:gap-4 hover:duration-200 cursor-pointer">
Learn more about the President
</h2>
</div>
</Link>
<div className="flex items-end h-28 p-2.5 rounded-lg bg-muted">
<h2 className="flex flex-row items-center gap-2 hover:gap-4 hover:duration-200 cursor-pointer">Acknowledge with the Federal Government</h2>
<h2 className="flex flex-row items-center gap-2 hover:gap-4 hover:duration-200 cursor-pointer">
Acknowledge with the Federal Government
</h2>
</div>
</div>
<div className="grid grid-rows-2 gap-8">
<div className="flex items-end h-28 p-2.5 rounded-lg bg-muted">
<h2 className="flex flex-row items-center gap-2 hover:gap-4 hover:duration-200 cursor-pointer">Regions of the Federation</h2>
<h2 className="flex flex-row items-center gap-2 hover:gap-4 hover:duration-200 cursor-pointer">
Regions of the Federation
</h2>
</div>
<div className="flex items-end h-28 p-2.5 rounded-lg bg-muted">
<h2 className="flex flex-row items-center gap-2 hover:gap-4 hover:duration-200 cursor-pointer">Receive consular services abroad</h2>
<h2 className="flex flex-row items-center gap-2 hover:gap-4 hover:duration-200 cursor-pointer">
Receive consular services abroad
</h2>
</div>
</div>
</div>
<div className="flex flex-col gap-8 mt-8">
<div className="flex flex-col gap-8 mt-4 lg:mt-8">
<h1>Recent news</h1>
<div className="flex flex-col gap-6">
{
@@ -50,7 +87,5 @@ export default async function Home() {
<Link href="/news"><h3 className="w-max flex flex-row items-center gap-2 hover:gap-2.5 hover:duration-200 cursor-pointer">See all news<ArrowRightIcon size={20} /></h3></Link>
</div>
</div>
<Footer />
</>
);
}
+46
View File
@@ -5,6 +5,7 @@
"": {
"name": "e-id",
"dependencies": {
"@imgly/background-removal": "^1.7.0",
"@prisma/adapter-pg": "^7.8.0",
"@prisma/client": "^7.8.0",
"@tanstack/react-table": "^8.21.3",
@@ -42,7 +43,10 @@
},
"trustedDependencies": [
"sharp",
"@prisma/engines",
"prisma",
"unrs-resolver",
"protobufjs",
],
"packages": {
"@alloc/quick-lru": ["@alloc/[email protected]", "", {}, "sha512-UrcABB+4bUrFABwbluTIBErXwvbsU/V7TZWfmbgJfbkwiBuziS9gxdODUyuiecfdGQ85jglMW6juS3+z5TsKLw=="],
@@ -211,6 +215,8 @@
"@img/sharp-win32-x64": ["@img/[email protected]", "", { "os": "win32", "cpu": "x64" }, "sha512-D4y1vNeZrIIJCN+uHaWVtH86B+aCrdMYYjicy9pXHvbGZeGYLLSd3wdVuC37FxVXlU1ARsk84eKWfWMXGYEqvA=="],
"@imgly/background-removal": ["@imgly/[email protected]", "", { "dependencies": { "lodash-es": "^4.17.21", "ndarray": "~1.0.0", "zod": "^3.23.8" }, "peerDependencies": { "onnxruntime-web": "1.21.0" } }, "sha512-/1ZryrMYg2ckIvJKoTu5Np50JfYMVffDMlVmppw/BdbN3pBTN7e6stI5/7E/LVh9DDzz6J588s7sWqul3fy5wA=="],
"@jridgewell/gen-mapping": ["@jridgewell/[email protected]", "", { "dependencies": { "@jridgewell/sourcemap-codec": "^1.5.0", "@jridgewell/trace-mapping": "^0.3.24" } }, "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA=="],
"@jridgewell/remapping": ["@jridgewell/[email protected]", "", { "dependencies": { "@jridgewell/gen-mapping": "^0.3.5", "@jridgewell/trace-mapping": "^0.3.24" } }, "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ=="],
@@ -291,6 +297,24 @@
"@prisma/studio-core": ["@prisma/[email protected]", "", { "dependencies": { "@radix-ui/react-toggle": "1.1.10", "chart.js": "4.5.1" }, "peerDependencies": { "@types/react": "^18.0.0 || ^19.0.0", "react": "^18.0.0 || ^19.0.0", "react-dom": "^18.0.0 || ^19.0.0" } }, "sha512-AADjNFPdsrglxHQVTmHFqv6DuKQZ5WY4p5/gVFY017twvNrSwpLJ9lqUbYYxEu2W7nbvVxTZA8deJ8LseNALsw=="],
"@protobufjs/aspromise": ["@protobufjs/[email protected]", "", {}, "sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ=="],
"@protobufjs/base64": ["@protobufjs/[email protected]", "", {}, "sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg=="],
"@protobufjs/codegen": ["@protobufjs/[email protected]", "", {}, "sha512-zgXFLzW3Ap33e6d0Wlj4MGIm6Ce8O89n/apUaGNB/jx+hw+ruWEp7EwGUshdLKVRCxZW12fp9r40E1mQrf/34g=="],
"@protobufjs/eventemitter": ["@protobufjs/[email protected]", "", {}, "sha512-vW1GmwMZNnL+gMRaovlh9yZX74kc+TTU3FObkkurpMaRtBfLP3ldjS9KQWlwZgraRE0+dheEEoAxdzcJQ8eXZg=="],
"@protobufjs/fetch": ["@protobufjs/[email protected]", "", { "dependencies": { "@protobufjs/aspromise": "^1.1.1" } }, "sha512-GpptLrs57adMSuHi3VNj0mAF8dwh36LMaYF6XyJ6JMWlVsc+t42tm1HSEDmOs3A8fC9yyeisgLhsTVQokOZ0zw=="],
"@protobufjs/float": ["@protobufjs/[email protected]", "", {}, "sha512-Ddb+kVXlXst9d+R9PfTIxh1EdNkgoRe5tOX6t01f1lYWOvJnSPDBlG241QLzcyPdoNTsblLUdujGSE4RzrTZGQ=="],
"@protobufjs/path": ["@protobufjs/[email protected]", "", {}, "sha512-6JOcJ5Tm08dOHAbdR3GrvP+yUUfkjG5ePsHYczMFLq3ZmMkAD98cDgcT2iA1lJ9NVwFd4tH/iSSoe44YWkltEA=="],
"@protobufjs/pool": ["@protobufjs/[email protected]", "", {}, "sha512-0kELaGSIDBKvcgS4zkjz1PeddatrjYcmMWOlAuAPwAeccUrPHdUqo/J6LiymHHEiJT5NrF1UVwxY14f+fy4WQw=="],
"@protobufjs/utf8": ["@protobufjs/[email protected]", "", {}, "sha512-oOAWABowe8EAbMyWKM0tYDKi8Yaox52D+HWZhAIJqQXbqe0xI/GV7FhLWqlEKreMkfDjshR5FKgi3mnle0h6Eg=="],
"@radix-ui/number": ["@radix-ui/[email protected]", "", {}, "sha512-ceTwaxc4I5IOi97DgCotl3pqiyRGvffcc0oOsE2dQYaJOFIDsDt4VWG6xEbg1QePv9QWausCEIppud/tJ1wNig=="],
"@radix-ui/primitive": ["@radix-ui/[email protected]", "", {}, "sha512-7AdCK9PQyiljKoBDbN8OuctCbd/esdwZPQ8RtOE3SsyQtUpiPb+ND75q0jEhC1m1ecBI0MFNeLJvwIh9iKHRcQ=="],
@@ -873,6 +897,8 @@
"flat-cache": ["[email protected]", "", { "dependencies": { "flatted": "^3.2.9", "keyv": "^4.5.4" } }, "sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw=="],
"flatbuffers": ["[email protected]", "", {}, "sha512-MI1qs7Lo4Syw0EOzUl0xjs2lsoeqFku44KpngfIduHBYvzm8h2+7K8YMQh1JtVVVrUvhLpNwqVi4DERegUJhPQ=="],
"flatted": ["[email protected]", "", {}, "sha512-PjDse7RzhcPkIJwy5t7KPWQSZ9cAbzQXcafsetQoD7sOJRQlGikNbx7yZp2OotDnJyrDcbyRq3Ttb18iYOqkxA=="],
"for-each": ["[email protected]", "", { "dependencies": { "is-callable": "^1.2.7" } }, "sha512-dKx12eRCVIzqCxFGplyFKJMPvLEWgmNtUrpTiJIR5u97zEhRG8ySrtboPHZXx7daLxQVrl643cTzbab2tkQjxg=="],
@@ -935,6 +961,8 @@
"graphmatch": ["[email protected]", "", {}, "sha512-5ykVn/EXM1hF0XCaWh05VbYvEiOL2lY1kBxZtaYsyvjp7cmWOU1XsAdfQBwClraEofXDT197lFbXOEVMHpvQOg=="],
"guid-typescript": ["[email protected]", "", {}, "sha512-Y8T4vYhEfwJOTbouREvG+3XDsjr8E3kIr7uf+JZ0BYloFsttiHU0WfvANVsR7TxNUJa/WpCnw/Ino/p+DeBhBQ=="],
"has-bigints": ["[email protected]", "", {}, "sha512-R3pbpkcIqv2Pm3dUwgjclDRVmWpTJW2DcMzcIhEXEx1oh/CEMObMm3KLmRJOdvhM7o4uQBnwr8pzRK2sJWIqfg=="],
"has-flag": ["[email protected]", "", {}, "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ=="],
@@ -975,6 +1003,8 @@
"internal-slot": ["[email protected]", "", { "dependencies": { "es-errors": "^1.3.0", "hasown": "^2.0.2", "side-channel": "^1.1.0" } }, "sha512-4gd7VpWNQNB4UKKCFFVcp1AVv+FMOgs9NKzjHKusc8jTMhd5eL1NqQqOpE0KzMds804/yHlglp3uxgluOqAPLw=="],
"iota-array": ["[email protected]", "", {}, "sha512-pZ2xT+LOHckCatGQ3DcG/a+QuEqvoxqkiL7tvE8nn3uuu+f6i1TtpB5/FtWFbxUuVr5PZCx8KskuGatbJDXOWA=="],
"ip-address": ["[email protected]", "", {}, "sha512-/+S6j4E9AHvW9SWMSEY9Xfy66O5PWvVEJ08O0y5JGyEKQpojb0K0GKpz/v5HJ/G0vi3D2sjGK78119oXZeE0qA=="],
"ipaddr.js": ["[email protected]", "", {}, "sha512-9VGk3HGanVE6JoZXHiCpnGy5X0jYDnN4EA4lntFPj+1vIWlFhIylq2CrrCOJH9EAhc5CYhq18F2Av2tgoAPsYQ=="],
@@ -989,6 +1019,8 @@
"is-boolean-object": ["[email protected]", "", { "dependencies": { "call-bound": "^1.0.3", "has-tostringtag": "^1.0.2" } }, "sha512-wa56o2/ElJMYqjCjGkXri7it5FbebW5usLw/nPmCMs5DeZ7eziSYZhSmPRn0txqeW4LnAmQQU7FgqLpsEFKM4A=="],
"is-buffer": ["[email protected]", "", {}, "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w=="],
"is-bun-module": ["[email protected]", "", { "dependencies": { "semver": "^7.7.1" } }, "sha512-gNCGbnnnnFAUGKeZ9PdbyeGYJqewpmc2aKHUEMO5nQPWU9lOmv7jcmQIv+qHD8fXW6W7qfuCwX4rY9LNRjXrkQ=="],
"is-callable": ["[email protected]", "", {}, "sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA=="],
@@ -1133,6 +1165,8 @@
"lodash": ["[email protected]", "", {}, "sha512-dMInicTPVE8d1e5otfwmmjlxkZoUpiVLwyeTdUsi/Caj/gfzzblBcCE5sRHV/AsjuCmxWrte2TNGSYuCeCq+0Q=="],
"lodash-es": ["[email protected]", "", {}, "sha512-J8xewKD/Gk22OZbhpOVSwcs60zhd95ESDwezOFuA3/099925PdHJ7OFHNTGtajL3AlZkykD32HykiMo+BIBI8A=="],
"lodash.merge": ["[email protected]", "", {}, "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ=="],
"log-symbols": ["[email protected]", "", { "dependencies": { "chalk": "^5.3.0", "is-unicode-supported": "^1.3.0" } }, "sha512-i24m8rpwhmPIS4zscNzK6MSEhk0DUWa/8iYQWxhffV8jkI4Phvs3F+quL5xvS0gdQR0FyTCMMH33Y78dDTzzIw=="],
@@ -1187,6 +1221,8 @@
"natural-compare": ["[email protected]", "", {}, "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw=="],
"ndarray": ["[email protected]", "", { "dependencies": { "iota-array": "^1.0.0", "is-buffer": "^1.0.2" } }, "sha512-B4JHA4vdyZU30ELBw3g7/p9bZupyew5a7tX1Y/gGeF2hafrPaQZhgrGQfsvgfYbgdFZjYwuEcnaobeM/WMW+HQ=="],
"negotiator": ["[email protected]", "", {}, "sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg=="],
"next": ["[email protected]", "", { "dependencies": { "@next/env": "16.2.9", "@swc/helpers": "0.5.15", "baseline-browser-mapping": "^2.9.19", "caniuse-lite": "^1.0.30001579", "postcss": "8.4.31", "styled-jsx": "5.1.6" }, "optionalDependencies": { "@next/swc-darwin-arm64": "16.2.9", "@next/swc-darwin-x64": "16.2.9", "@next/swc-linux-arm64-gnu": "16.2.9", "@next/swc-linux-arm64-musl": "16.2.9", "@next/swc-linux-x64-gnu": "16.2.9", "@next/swc-linux-x64-musl": "16.2.9", "@next/swc-win32-arm64-msvc": "16.2.9", "@next/swc-win32-x64-msvc": "16.2.9", "sharp": "^0.34.5" }, "peerDependencies": { "@opentelemetry/api": "^1.1.0", "@playwright/test": "^1.51.1", "babel-plugin-react-compiler": "*", "react": "^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ^19.0.0", "react-dom": "^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ^19.0.0", "sass": "^1.3.0" }, "optionalPeers": ["@opentelemetry/api", "@playwright/test", "babel-plugin-react-compiler", "sass"], "bin": { "next": "dist/bin/next" } }, "sha512-MEOJiq/UvuezAdqVSceHbqDgZt1kDw2tpGVOlsdIoJsQdbN2JY2hpVG4xnXGkbdJUOEWhnRfiu/O4Hpc9Juwww=="],
@@ -1227,6 +1263,10 @@
"onetime": ["[email protected]", "", { "dependencies": { "mimic-fn": "^2.1.0" } }, "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg=="],
"onnxruntime-common": ["[email protected]", "", {}, "sha512-Q632iLLrtCAVOTO65dh2+mNbQir/QNTVBG3h/QdZBpns7mZ0RYbLRBgGABPbpU9351AgYy7SJf1WaeVwMrBFPQ=="],
"onnxruntime-web": ["[email protected]", "", { "dependencies": { "flatbuffers": "^25.1.24", "guid-typescript": "^1.0.9", "long": "^5.2.3", "onnxruntime-common": "1.21.0", "platform": "^1.3.6", "protobufjs": "^7.2.4" } }, "sha512-adzOe+7uI7lKz6pQNbAsLMQd2Fq5Jhmoxd8LZjJr8m3KvbFyiYyRxRiC57/XXD+jb18voppjeGAjoZmskXG+7A=="],
"open": ["[email protected]", "", { "dependencies": { "default-browser": "^5.4.0", "define-lazy-prop": "^3.0.0", "is-in-ssh": "^1.0.0", "is-inside-container": "^1.0.0", "powershell-utils": "^0.1.0", "wsl-utils": "^0.3.0" } }, "sha512-smsWv2LzFjP03xmvFoJ331ss6h+jixfA4UUV/Bsiyuu4YJPfN+FIQGOIiv4w9/+MoHkfkJ22UIaQWRVFRfH6Vw=="],
"optionator": ["[email protected]", "", { "dependencies": { "deep-is": "^0.1.3", "fast-levenshtein": "^2.0.6", "levn": "^0.4.1", "prelude-ls": "^1.2.1", "type-check": "^0.4.0", "word-wrap": "^1.2.5" } }, "sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g=="],
@@ -1291,6 +1331,8 @@
"pkg-up": ["[email protected]", "", { "dependencies": { "find-up": "^3.0.0" } }, "sha512-nDywThFk1i4BQK4twPQ6TA4RT8bDY96yeuCVBWL3ePARCiEKDRSrNGbFIgUJpLp+XeIR65v8ra7WuJOFUBtkMA=="],
"platform": ["[email protected]", "", {}, "sha512-fnWVljUchTro6RiCFvCXBbNhJc2NijN7oIQxbwsyL0buWJPG85v81ehlHI9fXrJsMNgTofEoWIQeClKpgxFLrg=="],
"possible-typed-array-names": ["[email protected]", "", {}, "sha512-/+5VFTchJDoVj3bhoqi6UeymcD00DAwb1nJwamzPvHEszJ4FpF6SNNbUbOS8yI56qHzdV8eK0qEfOSiodkTdxg=="],
"postcss": ["[email protected]", "", { "dependencies": { "nanoid": "^3.3.12", "picocolors": "^1.1.1", "source-map-js": "^1.2.1" } }, "sha512-FfR8sjd4em2T6fb3I2MwAJU7HWVMr9zba+enmQeeWFfCbm+UOC/0X4DS8XtpUTMwWMGbjKYP7xjfNekzyGmB3A=="],
@@ -1321,6 +1363,8 @@
"proper-lockfile": ["[email protected]", "", { "dependencies": { "graceful-fs": "^4.2.4", "retry": "^0.12.0", "signal-exit": "^3.0.2" } }, "sha512-TjNPblN4BwAWMXU8s9AEz4JmQxnD1NNL7bNOY/AKUzyamc379FWASUhc/K1pL2noVb+XmZKLL68cjzLsiOAMaA=="],
"protobufjs": ["[email protected]", "", { "dependencies": { "@protobufjs/aspromise": "^1.1.2", "@protobufjs/base64": "^1.1.2", "@protobufjs/codegen": "^2.0.5", "@protobufjs/eventemitter": "^1.1.1", "@protobufjs/fetch": "^1.1.1", "@protobufjs/float": "^1.0.2", "@protobufjs/path": "^1.1.2", "@protobufjs/pool": "^1.1.0", "@protobufjs/utf8": "^1.1.1", "@types/node": ">=13.7.0", "long": "^5.3.2" } }, "sha512-/FPD0nUc9jH6rfFjji9IBqOz4pcSE3CsT1m7Ep6Mdb0LxSUMj8hgl6GomOvZzpNpAqqGaXA0P3VSrZLFzIhQrw=="],
"proxy-addr": ["[email protected]", "", { "dependencies": { "forwarded": "0.2.0", "ipaddr.js": "1.9.1" } }, "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg=="],
"punycode": ["[email protected]", "", {}, "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg=="],
@@ -1637,6 +1681,8 @@
"@img/sharp-webcontainers-wasm32/@img/sharp-wasm32": ["@img/[email protected]", "", { "dependencies": { "@emnapi/runtime": "^1.11.1" } }, "sha512-cZ0XkcYGpHZkqW6iCkqTcmUC0CD9DhD5d/qeZlZkfRBn6GnHniZXLUo5+9xw8Iv76YE6LQFN9YNBlKREcCG76w=="],
"@imgly/background-removal/zod": ["[email protected]", "", {}, "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ=="],
"@modelcontextprotocol/sdk/@hono/node-server": ["@hono/[email protected]", "", { "peerDependencies": { "hono": "^4" } }, "sha512-GwtvgtXxnWsucXvbQXkRgqksiH2Qed37H9xHZocE5sA3N8O8O8/8FA3uclQXxXVzc9XBZuEOMK7+r02FmSpHtw=="],
"@modelcontextprotocol/sdk/ajv": ["[email protected]", "", { "dependencies": { "fast-deep-equal": "^3.1.3", "fast-uri": "^3.0.1", "json-schema-traverse": "^1.0.0", "require-from-string": "^2.0.2" } }, "sha512-Thbli+OlOj+iMPYFBVBfJ3OmCAnaSyNn4M1vz9T6Gka5Jt9ba/HIR56joy65tY6kx/FCF5VXNB819Y7/GUrBGA=="],
+34 -27
View File
@@ -15,36 +15,18 @@ import Link from "next/link";
import { useState } from "react";
import { Spinner } from "@/components/ui/spinner";
import { PageType } from "@/lib/pages/types";
import { useAction } from "@/hooks/useAction";
type Draft = { id: string; type: PageType; title: string; slug: string; updatedAt: Date | null };
export default function DraftsDialog({ drafts }: { drafts: Draft[]}) {
const [isDeletingId, setIsDeletingId] = useState("");
async function deletePage(id: string, type: PageType) {
setIsDeletingId(id);
try {
await deletePageAction(id, type);
} finally {
setIsDeletingId("");
}
}
function DraftItem({ draft, onDeleted }: { draft: Draft; onDeleted: (id: string) => void }) {
const { run, isPending } = useAction(deletePageAction, {
successMessage: "Draft deleted",
onSuccess: () => onDeleted(draft.id),
});
return (
<Dialog>
<DialogTrigger asChild>
<Button variant="secondary" className="flex flex-row items-center gap-2">Drafts<div className="flex items-center justify-center bg-black/50 text-white w-3.5 h-3.5 text-xs rounded-full">{drafts.length}</div></Button>
</DialogTrigger>
<DialogContent className="sm:max-w-md">
<DialogHeader>
<DialogTitle>Drafts</DialogTitle>
<DialogDescription>Here are drafts of your pages</DialogDescription>
</DialogHeader>
{drafts.length > 0 ? (
<div className="flex flex-col items-center gap-2">
{drafts.map((draft) => (
<div className="w-full flex flex-row items-center justify-between" key={draft.id}>
<div className="w-full flex flex-row items-center justify-between">
<h3 className="w-64 truncate">
{draft.title}
</h3>
@@ -52,11 +34,36 @@ export default function DraftsDialog({ drafts }: { drafts: Draft[]}) {
<Link href={`/news/${draft.slug}/edit`}>
<Button variant="secondary" size="icon-sm"><PencilIcon /></Button>
</Link>
<Button disabled={isDeletingId === draft.id} variant="secondary" size="icon-sm" onClick={() => deletePage(draft.id, draft.type)}>
{isDeletingId === draft.id ? <Spinner /> : <XIcon />}
<Button disabled={isPending} variant="secondary" size="icon-sm" onClick={() => run(draft.id, draft.type)}>
{isPending ? <Spinner /> : <XIcon />}
</Button>
</div>
</div>
);
}
export default function DraftsDialog({ drafts }: { drafts: Draft[]}) {
const [items, setItems] = useState(drafts);
function handleDeleted(id: string) {
setItems((prev) => prev.filter((d) => d.id !== id));
}
return (
<Dialog>
<DialogTrigger asChild>
<Button variant="secondary" className="flex flex-row items-center gap-2">Drafts<div className="flex items-center justify-center bg-black/50 text-white w-3.5 h-3.5 text-xs rounded-full">{items.length}</div></Button>
</DialogTrigger>
<DialogContent className="sm:max-w-md">
<DialogHeader>
<DialogTitle>Drafts</DialogTitle>
<DialogDescription>Here are drafts of your pages</DialogDescription>
</DialogHeader>
{items.length > 0 ? (
<div className="flex flex-col items-center gap-2">
{items.map((draft) => (
<DraftItem key={draft.id} draft={draft} onDeleted={handleDeleted} />
))}
</div>
) : (
+17 -8
View File
@@ -139,7 +139,7 @@ export default function Editor({ page, initialBlocks = [], onChange, errors }: E
return (
<div className="flex flex-col gap-10">
<FieldSet>
<h2 className=" mb-6">Meta</h2>
<h2 className="md:mb-4">Meta</h2>
<FieldGroup>
<Field data-invalid={!!errors?.title?.length}>
<FieldLabel htmlFor="title">Title</FieldLabel>
@@ -219,12 +219,12 @@ export default function Editor({ page, initialBlocks = [], onChange, errors }: E
</FieldGroup>
</FieldSet>
<div className="flex flex-col gap-1">
<h2 className=" mb-6">Content</h2>
<div className="flex flex-col gap-4">
<h2 className="md:mb-4">Content</h2>
{blocks.length === 0 && (
<p className="text-sm text-muted-foreground">No blocks yet. Add one below.</p>
)}
<div className="flex flex-col gap-6">
<div className="flex flex-col gap-4 md:gap-6">
{blocks.map((block, index) => (
<div
key={block.id}
@@ -234,7 +234,7 @@ export default function Editor({ page, initialBlocks = [], onChange, errors }: E
onDrop={() => handleDrop(index)}
onDragEnd={() => { setDragIndex(null); setDropIndex(null); }}
className={cn(
"group relative flex flex-row gap-4 items-start py-1 transition-opacity",
"group relative flex flex-row gap-2 md:gap-4 items-start py-1 transition-opacity",
dragIndex === index && "opacity-30",
dropIndex === index && dragIndex !== index && "border-t-2 border-primary"
)}
@@ -291,10 +291,19 @@ function BlockInput({ block, onChange }: { block: Block; onChange: (c: Block["co
);
case "HEADING":
const level = (block.content as any).level;
return (
<div className="flex items-center gap-2">
<input
className="flex-1 bg-transparent outline-none tracking-tight placeholder:text-muted-foreground"
className={cn(
"flex-1 min-w-0 bg-transparent outline-none tracking-tight placeholder:text-muted-foreground",
{
"text-2xl sm:text-3xl": level === 1,
"text-xl sm:text-2xl": level === 2,
"text-lg sm:text-xl": level === 3,
}
)}
placeholder="Heading"
value={(block.content as any).text ?? ""}
onChange={(e) => onChange({ type: "HEADING", text: e.target.value, level: (block.content as any).level ?? 2 })}
@@ -362,12 +371,12 @@ function BlockInput({ block, onChange }: { block: Block; onChange: (c: Block["co
onChange={(e) => onChange({ type: "IMAGE", url: e.target.value })}
/>
{(block.content as any).url && (
<div className="w-max relative rounded-md overflow-hidden border bg-muted/30">
<div className="relative max-w-150 rounded-md overflow-hidden border bg-muted/30">
{/* eslint-disable-next-line @next/next/no-img-element */}
<img
src={(block.content as any).url}
alt="preview"
className="max-h-64 w-auto object-contain"
className="block max-w-full h-auto object-contain"
onError={(e) => { (e.target as HTMLImageElement).style.display = "none"; }}
/>
</div>
+4 -7
View File
@@ -4,8 +4,8 @@ import Link from "next/link";
export default function Footer() {
return (
<footer className="flex flex-col w-full px-16 py-8 gap-8 bg-muted">
<div className="flex items-center gap-4">
<footer className="flex flex-col w-full px-4 lg:px-16 py-8 gap-8 bg-muted">
<div className="flex flex-col lg:flex-row lg:items-center gap-4">
<Image
src="/emblem.png"
width={28}
@@ -14,7 +14,7 @@ export default function Footer() {
/>
<h3>This is an official site of the European Federation</h3>
</div>
<div className="flex flex-row gap-32">
<div className="flex flex-row justify-between lg:justify-start lg:gap-32">
<div className="flex flex-col gap-2">
<Link href="/" className="text-black/60 cursor-pointer hover:underline underline-offset-8 decoration-2">Main</Link>
<Link href="/news" className="text-black/60 cursor-pointer hover:underline underline-offset-8 decoration-2">News</Link>
@@ -25,11 +25,8 @@ export default function Footer() {
<Link href="/page/vice-president" className="text-black/60 cursor-pointer hover:underline underline-offset-8 decoration-2">Vice President</Link>
<Link href="/page/government" className="text-black/60 cursor-pointer hover:underline underline-offset-8 decoration-2">Federal Government</Link>
</div>
<div className="flex flex-col gap-2">
<Link href="/page/regions" className="text-black/60 cursor-pointer hover:underline underline-offset-8 decoration-2">Regions</Link>
</div>
</div>
<p>© 2026 European Federation. All rights reserved.</p>
<p>© {new Date().getFullYear()} European Federation. All rights reserved.</p>
</footer>
)
}
+25 -20
View File
@@ -4,38 +4,43 @@ import { login } from "@/lib/user/actions";
import { getCurrentUser } from "@/lib/user";
import Link from "next/link";
import { getNavLinks } from "@/lib/navlinks/repository";
import { MobileNav } from "./mobile-nav";
export default async function Header() {
const user = await getCurrentUser();
const links = await getNavLinks();
const navLinks = links.map((link) => ({
id: link.id,
href: link.href || (link.page ? `/${link.page.type.toLowerCase()}/${link.page.slug}` : "/"),
label: link.label ?? link.page?.title ?? "",
}));
return (
<header className="relative flex items-center justify-between w-full h-16 px-8 bg-gray-100">
<Link href="/" className="flex items-center gap-4">
<Image
src="/emblem.png"
width={28}
height={28}
alt="Emblem of the European Federation"
/>
<h3>European Federation</h3>
<header className="relative flex items-center justify-between w-full h-16 px-4 sm:px-8 bg-white sm:bg-gray-100">
<Link href="/" className="flex items-center gap-4 shrink-0">
<Image src="/emblem.png" width={28} height={28} alt="Emblem of the European Federation" />
<h3 className="hidden sm:block">European Federation</h3>
</Link>
<div className="absolute left-1/2 -translate-x-1/2 flex items-center gap-6">
{
links.map((link) => (
<Link className="hover:underline underline-offset-8 decoration-2 duration-200" key={link.id} href={link.href || (link.page ? `/${link.page.type.toLowerCase()}/${link.page.slug}` : "/")}><h3>{link.label ?? link.page?.title}</h3></Link>
))
}
<div className="hidden md:flex absolute left-1/2 -translate-x-1/2 items-center gap-6">
{navLinks.map((link) => (
<Link className="hover:underline underline-offset-8 decoration-2 duration-200" key={link.id} href={link.href}>
<h3>{link.label}</h3>
</Link>
))}
</div>
{
user ? (
<div className="hidden md:block">
{user ? (
<Link href="/account"><Button>Account</Button></Link>
) : (
<form action={login}>
<Button size="lg" type="submit">Sign in with Kotosoft ID</Button>
</form>
)
}
)}
</div>
<MobileNav links={navLinks} isAuthenticated={!!user} />
</header>
)
);
}
+13 -18
View File
@@ -70,7 +70,7 @@ export default function IdentityCard({ data }: { data: IdentityCardData }) {
const expiryClass = expiryDateClass(data.expiryDate);
return (
<div className="relative w-96 bg-blue-50 rounded-lg p-4 overflow-hidden">
<div className="relative md:w-96 bg-blue-50 rounded-lg p-4 overflow-hidden">
<CardPattern />
<div className="relative z-10">
<div className="flex flex-row items-center justify-between">
@@ -88,12 +88,12 @@ export default function IdentityCard({ data }: { data: IdentityCardData }) {
<DialogContent>
<DialogHeader>
<div className="flex flex-row gap-3">
<div className="relative w-12 h-14 shrink-0 rounded overflow-hidden">
<img src={data.profileUrl} alt="Profile" className="object-cover" />
<div className="relative w-12 aspect-4/5 shrink-0 rounded overflow-hidden">
<img src={data.profileUrl} alt="Profile" className="w-full h-full object-cover" />
</div>
<div className="flex flex-col gap-0 justify-center">
<div className="flex flex-col justify-center">
<DialogTitle asChild>
<h4 className="uppercase">{data.surname} {data.givenNames}</h4>
<h4 className="uppercase">{data.givenNames} {data.surname}</h4>
</DialogTitle>
<h4 className="text-muted-foreground">{data.documentNumber}</h4>
</div>
@@ -103,19 +103,14 @@ export default function IdentityCard({ data }: { data: IdentityCardData }) {
{DIALOG_FIELDS.map(({ key, label }) => (
<div className="flex flex-col" key={key}>
<h5 className="text-blue-500">{label}</h5>
<h4
className={cn(
"leading-6",
key === "expiryDate" && expiryClass
)}
>
<h4 className={cn(key === "expiryDate" && expiryClass)}>
{formatFieldValue(key, data[key])}
</h4>
</div>
))}
<div className="flex flex-col col-span-2">
<h5 className="text-blue-500">{ADDRESS_FIELD.label}</h5>
<h4 className="leading-6">{formatFieldValue(ADDRESS_FIELD.key, data[ADDRESS_FIELD.key])}</h4>
<h4>{formatFieldValue(ADDRESS_FIELD.key, data[ADDRESS_FIELD.key])}</h4>
</div>
</div>
</DialogContent>
@@ -123,12 +118,12 @@ export default function IdentityCard({ data }: { data: IdentityCardData }) {
</div>
<div className="flex flex-row gap-8 mt-4">
<div className="flex flex-col gap-8 w-24 shrink-0">
<div className="relative w-24 h-28 shrink-0">
<img src={data.profileUrl} alt="Profile" className="object-cover" />
<div className="flex flex-col gap-4 w-24 shrink-0">
<div className="w-24 aspect-4/5 rounded overflow-hidden">
<img src={data.profileUrl} alt="Profile" className="w-full h-full object-cover" />
</div>
<div className="relative w-24 h-12 shrink-0">
<img src={data.signatureUrl} alt="Signature" className="object-contain" />
<div className="w-24 aspect-5/2 rounded overflow-hidden">
<img src={data.signatureUrl} alt="Signature" className="w-full h-full object-contain" />
</div>
</div>
<div className="flex flex-col gap-2">
@@ -155,7 +150,7 @@ export default function IdentityCard({ data }: { data: IdentityCardData }) {
<div className="flex flex-wrap gap-x-6 gap-y-2">
<div className="flex flex-col min-w-fit">
<h5 className="text-blue-500">Authority</h5>
<h4 className="leading-6">{data.authority}</h4>
<h4>{data.authority}</h4>
</div>
<div className="flex flex-col min-w-fit">
<h5 className="text-blue-500">Nationality</h5>
+210
View File
@@ -0,0 +1,210 @@
"use client";
import { useRef, useState, useEffect } from "react";
import { Field, FieldDescription, FieldError, FieldLabel } from "@/components/ui/field";
import { Input } from "@/components/ui/input";
import { Button } from "@/components/ui/button";
import { XIcon, ImageIcon, RefreshCwIcon } from "lucide-react";
import { cn } from "@/lib/utils";
import { Spinner } from "@/components/ui/spinner";
type Props = {
id: string;
name?: string;
label: string;
description?: string;
error?: string;
variant?: "default" | "editor";
previewClassName?: string;
accept?: string;
required?: boolean;
value?: string;
onFileSelect?: (file: File, previewUrl: string) => void;
onRemove?: () => void;
isUploading?: boolean;
children?: React.ReactNode;
caption?: string;
onCaptionChange?: (caption: string) => void;
};
const MAX_SIZE = 5 * 1024 * 1024;
const DEFAULT_ACCEPT = "image/jpeg,image/png,image/webp";
const EDITOR_WRAPPER_CLASS = "flex flex-col gap-2 items-stretch md:items-start";
const EDITOR_IMG_CLASS = "block max-w-full md:max-w-200 h-auto rounded-md border object-contain";
function formatFileSize(bytes: number): string {
return bytes < 1024 * 1024
? `${Math.round(bytes / 1024)} KB`
: `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
}
function validateFile(file: File, accept: string): string | null {
const allowed = accept.split(",").map((t) => t.trim());
if (!allowed.includes(file.type)) {
return "Only JPEG, PNG, or WEBP images are allowed.";
}
if (file.size > MAX_SIZE) {
return "Image must be smaller than 5MB.";
}
return null;
}
export function ImageUploader({ id, name, label, description, error, variant = "default", previewClassName, accept = DEFAULT_ACCEPT, required, value, onFileSelect, onRemove, isUploading, children, caption, onCaptionChange }: Props) {
const inputRef = useRef<HTMLInputElement>(null);
const [previewUrl, setPreviewUrl] = useState<string | null>(null);
const [fileInfo, setFileInfo] = useState<{ name: string; size: number } | null>(null);
const [clientError, setClientError] = useState<string | null>(null);
const [isDragOver, setIsDragOver] = useState(false);
useEffect(() => {
return () => {
if (previewUrl) URL.revokeObjectURL(previewUrl);
};
}, [previewUrl]);
function clearFileState() {
if (previewUrl) URL.revokeObjectURL(previewUrl);
setPreviewUrl(null);
setFileInfo(null);
if (inputRef.current) inputRef.current.value = "";
}
function reset() {
clearFileState();
setClientError(null);
onRemove?.();
}
function applyFile(file: File) {
const validationError = validateFile(file, accept);
if (validationError) {
setClientError(validationError);
clearFileState();
return;
}
setClientError(null);
const url = URL.createObjectURL(file);
setPreviewUrl(url);
setFileInfo({ name: file.name, size: file.size });
onFileSelect?.(file, url);
}
function handleChange(e: React.ChangeEvent<HTMLInputElement>) {
const file = e.target.files?.[0];
if (!file) return;
applyFile(file);
}
function handleDrop(e: React.DragEvent<HTMLDivElement>) {
e.preventDefault();
setIsDragOver(false);
const file = e.dataTransfer.files?.[0];
if (file) applyFile(file);
}
const displayedError = clientError ?? error;
const displayUrl = previewUrl ?? value;
if (variant === "editor") {
return (
<Field data-invalid={!!displayedError}>
<Input ref={inputRef} id={id} name={name} type="file" accept={accept} className="hidden" onChange={handleChange} disabled={isUploading} />
{displayUrl ? (
<div className={EDITOR_WRAPPER_CLASS}>
<div className="group relative rounded-md">
<img src={displayUrl} alt="" className={previewClassName ?? EDITOR_IMG_CLASS} />
<div className="absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity">
<Button type="button" variant="secondary" size="sm" onClick={() => inputRef.current?.click()} disabled={isUploading}>
<RefreshCwIcon />
Replace
</Button>
</div>
{isUploading && (
<div className="absolute inset-0 flex items-center justify-center bg-background/90 rounded-md">
<Spinner />
</div>
)}
</div>
{onCaptionChange && (
<input
className="w-full bg-transparent outline-none text-xs md:text-sm text-muted-foreground placeholder:text-muted-foreground/50"
placeholder="Add a caption..."
value={caption ?? ""}
onChange={(e) => onCaptionChange(e.target.value)}
/>
)}
</div>
) : (
<div
role="button"
tabIndex={0}
onClick={() => inputRef.current?.click()}
onKeyDown={(e) => { if (e.key === "Enter" || e.key === " ") inputRef.current?.click(); }}
onDragOver={(e) => { e.preventDefault(); setIsDragOver(true); }}
onDragLeave={() => setIsDragOver(false)}
onDrop={handleDrop}
className={cn(
"flex flex-row rounded-md bg-card px-2.5 py-1 text-sm text-muted-foreground ring-1 ring-foreground/10 transition-colors items-center gap-2",
"hover:bg-muted/60",
isDragOver && "bg-muted"
)}
>
<ImageIcon size={16} />
<span>Add image</span>
</div>
)}
{displayedError && <FieldError>{displayedError}</FieldError>}
</Field>
);
}
return (
<Field data-invalid={!!displayedError}>
<FieldLabel htmlFor={id}>{label}</FieldLabel>
<div className="flex flex-col md:flex-row items-start gap-4">
<div
className={cn(
"w-28 rounded-md border border-dashed border-foreground/15 bg-muted flex items-center justify-center overflow-hidden shrink-0",
previewClassName ?? "aspect-square"
)}
>
{isUploading ? (
<Spinner className="text-muted-foreground" />
) : displayUrl ? (
<img src={displayUrl} alt="" className="w-full h-full object-cover" />
) : (
<ImageIcon className="text-muted-foreground" size={24} />
)}
</div>
<div className="flex flex-col gap-1 flex-1 min-w-0">
<Input ref={inputRef} id={id} name={name} type="file" accept={accept} aria-invalid={!!displayedError} onChange={handleChange} disabled={isUploading} required={required && !fileInfo && !value} />
{fileInfo && (
<div className="flex items-center gap-2 text-sm text-muted-foreground min-w-0">
<span className="flex-1 truncate">
{fileInfo.name} ({formatFileSize(fileInfo.size)})
</span>
<Button type="button" variant="ghost" size="icon" className="h-6 w-6" onClick={reset} disabled={isUploading}>
<XIcon size={14} />
</Button>
</div>
)}
{description && <FieldDescription className="mt-1">{description}</FieldDescription>}
{children}
</div>
</div>
{displayedError && <FieldError>{displayedError}</FieldError>}
</Field>
);
}
+53
View File
@@ -0,0 +1,53 @@
"use client";
import { useState } from "react";
import Link from "next/link";
import { MenuIcon, XIcon } from "lucide-react";
import { Button } from "./ui/button";
import { login } from "@/lib/user/actions";
import Image from "next/image";
type NavLink = { id: string; href: string; label: string };
export function MobileNav({ links, isAuthenticated }: { links: NavLink[]; isAuthenticated: boolean }) {
const [open, setOpen] = useState(false);
return (
<div className="md:hidden">
<Button variant="ghost" size="icon" onClick={() => setOpen(true)} aria-label="Open menu">
<MenuIcon />
</Button>
{open && (
<div className="fixed inset-0 z-50 bg-white flex flex-col">
<div className="flex items-center justify-between h-16 px-4">
<Link href="/" onClick={() => setOpen(false)} className="flex items-center gap-4 shrink-0">
<Image src="/emblem.png" width={28} height={28} alt="Emblem of the European Federation" />
<h3 className="hidden sm:block">European Federation</h3>
</Link>
<Button variant="ghost" size="icon" onClick={() => setOpen(false)} aria-label="Close menu">
<XIcon />
</Button>
</div>
<nav className="flex flex-col gap-2.5 p-4">
{links.map((link) => (
<Link key={link.id} href={link.href} onClick={() => setOpen(false)} className="hover:underline underline-offset-8 decoration-2 duration-200">
<h2>{link.label}</h2>
</Link>
))}
<div className="mt-4">
{isAuthenticated ? (
<Link href="/account" onClick={() => setOpen(false)}>
<Button>Account</Button>
</Link>
) : (
<form action={login}>
<Button size="lg" type="submit">Sign in with Kotosoft ID</Button>
</form>
)}
</div>
</nav>
</div>
)}
</div>
);
}
+4 -2
View File
@@ -10,10 +10,12 @@ export function NewsCard({ news }: { news: PagePublic }) {
<Link href={`/news/${news.slug}`} className="w-max">
<h2 className="hover:underline underline-offset-8 decoration-2 hover:duration-200 cursor-pointer">{news.title}</h2>
</Link>
<div className="flex flex-row gap-8 items-center">
<div className="flex flex-col md:flex-row gap-2 md:gap-8 md:items-center">
<div className="flex flex-row gap-4 md:gap-8">
<p className="flex gap-2 items-center"><CalendarIcon size={16} />{formatDate(news.publishedAt)}</p>
{(news?.meta as PageMeta)?.location && <p className="flex gap-2 items-center"><Globe2Icon size={16} />{(news.meta as PageMeta)?.location}</p>}
<div className="flex flex-row gap-4">
</div>
<div className="hidden md:flex flex-row gap-4">
{((news.meta as PageMeta)?.tags)?.map((tag) => (
<Badge key={tag}>{tag}</Badge>
))}
+1 -1
View File
@@ -23,7 +23,7 @@ const buttonVariants = cva(
size: {
default:
"h-8 gap-1.5 px-3 has-data-[icon=inline-end]:pr-2.5 has-data-[icon=inline-start]:pl-2.5",
xs: "h-6 gap-1 px-2.5 text-xs has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2 [&_svg:not([class*='size-'])]:size-3",
xs: "h-6 gap-1 px-2.5 text-xs md:text-xs has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2 [&_svg:not([class*='size-'])]:size-3",
sm: "h-7 gap-1 px-3 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
lg: "h-9 gap-1.5 px-4 has-data-[icon=inline-end]:pr-3 has-data-[icon=inline-start]:pl-3",
icon: "size-8",
+5 -5
View File
@@ -30,7 +30,7 @@ function FieldLegend({
data-slot="field-legend"
data-variant={variant}
className={cn(
"mb-1.5 font-medium data-[variant=label]:text-sm data-[variant=legend]:text-base",
"mb-3 font-medium data-[variant=label]:text-sm data-[variant=legend]:text-base md:data-[variant=legend]:text-lg",
className
)}
{...props}
@@ -43,7 +43,7 @@ function FieldGroup({ className, ...props }: React.ComponentProps<"div">) {
<div
data-slot="field-group"
className={cn(
"group/field-group @container/field-group flex w-full flex-col gap-5 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4",
"group/field-group @container/field-group flex w-full flex-col gap-6 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4",
className
)}
{...props}
@@ -130,11 +130,11 @@ function FieldTitle({ className, ...props }: React.ComponentProps<"div">) {
function FieldDescription({ className, ...props }: React.ComponentProps<"p">) {
return (
<p
<h5
data-slot="field-description"
className={cn(
"text-left text-sm leading-normal font-normal text-muted-foreground group-has-data-horizontal/field:text-balance [[data-variant=legend]+&]:-mt-1.5",
"last:mt-0 nth-last-2:-mt-1",
"text-left font-normal text-muted-foreground group-has-data-horizontal/field:text-balance [[data-variant=legend]+&]:-mt-2",
"nth-last-2:-mt-0.5",
"[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",
className
)}
+1 -1
View File
@@ -8,7 +8,7 @@ function Input({ className, type, ...props }: React.ComponentProps<"input">) {
type={type}
data-slot="input"
className={cn(
"h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",
"h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",
className
)}
{...props}
+57
View File
@@ -0,0 +1,57 @@
"use client"
import * as React from "react"
import { Tooltip as TooltipPrimitive } from "radix-ui"
import { cn } from "@/lib/utils"
function TooltipProvider({
delayDuration = 0,
...props
}: React.ComponentProps<typeof TooltipPrimitive.Provider>) {
return (
<TooltipPrimitive.Provider
data-slot="tooltip-provider"
delayDuration={delayDuration}
{...props}
/>
)
}
function Tooltip({
...props
}: React.ComponentProps<typeof TooltipPrimitive.Root>) {
return <TooltipPrimitive.Root data-slot="tooltip" {...props} />
}
function TooltipTrigger({
...props
}: React.ComponentProps<typeof TooltipPrimitive.Trigger>) {
return <TooltipPrimitive.Trigger data-slot="tooltip-trigger" {...props} />
}
function TooltipContent({
className,
sideOffset = 0,
children,
...props
}: React.ComponentProps<typeof TooltipPrimitive.Content>) {
return (
<TooltipPrimitive.Portal>
<TooltipPrimitive.Content
data-slot="tooltip-content"
sideOffset={sideOffset}
className={cn(
"z-50 inline-flex w-fit max-w-xs origin-(--radix-tooltip-content-transform-origin) items-center gap-1.5 rounded-xl bg-foreground px-3 py-1.5 text-xs text-background has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-lg data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
className
)}
{...props}
>
{children}
<TooltipPrimitive.Arrow className="z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground data-[side=left]:translate-x-[-1.5px] data-[side=right]:translate-x-[1.5px]" />
</TooltipPrimitive.Content>
</TooltipPrimitive.Portal>
)
}
export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger }
+36
View File
@@ -0,0 +1,36 @@
services:
eu:
image: localhost:5000/eu:latest
restart: unless-stopped
environment:
PUBLIC_URL: ${PUBLIC_URL}
DATABASE_URL: ${DATABASE_URL}
KOTOSOFT_ID_API_URL: ${KOTOSOFT_ID_API_URL}
KOTOSOFT_CLIENT_ID: ${KOTOSOFT_CLIENT_ID}*
KOTOSOFT_CLIENT_SECRET: ${KOTOSOFT_CLIENT_SECRET}*
JWT_SECRET: ${JWT_SECRET}
SESSION_MAX_AGE: 604800
MINIO_URL: ${MINIO_URL}
MINIO_PORT: 9000
MINIO_ACCESS_KEY: ${MINIO_ACCESS_KEY}
MINIO_SECRET_KEY: ${MINIO_SECRET_KEY}
MINIO_PUBLIC_URL: ${MINIO_PUBLIC_URL}
VIRTUAL_HOST: ${API_DOMAIN}
VIRTUAL_PORT: 8080
LETSENCRYPT_HOST: ${API_DOMAIN}
LETSENCRYPT_EMAIL: ${LETSENCRYPT_EMAIL}
expose:
- "3000"
networks:
- proxy
- eu_net
networks:
proxy:
external: true
eu_net:
external: true
+26 -5
View File
@@ -11,7 +11,7 @@ import { createApplication, getActiveCitizenship, getApplicationEligibility } fr
import { prisma } from "../prisma";
import { formatAddress } from "@/lib/address";
import { Prisma } from "@/lib/generated/prisma/client";
import { uploadImage } from "../image";
import { removeImage, uploadImage } from "../image";
function generateDocumentNumber(): string {
const letter = () => String.fromCharCode(65 + Math.floor(Math.random() * 26));
@@ -70,8 +70,17 @@ export const submitCitizenshipApplication = formAction(citizenshipApplicationSch
customAddress: data.customAddress,
});
const profileKey = await uploadImage(profile, "citizenship/profiles");
const signatureKey = await uploadImage(signature, "citizenship/signatures");
let profileKey: string | undefined;
let signatureKey: string | undefined;
try {
const profileKey = await uploadImage(profile, "citizenship/profiles", {
maxWidth: 800, maxHeight: 1000, fit: "cover",
});
const signatureKey = await uploadImage(signature, "citizenship/signatures", {
maxWidth: 1000, maxHeight: 400, fit: "inside",
});
await createApplication(user.id, {
surname: user.secondName,
@@ -87,6 +96,11 @@ export const submitCitizenshipApplication = formAction(citizenshipApplicationSch
profileKey,
signatureKey
});
} catch (e) {
if (profileKey) await removeImage(profileKey);
if (signatureKey) await removeImage(signatureKey);
throw e;
}
revalidatePath("/account/citizenship");
redirect("/account/citizenship");
@@ -102,8 +116,10 @@ export async function approveApplication(id: string): Promise<ActionResult> {
if (application.status !== "PENDING") throw new AppError("This application is no longer pending review.");
if (application.userId === user.id) throw new AppError("You cannot approve your own application.");
const existingCitizenship = await prisma.citizenship.findUnique({ where: { userId: application.userId } });
if (existingCitizenship && !existingCitizenship.revokedAt) {
const existingCitizenship = await prisma.citizenship.findFirst({
where: { userId: application.userId, revokedAt: null },
});
if (existingCitizenship) {
throw new AppError("This applicant is already a citizen.");
}
@@ -154,6 +170,11 @@ export async function rejectApplication(id: string, reason: string): Promise<Act
data: { status: "REJECTED", rejectionReason: trimmedReason, reviewedAt: new Date(), reviewedBy: user.id },
});
await Promise.allSettled([
removeImage(application.profileKey),
removeImage(application.signatureKey),
]);
revalidatePath("/account/citizenship/review");
});
}
+4 -4
View File
@@ -38,7 +38,7 @@ export async function getApplicationEligibility(
};
}
const citizenship = await prisma.citizenship.findUnique({ where: { userId } });
const citizenship = await prisma.citizenship.findFirst({ where: { userId, revokedAt: null } });
if (citizenship && !citizenship.revokedAt) {
return {
eligible: false,
@@ -100,7 +100,7 @@ export async function getPendingApplicationsCount(): Promise<number> {
}
export async function getActiveCitizenship(userId: string) {
const citizenship = await prisma.citizenship.findUnique({ where: { userId } });
if (!citizenship || citizenship.revokedAt) return null;
return citizenship;
return prisma.citizenship.findFirst({
where: { userId, revokedAt: null },
});
}
-2
View File
@@ -36,8 +36,6 @@ export type CitizenshipApplication = {
updatedAt: Date;
profileKey: string;
signatureKey: string;
profile: File;
signature: File;
};
export type CitizenshipApplicationWithWarning = CitizenshipApplication & {
+21 -25
View File
@@ -5,53 +5,49 @@ import { AppError } from "@/lib/action-result";
import { minioClient } from "@/lib/minio";
const BUCKET = "uploads";
const MAX_FILE_SIZE = 5 * 1024 * 1024;
const ALLOWED_INPUT_FORMATS = new Set(["jpeg", "png", "webp"]);
export async function uploadImage(file: File, directory: string): Promise<string> {
if (file.size === 0) {
throw new AppError("A file is required");
}
if (file.size > MAX_FILE_SIZE) {
throw new AppError("Image must be smaller than 5MB");
}
export async function uploadImage(file: File, directory: string, options: { maxWidth: number; maxHeight: number; fit?: "inside" | "cover"; removeBg?: boolean }): Promise<string> {
if (file.size === 0) throw new AppError("A file is required");
if (file.size > MAX_FILE_SIZE) throw new AppError("Image must be smaller than 5MB");
const input = Buffer.from(await file.arrayBuffer());
let image = sharp(input, {
failOn: "error",
limitInputPixels: 30_000_000,
});
const metadata = await image.metadata();
if (!metadata.format) {
if (!metadata.format || !ALLOWED_INPUT_FORMATS.has(metadata.format)) {
throw new AppError("Only JPEG, PNG, or WEBP images are allowed");
}
if (!metadata.width || !metadata.height || metadata.width < 100 || metadata.height < 100) {
throw new AppError("Image is too small");
}
const output = await image
.rotate()
.webp({
quality: 80,
effort: 4,
.resize({
width: options.maxWidth,
height: options.maxHeight,
fit: options.fit ?? "inside",
withoutEnlargement: true,
})
.webp({ quality: 80, effort: 4 })
.toBuffer();
const key = `${directory}/${crypto.randomUUID()}.webp`;
await minioClient.putObject(
BUCKET,
key,
output,
output.length,
{
"Content-Type": "image/webp",
},
);
await minioClient.putObject(BUCKET, key, output, output.length, { "Content-Type": "image/webp" });
return key;
}
export async function removeImage(key: string) {
await minioClient.removeObject(BUCKET, key)
}
export async function getImageUrl(key: string): Promise<string> {
return minioClient.presignedGetObject(
BUCKET,
+12 -6
View File
@@ -3,16 +3,22 @@
import { revalidatePath } from "next/cache";
import { addNavLink, deleteNavLinkByPageId } from "./repository";
import { prisma } from "../prisma";
import { requireAdmin } from "../user/require";
import { runAction } from "../run-action";
import type { ActionResult } from "../action-result";
export async function pinPageAction(pageId: string) {
export async function togglePinAction(pageId: string, isPinned: boolean): Promise<ActionResult> {
return runAction(async () => {
await requireAdmin();
if (isPinned) {
await deleteNavLinkByPageId(pageId);
} else {
const page = await prisma.page.findUnique({ where: { id: pageId } });
if (!page) throw new Error(`Page not found: ${pageId}`);
await addNavLink({ pageId });
revalidatePath("/", "layout");
}
}
export async function unpinPageAction(pageId: string) {
await deleteNavLinkByPageId(pageId);
revalidatePath("/", "layout");
});
}
+16 -3
View File
@@ -6,6 +6,9 @@ import { archivePage, createPage, deletePage, updatePage } from "./repository";
import { revalidatePath } from "next/cache";
import { deleteNavLinkByPageId } from "../navlinks/repository";
import { validatePage } from "./validation";
import { requireAdmin } from "../user/require";
import { runAction } from "../run-action";
import type { ActionResult } from "../action-result";
export async function savePageAction(params: {
id: string | null,
@@ -15,7 +18,10 @@ export async function savePageAction(params: {
status: PageStatus,
blocks: Block[],
meta?: PageMeta
}) {
}): Promise<ActionResult> {
return runAction(async () => {
await requireAdmin();
const parsed = validatePage(params);
if (!parsed.success) {
throw new Error(parsed.errors.join("; "));
@@ -30,16 +36,23 @@ export async function savePageAction(params: {
revalidatePath(`/${params.type.toLowerCase()}`);
redirect(`/${params.type.toLowerCase()}/${page.slug}`);
}
});
}
export async function archivePageAction(id: string, slug: string, type: PageType) {
export async function archivePageAction(id: string, slug: string, type: PageType): Promise<ActionResult> {
return runAction(async () => {
await requireAdmin();
await archivePage(id);
await deleteNavLinkByPageId(id);
revalidatePath(`/${type.toLowerCase()}/${slug}`);
revalidatePath(`/${type.toLowerCase()}`);
});
}
export async function deletePageAction(id: string, type: PageType) {
export async function deletePageAction(id: string, type: PageType): Promise<ActionResult> {
return runAction(async () => {
await requireAdmin();
await deletePage(id);
revalidatePath(`/${type.toLowerCase()}`);
});
}
+3 -11
View File
@@ -36,13 +36,7 @@ export async function getPageBySlug(slug: string, type?: PageType) {
export async function createPage(slug: string, title: string, type: PageType, status: PageStatus, blocks: Block[], meta?: PageMeta) {
const user = await getCurrentUser();
if (!user) {
throw new Error("Failed to fetch user");
}
if (!user.isAdmin) {
throw new Error("Access denied");
}
if (!user) throw new Error("Failed to fetch user");
try {
const page = await prisma.page.create({
@@ -87,7 +81,7 @@ export async function updatePage(
meta?: PageMeta
) {
const user = await getCurrentUser();
if (!user?.isAdmin) throw new Error("Access denied");
if (!user) throw new Error("Failed to fetch user");
const currentPage = await prisma.page.findUnique({ where: { id }, select: { status: true } });
const isNewlyPublished = status === "PUBLISHED" && currentPage?.status !== "PUBLISHED";
@@ -125,13 +119,11 @@ export async function updatePage(
export async function archivePage(id: string) {
const user = await getCurrentUser();
if (!user?.isAdmin) throw new Error("Access denied");
if (!user) throw new Error("Failed to fetch user");
await prisma.page.update({ where: { id }, data: { status: "ARCHIVED", updatedBy: user.id } });
}
export async function deletePage(id: string) {
const user = await getCurrentUser();
if (!user?.isAdmin) throw new Error("Access denied");
await prisma.page.delete({ where: { id } });
}
+5 -1
View File
@@ -9,7 +9,7 @@ import { deleteUser, updateUser } from "./repository";
import { getAccessToken } from "@/lib/auth/tokens";
import { fetchKotosoftUser } from "@/lib/kotosoft/client";
import { revalidatePath } from "next/cache";
import { getCurrentUser } from "../user";
import { getCurrentUser, getUser } from "../user";
import { runAction } from "@/lib/run-action";
import { AppError, type ActionResult } from "@/lib/action-result";
@@ -61,6 +61,10 @@ export async function updateUserAction(): Promise<ActionResult> {
const userId = await getSessionUserId();
if (!userId) throw new AppError("Not authenticated");
const user = await getUser(userId);
if (user?.kotosoftId !== kotosoftUser.id) throw new AppError("Your session does not match your Kotosoft ID account");
await updateUser(userId, {
email: kotosoftUser.email,
firstName: kotosoftUser.first_name,
+1 -1
View File
@@ -4,7 +4,7 @@ const nextConfig: NextConfig = {
images: {
remotePatterns: [
{
hostname: process.env.MINIO_URL!,
hostname: "**",
},
],
},
+5
View File
@@ -9,6 +9,7 @@
"lint": "eslint"
},
"dependencies": {
"@imgly/background-removal": "^1.7.0",
"@prisma/adapter-pg": "^7.8.0",
"@prisma/client": "^7.8.0",
"@tanstack/react-table": "^8.21.3",
@@ -47,6 +48,10 @@
"unrs-resolver"
],
"trustedDependencies": [
"@prisma/engines",
"onnxruntime-node",
"prisma",
"protobufjs",
"sharp",
"unrs-resolver"
]
+7 -4
View File
@@ -149,13 +149,16 @@ model CitizenshipApplication {
model Citizenship {
id String @id @default(uuid())
userId String @unique
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
userId String
applicationId String @unique
application CitizenshipApplication @relation(fields: [applicationId], references: [id])
issuedAt DateTime @default(now())
revokedAt DateTime?
documents IdentityDocument[]
user User @relation(fields: [userId], references: [id])
application CitizenshipApplication @relation(fields: [applicationId], references: [id])
identityDocuments IdentityDocument[]
@@index([userId])
}
model IdentityDocument {
Binary file not shown.

Before

Width:  |  Height:  |  Size: 184 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

-8
View File
@@ -1,8 +0,0 @@
- ID card page design
- Forced denaturalization
- Expiry
- Admin page
- Mobile version
- Security bugs
- Photos and signature remove bg, size req
- typography: leading