prod
This commit is contained in:
+75
@@ -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
@@ -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
|
||||||
@@ -1,21 +1,23 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useTransition } from "react";
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { ArchiveIcon } from "lucide-react";
|
import { ArchiveIcon } from "lucide-react";
|
||||||
import { Spinner } from "@/components/ui/spinner";
|
import { Spinner } from "@/components/ui/spinner";
|
||||||
import { archivePageAction } from "@/lib/pages/actions";
|
import { archivePageAction } from "@/lib/pages/actions";
|
||||||
import { PageType } from "@/lib/pages/types";
|
import { PageType } from "@/lib/pages/types";
|
||||||
|
import { useAction } from "@/hooks/useAction";
|
||||||
|
|
||||||
export function ArchiveButton({ pageId, slug, type }: { pageId: string, slug: string, type: PageType }) {
|
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 (
|
return (
|
||||||
<Button
|
<Button
|
||||||
variant="secondary"
|
variant="secondary"
|
||||||
size="icon-sm"
|
size="icon-sm"
|
||||||
disabled={isPending}
|
disabled={isPending}
|
||||||
onClick={() => startTransition(() => archivePageAction(pageId, slug, type))}
|
onClick={() => run(pageId, slug, type)}
|
||||||
>
|
>
|
||||||
{isPending ? <Spinner /> : <ArchiveIcon />}
|
{isPending ? <Spinner /> : <ArchiveIcon />}
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useRef, useState, useTransition } from "react";
|
import { useRef } from "react";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import Editor, { EditorData } from "@/components/editor";
|
import Editor, { EditorData } from "@/components/editor";
|
||||||
import { savePageAction } from "@/lib/pages/actions";
|
import { savePageAction } from "@/lib/pages/actions";
|
||||||
import { validatePage } from "@/lib/pages/validation";
|
|
||||||
import { Block, Page, PageMeta, PageType } from "@/lib/pages/types";
|
import { Block, Page, PageMeta, PageType } from "@/lib/pages/types";
|
||||||
import { Loader2 } from "lucide-react";
|
import { Spinner } from "@/components/ui/spinner";
|
||||||
import { toast } from "sonner";
|
import { useAction } from "@/hooks/useAction";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
page: Page | null;
|
page: Page | null;
|
||||||
@@ -18,8 +17,10 @@ type Props = {
|
|||||||
|
|
||||||
export default function EditPageClient({ page, pageType, initialBlocks = [] }: Props) {
|
export default function EditPageClient({ page, pageType, initialBlocks = [] }: Props) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [isPending, startTransition] = useTransition();
|
const { run, isPending } = useAction(savePageAction, {
|
||||||
const [fieldErrors, setFieldErrors] = useState<{ title?: string[]; slug?: string[] }>({});
|
successMessage: "Page saved",
|
||||||
|
onSuccess: () => router.push(`/${pageType.toLowerCase()}/${dataRef.current.slug}`),
|
||||||
|
});
|
||||||
|
|
||||||
const dataRef = useRef<EditorData>({
|
const dataRef = useRef<EditorData>({
|
||||||
title: page?.title ?? "",
|
title: page?.title ?? "",
|
||||||
@@ -31,47 +32,20 @@ export default function EditPageClient({ page, pageType, initialBlocks = [] }: P
|
|||||||
});
|
});
|
||||||
|
|
||||||
function handleSave(status: "DRAFT" | "PUBLISHED") {
|
function handleSave(status: "DRAFT" | "PUBLISHED") {
|
||||||
startTransition(async () => {
|
const data = dataRef.current;
|
||||||
const data = dataRef.current;
|
run({
|
||||||
const payload = {
|
id: page?.id ?? null,
|
||||||
id: page?.id ?? null,
|
slug: data.slug || data.title.toLowerCase().replace(/\s+/g, "-"),
|
||||||
slug: data.slug || data.title.toLowerCase().replace(/\s+/g, "-"),
|
title: data.title,
|
||||||
title: data.title,
|
type: pageType,
|
||||||
type: pageType,
|
status,
|
||||||
status,
|
blocks: data.blocks,
|
||||||
blocks: data.blocks,
|
meta: { location: data.location, tags: data.tags },
|
||||||
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 (
|
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">
|
<div className="flex flex-row items-center justify-between">
|
||||||
<h1>Edit page</h1>
|
<h1>Edit page</h1>
|
||||||
<div className="flex flex-row gap-3">
|
<div className="flex flex-row gap-3">
|
||||||
@@ -79,7 +53,7 @@ export default function EditPageClient({ page, pageType, initialBlocks = [] }: P
|
|||||||
disabled={isPending}
|
disabled={isPending}
|
||||||
onClick={() => handleSave("PUBLISHED")}
|
onClick={() => handleSave("PUBLISHED")}
|
||||||
>
|
>
|
||||||
{isPending && <Loader2 size={14} className="animate-spin mr-1" />}
|
{isPending && <Spinner />}
|
||||||
Save
|
Save
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
@@ -88,10 +62,8 @@ export default function EditPageClient({ page, pageType, initialBlocks = [] }: P
|
|||||||
page={page}
|
page={page}
|
||||||
type={pageType}
|
type={pageType}
|
||||||
initialBlocks={initialBlocks}
|
initialBlocks={initialBlocks}
|
||||||
errors={fieldErrors}
|
|
||||||
onChange={(data) => {
|
onChange={(data) => {
|
||||||
dataRef.current = data;
|
dataRef.current = data;
|
||||||
setFieldErrors({});
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import Header from "@/components/header";
|
|
||||||
import Footer from "@/components/footer";
|
|
||||||
import { getPageBySlug, getBlocksByPageId } from "@/lib/pages/repository";
|
import { getPageBySlug, getBlocksByPageId } from "@/lib/pages/repository";
|
||||||
import { getCurrentUser } from "@/lib/user";
|
import { getCurrentUser } from "@/lib/user";
|
||||||
import { redirect, notFound } from "next/navigation";
|
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) : [];
|
const blocks = page ? await getBlocksByPageId(page.id) : [];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<EditPageClient page={page ?? null} pageType={pageType} initialBlocks={blocks} />
|
||||||
<Header />
|
|
||||||
<EditPageClient page={page ?? null} pageType={pageType} initialBlocks={blocks} />
|
|
||||||
<Footer />
|
|
||||||
</>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
+38
-42
@@ -53,7 +53,7 @@ function BlockRenderer({ block }: { block: Block }) {
|
|||||||
|
|
||||||
case "CALLOUT":
|
case "CALLOUT":
|
||||||
return (
|
return (
|
||||||
<Alert className="w-max">
|
<Alert className="md:w-max">
|
||||||
<InfoIcon />
|
<InfoIcon />
|
||||||
<AlertTitle>{b.title}</AlertTitle>
|
<AlertTitle>{b.title}</AlertTitle>
|
||||||
<AlertDescription>{b.text}</AlertDescription>
|
<AlertDescription>{b.text}</AlertDescription>
|
||||||
@@ -68,11 +68,11 @@ function BlockRenderer({ block }: { block: Block }) {
|
|||||||
alt={b.caption || "Image"}
|
alt={b.caption || "Image"}
|
||||||
width={1200}
|
width={1200}
|
||||||
height={800}
|
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 && (
|
{b.caption && (
|
||||||
<figcaption className="text-sm text-muted-foreground">
|
<figcaption className="text-xs md:text-sm text-muted-foreground">
|
||||||
{b.caption}
|
{b.caption}
|
||||||
</figcaption>
|
</figcaption>
|
||||||
)}
|
)}
|
||||||
@@ -83,13 +83,13 @@ function BlockRenderer({ block }: { block: Block }) {
|
|||||||
return b.style === "ORDERED" ? (
|
return b.style === "ORDERED" ? (
|
||||||
<div className="flex flex-col gap-2">
|
<div className="flex flex-col gap-2">
|
||||||
{b.items.map((item: string, index: number) => (
|
{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>
|
||||||
) : (
|
) : (
|
||||||
<div className="flex flex-col gap-2">
|
<div className="flex flex-col gap-2">
|
||||||
{b.items.map((item: string, index: number) => (
|
{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>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -124,7 +124,7 @@ function BlockRenderer({ block }: { block: Block }) {
|
|||||||
|
|
||||||
case "LINK":
|
case "LINK":
|
||||||
return <Link href={b.href} target="_blank">
|
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>
|
</Link>
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -166,44 +166,40 @@ export default async function Page({ params }: { params: Promise<{ type: string;
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<div className="flex flex-col p-4 md:p-16 gap-6 md:gap-12 mb-4 md:mb-0">
|
||||||
<Header />
|
<div className={cn("flex flex-col gap-8 md:gap-4 justify-center", isNews && "md:items-center")}>
|
||||||
<div className="flex flex-col p-16 gap-12">
|
<div className="flex flex-col md:flex-row items-center gap-2 md:gap-6">
|
||||||
<div className={cn("flex flex-col gap-4 justify-center", isNews && "items-center")}>
|
<h1>{page?.title}</h1>
|
||||||
<div className="flex flex-row items-center gap-6">
|
{user?.isAdmin && (
|
||||||
<h1>{page?.title}</h1>
|
<div className="flex flex-row gap-2 items-center">
|
||||||
{user?.isAdmin && (
|
<Link href={`/${page.type.toLowerCase()}/${page.slug}/edit`}>
|
||||||
<div className="flex flex-row gap-2 items-center">
|
<Button variant="secondary" size="icon-sm"><PencilIcon /></Button>
|
||||||
<Link href={`/${page.type.toLowerCase()}/${page.slug}/edit`}>
|
</Link>
|
||||||
<Button variant="secondary" size="icon-sm"><PencilIcon /></Button>
|
{!isArchived && <ArchiveButton pageId={page.id} slug={page.slug} type={page.type} />}
|
||||||
</Link>
|
{!isArchived && <PinToggleButton pageId={page.id} isPinned={!!navlink} />}
|
||||||
{!isArchived && <ArchiveButton pageId={page.id} slug={page.slug} type={page.type} />}
|
</div>
|
||||||
{!isArchived && <PinToggleButton label={page.title} pageId={page.id} isPinned={!!navlink} />}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
<div className="flex flex-row gap-6 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>}
|
|
||||||
{meta.author && <p className="flex gap-1.5 items-center"><UserIcon size={16} />{meta.author}</p>}
|
|
||||||
{meta.updatedBy && <p className="flex gap-1.5 items-center"><UserIcon size={16} />Last update by {meta.updatedBy}</p>}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="flex flex-col gap-6">
|
|
||||||
{isArchived && (
|
|
||||||
<Alert className="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>
|
|
||||||
</Alert>
|
|
||||||
)}
|
)}
|
||||||
{blocks.map((block) => (
|
</div>
|
||||||
<BlockRenderer key={block.id} block={block} />
|
<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>}
|
||||||
|
{meta.author && <p className="flex gap-1.5 items-center"><UserIcon size={16} />{meta.author}</p>}
|
||||||
|
{meta.updatedBy && <p className="flex gap-1.5 items-center"><UserIcon size={16} />Last update by {meta.updatedBy}</p>}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Footer />
|
<div className="flex flex-col gap-6">
|
||||||
</>
|
{isArchived && (
|
||||||
|
<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>
|
||||||
|
</Alert>
|
||||||
|
)}
|
||||||
|
{blocks.map((block) => (
|
||||||
|
<BlockRenderer key={block.id} block={block} />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1,22 +1,18 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useTransition } from "react";
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { PinIcon, PinOffIcon } from "lucide-react";
|
import { PinIcon, PinOffIcon } from "lucide-react";
|
||||||
import { Spinner } from "@/components/ui/spinner";
|
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 }) {
|
export function PinToggleButton({ pageId, isPinned }: { pageId: string; isPinned: boolean }) {
|
||||||
const [isPending, startTransition] = useTransition();
|
const { run, isPending } = useAction(togglePinAction, {
|
||||||
|
successMessage: isPinned ? "Page unpinned" : "Page pinned",
|
||||||
const handleClick = () => {
|
});
|
||||||
startTransition(() =>
|
|
||||||
isPinned ? unpinPageAction(pageId) : pinPageAction(pageId)
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
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 />}
|
{isPending ? <Spinner /> : isPinned ? <PinOffIcon /> : <PinIcon />}
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ export function AccountMenu() {
|
|||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
|
|
||||||
return (
|
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) => {
|
{menuItems.map((item) => {
|
||||||
const Icon = item.icon;
|
const Icon = item.icon;
|
||||||
const active = pathname === item.href;
|
const active = pathname === item.href;
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ export function CitizenshipApplicationForm({ firstName, secondName, sex, birthDa
|
|||||||
<FieldGroup>
|
<FieldGroup>
|
||||||
<FieldSet>
|
<FieldSet>
|
||||||
<FieldLegend>Personal information</FieldLegend>
|
<FieldLegend>Personal information</FieldLegend>
|
||||||
<Alert variant="warning">
|
<Alert className="mt-2" variant="warning">
|
||||||
<InfoIcon />
|
<InfoIcon />
|
||||||
<AlertTitle>Important notice</AlertTitle>
|
<AlertTitle>Important notice</AlertTitle>
|
||||||
<AlertDescription>
|
<AlertDescription>
|
||||||
@@ -251,7 +251,7 @@ export function CitizenshipApplicationForm({ firstName, secondName, sex, birthDa
|
|||||||
<FieldLegend>Additional information</FieldLegend>
|
<FieldLegend>Additional information</FieldLegend>
|
||||||
<FieldDescription>Provide details required for your identity document.</FieldDescription>
|
<FieldDescription>Provide details required for your identity document.</FieldDescription>
|
||||||
<FieldGroup>
|
<FieldGroup>
|
||||||
<div className="grid grid-cols-2 gap-4">
|
<div className="grid md:grid-cols-2 gap-4">
|
||||||
<Field data-invalid={!!errors.height?.length}>
|
<Field data-invalid={!!errors.height?.length}>
|
||||||
<FieldLabel htmlFor="height">Height (in cm)</FieldLabel>
|
<FieldLabel htmlFor="height">Height (in cm)</FieldLabel>
|
||||||
<Input
|
<Input
|
||||||
@@ -293,6 +293,8 @@ export function CitizenshipApplicationForm({ firstName, secondName, sex, birthDa
|
|||||||
label="Profile"
|
label="Profile"
|
||||||
description="Select a profile image to upload. The image should be taken on a neutral background."
|
description="Select a profile image to upload. The image should be taken on a neutral background."
|
||||||
error={errors.profile?.[0]}
|
error={errors.profile?.[0]}
|
||||||
|
previewClassName="aspect-4/5"
|
||||||
|
removeBg
|
||||||
/>
|
/>
|
||||||
<ImageUploadField
|
<ImageUploadField
|
||||||
id="signature"
|
id="signature"
|
||||||
@@ -300,6 +302,7 @@ export function CitizenshipApplicationForm({ firstName, secondName, sex, birthDa
|
|||||||
label="Signature"
|
label="Signature"
|
||||||
description="Select a signature to upload."
|
description="Select a signature to upload."
|
||||||
error={errors.signature?.[0]}
|
error={errors.signature?.[0]}
|
||||||
|
previewClassName="aspect-5/2"
|
||||||
/>
|
/>
|
||||||
</FieldGroup>
|
</FieldGroup>
|
||||||
</FieldSet>
|
</FieldSet>
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useState } from "react";
|
import { useRef, useState } from "react";
|
||||||
import { Field, FieldDescription, FieldError, FieldLabel } from "@/components/ui/field";
|
import { Field, FieldDescription, FieldError, FieldLabel } from "@/components/ui/field";
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
import { XIcon, ImageIcon } from "lucide-react";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
import { removeBackground } from "@imgly/background-removal";
|
||||||
|
import { Spinner } from "@/components/ui/spinner";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -11,41 +15,74 @@ type Props = {
|
|||||||
label: string;
|
label: string;
|
||||||
description: string;
|
description: string;
|
||||||
error?: 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 [previewUrl, setPreviewUrl] = useState<string | null>(null);
|
||||||
|
const [fileInfo, setFileInfo] = useState<{ name: string; size: number } | null>(null);
|
||||||
const [clientError, setClientError] = useState<string | null>(null);
|
const [clientError, setClientError] = useState<string | null>(null);
|
||||||
|
const [isProcessing, setIsProcessing] = useState(false);
|
||||||
|
|
||||||
const MAX_SIZE = 5 * 1024 * 1024;
|
function reset() {
|
||||||
const ACCEPTED_TYPES = ["image/jpeg", "image/png", "image/webp"];
|
|
||||||
|
|
||||||
function handleChange(e: React.ChangeEvent<HTMLInputElement>) {
|
|
||||||
const file = e.target.files?.[0];
|
|
||||||
if (previewUrl) URL.revokeObjectURL(previewUrl);
|
if (previewUrl) URL.revokeObjectURL(previewUrl);
|
||||||
|
setPreviewUrl(null);
|
||||||
|
setFileInfo(null);
|
||||||
|
if (inputRef.current) inputRef.current.value = "";
|
||||||
|
}
|
||||||
|
|
||||||
if (!file) {
|
async function handleChange(e: React.ChangeEvent<HTMLInputElement>) {
|
||||||
setPreviewUrl(null);
|
const file = e.target.files?.[0];
|
||||||
setClientError(null);
|
if (!file) { reset(); setClientError(null); return; }
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ACCEPTED_TYPES.includes(file.type)) {
|
if (!ACCEPTED_TYPES.includes(file.type)) {
|
||||||
setClientError("Only JPEG, PNG, or WEBP images are allowed.");
|
setClientError("Only JPEG, PNG, or WEBP images are allowed.");
|
||||||
setPreviewUrl(null);
|
reset();
|
||||||
e.target.value = "";
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file.size > MAX_SIZE) {
|
if (file.size > MAX_SIZE) {
|
||||||
setClientError("Image must be smaller than 5MB.");
|
setClientError("Image must be smaller than 5MB.");
|
||||||
setPreviewUrl(null);
|
reset();
|
||||||
e.target.value = "";
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setClientError(null);
|
setClientError(null);
|
||||||
setPreviewUrl(URL.createObjectURL(file));
|
|
||||||
|
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;
|
const displayedError = clientError ?? error;
|
||||||
@@ -53,27 +90,47 @@ export function ImageUploadField({ id, name, label, description, error }: Props)
|
|||||||
return (
|
return (
|
||||||
<Field data-invalid={!!displayedError}>
|
<Field data-invalid={!!displayedError}>
|
||||||
<FieldLabel htmlFor={id}>{label}</FieldLabel>
|
<FieldLabel htmlFor={id}>{label}</FieldLabel>
|
||||||
<div className="flex items-center gap-4">
|
<div className="flex flex-col md:flex-row items-start gap-4">
|
||||||
{previewUrl && (
|
<div
|
||||||
<img
|
className={cn(
|
||||||
src={previewUrl}
|
"w-28 rounded-md border border-dashed border-foreground/15 bg-muted flex items-center justify-center overflow-hidden shrink-0",
|
||||||
alt=""
|
previewClassName ?? "aspect-4/5"
|
||||||
className={cn(
|
)}
|
||||||
"w-16 h-16 rounded-md object-cover ring-1 ring-foreground/10 shrink-0"
|
>
|
||||||
)}
|
{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}
|
||||||
|
disabled={isProcessing}
|
||||||
|
required={!fileInfo}
|
||||||
/>
|
/>
|
||||||
)}
|
{fileInfo && (
|
||||||
<Input
|
<div className="flex items-center gap-2 text-sm text-muted-foreground w-full min-w-0">
|
||||||
id={id}
|
<span className="flex-1 min-w-0 truncate">
|
||||||
name={name}
|
{fileInfo.name} ({formatFileSize(fileInfo.size)})
|
||||||
type="file"
|
</span>
|
||||||
accept="image/jpeg,image/png,image/webp"
|
<Button type="button" variant="ghost" size="icon" className="h-6 w-6" onClick={reset} disabled={isProcessing}>
|
||||||
aria-invalid={!!displayedError}
|
<XIcon size={14} />
|
||||||
onChange={handleChange}
|
</Button>
|
||||||
required
|
</div>
|
||||||
/>
|
)}
|
||||||
|
<FieldDescription className="mt-1">{description}</FieldDescription>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<FieldDescription>{description}</FieldDescription>
|
|
||||||
{displayedError && <FieldError>{displayedError}</FieldError>}
|
{displayedError && <FieldError>{displayedError}</FieldError>}
|
||||||
</Field>
|
</Field>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import Footer from "@/components/footer";
|
|
||||||
import Header from "@/components/header";
|
|
||||||
import { getCurrentUser } from "@/lib/user";
|
import { getCurrentUser } from "@/lib/user";
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
import { AccountMenu } from "../../account-menu";
|
import { AccountMenu } from "../../account-menu";
|
||||||
@@ -17,34 +15,30 @@ export default async function CitizenshipApplication() {
|
|||||||
const regions = await prisma.region.findMany({ orderBy: { name: "asc" } });
|
const regions = await prisma.region.findMany({ orderBy: { name: "asc" } });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<div className="flex flex-col md:flex-row p-4 md:p-16 gap-8 md:gap-16 mb-4 md:mb-0">
|
||||||
<Header />
|
<AccountMenu />
|
||||||
<div className="flex flex-row py-16 gap-8">
|
<div className="flex flex-col gap-8 w-full">
|
||||||
<AccountMenu />
|
<div className="flex flex-col gap-6">
|
||||||
<div className="flex flex-col gap-8">
|
<h2>Citizenship application</h2>
|
||||||
<div className="flex flex-col gap-6">
|
<div className="max-w-96 w-full flex flex-col gap-6">
|
||||||
<h2>Citizenship application</h2>
|
{!eligibility.eligible ? (
|
||||||
<div className="w-96 flex flex-col gap-6">
|
<Alert variant="warning">
|
||||||
{!eligibility.eligible ? (
|
<InfoIcon />
|
||||||
<Alert variant="warning">
|
<AlertTitle>Cannot submit application</AlertTitle>
|
||||||
<InfoIcon />
|
<AlertDescription>{eligibility.reason}</AlertDescription>
|
||||||
<AlertTitle>Cannot submit application</AlertTitle>
|
</Alert>
|
||||||
<AlertDescription>{eligibility.reason}</AlertDescription>
|
) : (
|
||||||
</Alert>
|
<CitizenshipApplicationForm
|
||||||
) : (
|
firstName={user.firstName}
|
||||||
<CitizenshipApplicationForm
|
secondName={user.secondName}
|
||||||
firstName={user.firstName}
|
sex={user.sex}
|
||||||
secondName={user.secondName}
|
birthDate={user.birthDate!}
|
||||||
sex={user.sex}
|
regions={regions}
|
||||||
birthDate={user.birthDate!}
|
/>
|
||||||
regions={regions}
|
)}
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Footer />
|
</div>
|
||||||
</>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -34,11 +34,9 @@ export async function HasCitizenship({ userId }: { userId: string }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col gap-8">
|
<div className="flex flex-col gap-6 md:gap-8">
|
||||||
<IdentityCard data={identityDocument} />
|
<IdentityCard data={identityDocument} />
|
||||||
<div className="flex flex-col gap-2">
|
<RenunciationDialog citizenship={citizenship} />
|
||||||
<RenunciationDialog citizenship={citizenship} />
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,13 +25,13 @@ export async function NoCitizenship({ userId }: { userId: string }) {
|
|||||||
</AlertDescription>
|
</AlertDescription>
|
||||||
</Alert>
|
</Alert>
|
||||||
|
|
||||||
<div className="flex flex-col gap-3">
|
<div className="flex flex-col gap-3 w-full">
|
||||||
<div className="flex flex-row gap-3 w-max">
|
<div className="flex flex-col md:flex-row gap-3">
|
||||||
<Link href="/page/citizenship">
|
<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>
|
||||||
<Link href="/account/citizenship/apply">
|
<Link href="/account/citizenship/apply">
|
||||||
<Button>Apply for citizenship</Button>
|
<Button className="w-full">Apply for citizenship</Button>
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
{applications.length > 0 && <ApplicationsDialog applications={applications} />}
|
{applications.length > 0 && <ApplicationsDialog applications={applications} />}
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import Footer from "@/components/footer";
|
|
||||||
import Header from "@/components/header";
|
|
||||||
import { getCurrentUser } from "@/lib/user";
|
import { getCurrentUser } from "@/lib/user";
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
import { AccountMenu } from "../account-menu";
|
import { AccountMenu } from "../account-menu";
|
||||||
@@ -17,30 +15,26 @@ export default async function Citizenship() {
|
|||||||
const pendingCount = user.isAdmin ? await getPendingApplicationsCount() : 0
|
const pendingCount = user.isAdmin ? await getPendingApplicationsCount() : 0
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<div className="flex flex-col md:flex-row p-4 md:p-16 gap-8 md:gap-16 mb-4 md:mb-0">
|
||||||
<Header />
|
<AccountMenu />
|
||||||
<div className="flex flex-row py-16 gap-8">
|
<div className="flex flex-col gap-8 max-w-lg">
|
||||||
<AccountMenu />
|
<div className="flex flex-col gap-6 md:w-min">
|
||||||
<div className="flex flex-col gap-8 max-w-lg">
|
<h2>Citizenship</h2>
|
||||||
<div className="flex flex-col gap-6 w-min">
|
|
||||||
<h2>Citizenship</h2>
|
|
||||||
|
|
||||||
{citizenship ? <HasCitizenship userId={user.id} /> : <NoCitizenship userId={user.id} />}
|
{citizenship ? <HasCitizenship userId={user.id} /> : <NoCitizenship userId={user.id} />}
|
||||||
|
|
||||||
{user.isAdmin && (
|
{user.isAdmin && (
|
||||||
<Link href="/account/citizenship/review">
|
<Link href="/account/citizenship/review">
|
||||||
<Button variant="secondary" className="w-full">
|
<Button variant="secondary" className="w-full">
|
||||||
Review citizenship applications
|
Review citizenship applications
|
||||||
<div className="flex items-center justify-center bg-black/50 text-white w-3.5 h-3.5 text-xs rounded-full">
|
<div className="flex items-center justify-center bg-black/50 text-white w-3.5 h-3.5 text-xs rounded-full">
|
||||||
{pendingCount}
|
{pendingCount}
|
||||||
</div>
|
</div>
|
||||||
</Button>
|
</Button>
|
||||||
</Link>
|
</Link>
|
||||||
)}
|
)}
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Footer />
|
</div>
|
||||||
</>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -45,7 +45,7 @@ export function RenunciationDialog({ citizenship }: { citizenship: Citizenship }
|
|||||||
<DialogClose asChild>
|
<DialogClose asChild>
|
||||||
<Button variant="secondary">Cancel</Button>
|
<Button variant="secondary">Cancel</Button>
|
||||||
</DialogClose>
|
</DialogClose>
|
||||||
<Button variant="destructive" disabled={isPending} onClick={() => run()}>
|
<Button disabled={isPending} onClick={() => run()}>
|
||||||
{isPending && <Spinner />}Renounce citizenship
|
{isPending && <Spinner />}Renounce citizenship
|
||||||
</Button>
|
</Button>
|
||||||
</DialogFooter>
|
</DialogFooter>
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, D
|
|||||||
import { Separator } from "@/components/ui/separator";
|
import { Separator } from "@/components/ui/separator";
|
||||||
import { Spinner } from "@/components/ui/spinner";
|
import { Spinner } from "@/components/ui/spinner";
|
||||||
import { Textarea } from "@/components/ui/textarea";
|
import { Textarea } from "@/components/ui/textarea";
|
||||||
|
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
|
||||||
import { approveApplication, rejectApplication } from "@/lib/citizenship/actions";
|
import { approveApplication, rejectApplication } from "@/lib/citizenship/actions";
|
||||||
import { CitizenshipApplicationWithWarning } from "@/lib/citizenship/types";
|
import { CitizenshipApplicationWithWarning } from "@/lib/citizenship/types";
|
||||||
import { formatDate } from "@/lib/utils";
|
import { formatDate } from "@/lib/utils";
|
||||||
@@ -22,7 +23,7 @@ export default function ApplicationCard({ application, onClose }: { application:
|
|||||||
|
|
||||||
if (!application?.id) {
|
if (!application?.id) {
|
||||||
return (
|
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
|
Click on a row to see the application
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
@@ -64,18 +65,14 @@ export default function ApplicationCard({ application, onClose }: { application:
|
|||||||
<CardDescription>{application.applicationType === "PREVIOUS_CITIZENSHIP" ? "Previous citizenship application" : "Naturalization application"}</CardDescription>
|
<CardDescription>{application.applicationType === "PREVIOUS_CITIZENSHIP" ? "Previous citizenship application" : "Naturalization application"}</CardDescription>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent className="max-w-sm">
|
<CardContent className="max-w-sm">
|
||||||
<div className="flex flex-row gap-2 mb-2">
|
<div className="flex flex-row gap-3 mb-4">
|
||||||
<img
|
<div className="w-20 aspect-4/5 rounded-md overflow-hidden ring-1 ring-foreground/10 shrink-0">
|
||||||
src={application.profileUrl}
|
<img src={application.profileUrl} alt="Profile photo" className="w-full h-full object-cover" />
|
||||||
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>
|
</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">
|
<div className="flex flex-col gap-1">
|
||||||
<h4 className="mb-1">Personal information</h4>
|
<h4 className="mb-1">Personal information</h4>
|
||||||
{ application.nameMismatch && (
|
{ application.nameMismatch && (
|
||||||
@@ -110,7 +107,14 @@ export default function ApplicationCard({ application, onClose }: { application:
|
|||||||
</div>
|
</div>
|
||||||
<div className="flex flex-col gap-0.5">
|
<div className="flex flex-col gap-0.5">
|
||||||
<p className="text-muted-foreground">Address</p>
|
<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>
|
||||||
<div className="flex flex-row gap-4 items-center">
|
<div className="flex flex-row gap-4 items-center">
|
||||||
<p className="text-muted-foreground">Height</p>
|
<p className="text-muted-foreground">Height</p>
|
||||||
@@ -169,7 +173,7 @@ export default function ApplicationCard({ application, onClose }: { application:
|
|||||||
/>
|
/>
|
||||||
<DialogFooter>
|
<DialogFooter>
|
||||||
<Button variant="outline" onClick={() => setRejectOpen(false)}>Cancel</Button>
|
<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
|
{isloading && <Spinner />}Confirm rejection
|
||||||
</Button>
|
</Button>
|
||||||
</DialogFooter>
|
</DialogFooter>
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ export default function ReviewPageClient({ applications }: { applications: Citiz
|
|||||||
|
|
||||||
return (
|
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-8">
|
||||||
<div className="flex flex-col gap-6">
|
<div className="flex flex-col gap-6">
|
||||||
<h2>Review citizenship applications</h2>
|
<h2>Review citizenship applications</h2>
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import Header from "@/components/header";
|
|
||||||
import Footer from "@/components/footer";
|
|
||||||
import ReviewPageClient from "./client";
|
import ReviewPageClient from "./client";
|
||||||
import { getCurrentUser } from "@/lib/user";
|
import { getCurrentUser } from "@/lib/user";
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
@@ -29,13 +27,9 @@ export default async function ReviewPage() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<div className="flex flex-col md:flex-row p-4 md:p-16 gap-8 md:gap-16 mb-4 md:mb-0">
|
||||||
<Header />
|
<AccountMenu />
|
||||||
<div className="flex flex-row py-16 gap-8">
|
<ReviewPageClient applications={applicationsWithWarning} />
|
||||||
<AccountMenu />
|
</div>
|
||||||
<ReviewPageClient applications={applicationsWithWarning} />
|
|
||||||
</div>
|
|
||||||
<Footer />
|
|
||||||
</>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
+37
-44
@@ -1,9 +1,6 @@
|
|||||||
import Footer from "@/components/footer";
|
|
||||||
import Header from "@/components/header";
|
|
||||||
import { Separator } from "@/components/ui/separator";
|
import { Separator } from "@/components/ui/separator";
|
||||||
import { getCurrentUser } from "@/lib/user";
|
import { getCurrentUser } from "@/lib/user";
|
||||||
import { formatDate } from "@/lib/utils";
|
import { formatDate } from "@/lib/utils";
|
||||||
import { BookOpenTextIcon, SignatureIcon, UserIcon } from "lucide-react";
|
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
import { DeleteDialog } from "./delete-dialog";
|
import { DeleteDialog } from "./delete-dialog";
|
||||||
import { LogoutButton } from "./logout-button";
|
import { LogoutButton } from "./logout-button";
|
||||||
@@ -24,52 +21,48 @@ export default async function Account() {
|
|||||||
if (!user) redirect("/");
|
if (!user) redirect("/");
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<div className="flex flex-col md:flex-row p-4 md:p-16 gap-8 md:gap-16 mb-4 md:mb-0">
|
||||||
<Header />
|
<AccountMenu />
|
||||||
<div className="flex flex-row py-16 gap-8">
|
<div className="flex flex-col gap-8 max-w-lg">
|
||||||
<AccountMenu />
|
<div className="flex flex-col gap-6">
|
||||||
<div className="flex flex-col gap-8 max-w-lg">
|
<div className="flex flex-col gap-1">
|
||||||
<div className="flex flex-col gap-6">
|
<h2>Personal details</h2>
|
||||||
<div className="flex flex-col gap-1">
|
<p className="text-muted-foreground text-sm">
|
||||||
<h2>Personal details</h2>
|
Synced from your Kotosoft ID account. To correct any details, update them there first, then click Update below.
|
||||||
<p className="text-muted-foreground text-sm">
|
</p>
|
||||||
Synced from your Kotosoft ID account. To correct any details, update them there first, then click Update below.
|
</div>
|
||||||
</p>
|
<div className="flex flex-col gap-4">
|
||||||
|
<ProfileField label="Name" value={`${user.firstName} ${user.secondName}`} />
|
||||||
|
<ProfileField label="Email" value={user.email} />
|
||||||
|
<ProfileField label="Birthday" value={formatDate(user.birthDate)} />
|
||||||
|
<ProfileField label="Sex" value={user.sex === "MALE" ? "Male" : "Female"} />
|
||||||
|
{user.isAdmin && <ProfileField label="Role" value="Administrator" />}
|
||||||
|
</div>
|
||||||
|
<Separator />
|
||||||
|
<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>
|
</div>
|
||||||
<div className="flex flex-col gap-4">
|
<UpdateButton />
|
||||||
<ProfileField label="Name" value={`${user.firstName} ${user.secondName}`} />
|
</div>
|
||||||
<ProfileField label="Email" value={user.email} />
|
<div className="flex flex-row items-center justify-between gap-2">
|
||||||
<ProfileField label="Birthday" value={formatDate(user.birthDate)} />
|
<div className="flex flex-col">
|
||||||
<ProfileField label="Sex" value={user.sex === "MALE" ? "Male" : "Female"} />
|
<h4>Log out</h4>
|
||||||
{user.isAdmin && <ProfileField label="Role" value="Administrator" />}
|
<p className="text-muted-foreground">Log out from your account on this device</p>
|
||||||
</div>
|
</div>
|
||||||
<Separator />
|
<LogoutButton />
|
||||||
<div className="flex flex-row items-center justify-between">
|
</div>
|
||||||
<div className="flex flex-col">
|
<Separator />
|
||||||
<h4>Update personal details</h4>
|
<div className="flex flex-row items-center justify-between gap-2">
|
||||||
<p className="text-muted-foreground">Syncs your name, email, and birthday from Kotosoft ID</p>
|
<div className="flex flex-col">
|
||||||
</div>
|
<h4>Delete account</h4>
|
||||||
<UpdateButton />
|
<p className="text-muted-foreground">Permanently delete your account and all associated data</p>
|
||||||
</div>
|
|
||||||
<div className="flex flex-row items-center justify-between">
|
|
||||||
<div className="flex flex-col">
|
|
||||||
<h4>Log out</h4>
|
|
||||||
<p className="text-muted-foreground">Log out from your account on this device</p>
|
|
||||||
</div>
|
|
||||||
<LogoutButton />
|
|
||||||
</div>
|
|
||||||
<Separator />
|
|
||||||
<div className="flex flex-row items-center justify-between">
|
|
||||||
<div className="flex flex-col">
|
|
||||||
<h4>Delete account</h4>
|
|
||||||
<p className="text-muted-foreground">Permanently delete your account and all associated data</p>
|
|
||||||
</div>
|
|
||||||
<DeleteDialog />
|
|
||||||
</div>
|
</div>
|
||||||
|
<DeleteDialog />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Footer />
|
</div>
|
||||||
</>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
+20
-47
@@ -1,18 +1,20 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useRef, useState, useTransition } from "react";
|
import { useRef } from "react";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import Editor, { EditorData } from "@/components/editor";
|
import Editor, { EditorData } from "@/components/editor";
|
||||||
import { savePageAction } from "@/lib/pages/actions";
|
import { savePageAction } from "@/lib/pages/actions";
|
||||||
import { validatePage } from "@/lib/pages/validation";
|
import { Spinner } from "@/components/ui/spinner";
|
||||||
import { Loader2 } from "lucide-react";
|
import { useAction } from "@/hooks/useAction";
|
||||||
import { toast } from "sonner";
|
|
||||||
|
|
||||||
export default function CreatePageClient() {
|
export default function CreatePageClient() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [isPending, startTransition] = useTransition();
|
const { run, isPending } = useAction(savePageAction, {
|
||||||
const [fieldErrors, setFieldErrors] = useState<{ title?: string[]; slug?: string[] }>({});
|
successMessage: "Page saved",
|
||||||
|
onSuccess: () => router.push("/news"),
|
||||||
|
});
|
||||||
|
|
||||||
const dataRef = useRef<EditorData>({
|
const dataRef = useRef<EditorData>({
|
||||||
title: "",
|
title: "",
|
||||||
type: "NEWS",
|
type: "NEWS",
|
||||||
@@ -23,47 +25,20 @@ export default function CreatePageClient() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function handleSave(status: "DRAFT" | "PUBLISHED") {
|
function handleSave(status: "DRAFT" | "PUBLISHED") {
|
||||||
startTransition(async () => {
|
const data = dataRef.current;
|
||||||
const data = dataRef.current;
|
run({
|
||||||
const payload = {
|
id: null,
|
||||||
id: null,
|
slug: data.slug || data.title.toLowerCase().replace(/\s+/g, "-"),
|
||||||
slug: data.slug || data.title.toLowerCase().replace(/\s+/g, "-"),
|
title: data.title,
|
||||||
title: data.title,
|
type: data.type,
|
||||||
type: data.type,
|
status,
|
||||||
status,
|
blocks: data.blocks,
|
||||||
blocks: data.blocks,
|
meta: { location: data.location, tags: data.tags },
|
||||||
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 (
|
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">
|
<div className="flex flex-row items-center justify-between">
|
||||||
<h1>Create page</h1>
|
<h1>Create page</h1>
|
||||||
<div className="flex flex-row gap-3">
|
<div className="flex flex-row gap-3">
|
||||||
@@ -72,11 +47,11 @@ export default function CreatePageClient() {
|
|||||||
disabled={isPending}
|
disabled={isPending}
|
||||||
onClick={() => handleSave("DRAFT")}
|
onClick={() => handleSave("DRAFT")}
|
||||||
>
|
>
|
||||||
{isPending && <Loader2 size={14} className="animate-spin mr-1" />}
|
{isPending && <Spinner />}
|
||||||
Save as draft
|
Save as draft
|
||||||
</Button>
|
</Button>
|
||||||
<Button disabled={isPending} onClick={() => handleSave("PUBLISHED")}>
|
<Button disabled={isPending} onClick={() => handleSave("PUBLISHED")}>
|
||||||
{isPending && <Loader2 size={14} className="animate-spin mr-1" />}
|
{isPending && <Spinner />}
|
||||||
Publish
|
Publish
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
@@ -84,9 +59,7 @@ export default function CreatePageClient() {
|
|||||||
<Editor
|
<Editor
|
||||||
onChange={(data) => {
|
onChange={(data) => {
|
||||||
dataRef.current = data;
|
dataRef.current = data;
|
||||||
setFieldErrors({});
|
|
||||||
}}
|
}}
|
||||||
errors={fieldErrors}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
+1
-7
@@ -1,5 +1,3 @@
|
|||||||
import Header from "@/components/header";
|
|
||||||
import Footer from "@/components/footer";
|
|
||||||
import { getCurrentUser } from "@/lib/user";
|
import { getCurrentUser } from "@/lib/user";
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
import CreatePageClient from "./client";
|
import CreatePageClient from "./client";
|
||||||
@@ -9,10 +7,6 @@ export default async function CreatePage() {
|
|||||||
if (!user?.isAdmin) redirect("/");
|
if (!user?.isAdmin) redirect("/");
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<CreatePageClient />
|
||||||
<Header />
|
|
||||||
<CreatePageClient />
|
|
||||||
<Footer />
|
|
||||||
</>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -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>
|
||||||
|
)
|
||||||
|
}
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 5.9 KiB |
+35
-10
@@ -4,6 +4,16 @@
|
|||||||
|
|
||||||
@custom-variant dark (&:is(.dark *));
|
@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 {
|
@theme inline {
|
||||||
--color-background: var(--background);
|
--color-background: var(--background);
|
||||||
--color-foreground: var(--foreground);
|
--color-foreground: var(--foreground);
|
||||||
@@ -133,29 +143,44 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
h1 {
|
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 {
|
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 {
|
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 {
|
h4 {
|
||||||
@apply text-lg tracking-tight
|
font-size: clamp(1rem, 0.9482rem + 0.221vw, 1.125rem);
|
||||||
}
|
line-height: 1.35;
|
||||||
|
letter-spacing: -0.02em;
|
||||||
p {
|
|
||||||
@apply text-base tracking-tight
|
|
||||||
}
|
}
|
||||||
|
|
||||||
h5 {
|
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 {
|
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
@@ -3,6 +3,9 @@ import localFont from "next/font/local"
|
|||||||
import "./globals.css";
|
import "./globals.css";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
import { Toaster } from "@/components/ui/sonner";
|
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({
|
const helvetica = localFont({
|
||||||
src: "../public/fonts/HelveticaNeue-Medium.otf",
|
src: "../public/fonts/HelveticaNeue-Medium.otf",
|
||||||
@@ -25,7 +28,11 @@ export default function RootLayout({
|
|||||||
className={cn("h-full", "antialiased", helvetica.className, "font-sans")}
|
className={cn("h-full", "antialiased", helvetica.className, "font-sans")}
|
||||||
>
|
>
|
||||||
<body className="min-h-full flex flex-col">
|
<body className="min-h-full flex flex-col">
|
||||||
{children}
|
<TooltipProvider>
|
||||||
|
<Header />
|
||||||
|
<div className="flex-1">{children}</div>
|
||||||
|
<Footer />
|
||||||
|
</TooltipProvider>
|
||||||
<Toaster />
|
<Toaster />
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
+18
-24
@@ -1,6 +1,4 @@
|
|||||||
import DraftsDialog from "@/components/drafts-dialog";
|
import DraftsDialog from "@/components/drafts-dialog";
|
||||||
import Footer from "@/components/footer";
|
|
||||||
import Header from "@/components/header";
|
|
||||||
import { NewsCard } from "@/components/news-card";
|
import { NewsCard } from "@/components/news-card";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { getPages } from "@/lib/pages/repository";
|
import { getPages } from "@/lib/pages/repository";
|
||||||
@@ -17,29 +15,25 @@ export default async function News() {
|
|||||||
const drafts = [...newsDrafts, ...pageDrafts];
|
const drafts = [...newsDrafts, ...pageDrafts];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<div className="flex flex-col p-4 md:p-16 gap-8 md:gap-16 mb-4 md:mb-0">
|
||||||
<Header />
|
<div className="flex flex-col gap-4 md:flex-row md:items-center justify-between">
|
||||||
<div className="flex flex-col p-16 gap-16">
|
<h1>News</h1>
|
||||||
<div className="flex flex-row items-center justify-between">
|
<div className="flex flex-row items-center gap-4">
|
||||||
<h1>News</h1>
|
{user?.isAdmin && (
|
||||||
<div className="flex flex-row items-center gap-4">
|
<div className="flex flex-row items-center gap-4">
|
||||||
{user?.isAdmin && (
|
<DraftsDialog drafts={drafts} />
|
||||||
<div className="flex flex-row items-center gap-4">
|
<Link href="/create/"><Button variant="secondary">Create a new page</Button></Link>
|
||||||
<DraftsDialog drafts={drafts} />
|
</div>
|
||||||
<Link href="/create/"><Button variant="secondary">Create a new page</Button></Link>
|
)}
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="flex flex-col gap-6">
|
|
||||||
{
|
|
||||||
news.length > 0 ? news.map((n) => (
|
|
||||||
<NewsCard news={n} key={n.id} />
|
|
||||||
)) : <h2 className="text-muted-foreground">There are no news yet...</h2>
|
|
||||||
}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Footer />
|
<div className="flex flex-col gap-6">
|
||||||
</>
|
{
|
||||||
|
news.length > 0 ? news.map((n) => (
|
||||||
|
<NewsCard news={n} key={n.id} />
|
||||||
|
)) : <h2 className="text-muted-foreground">There are no news yet...</h2>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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>
|
||||||
|
)
|
||||||
|
}
|
||||||
+74
-39
@@ -1,5 +1,3 @@
|
|||||||
import Footer from "@/components/footer";
|
|
||||||
import Header from "@/components/header";
|
|
||||||
import { NewsCard } from "@/components/news-card";
|
import { NewsCard } from "@/components/news-card";
|
||||||
import { getPages } from "@/lib/pages/repository";
|
import { getPages } from "@/lib/pages/repository";
|
||||||
import { ArrowRightIcon } from "lucide-react";
|
import { ArrowRightIcon } from "lucide-react";
|
||||||
@@ -9,48 +7,85 @@ export default async function Home() {
|
|||||||
const news = await getPages("NEWS", "PUBLISHED", 5);
|
const news = await getPages("NEWS", "PUBLISHED", 5);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<div className="flex flex-col p-4 md:p-16 gap-8 md:gap-16 mb-4 md:mb-0">
|
||||||
<Header />
|
<h1>Welcome to the European Federation!</h1>
|
||||||
<div className="flex flex-col p-16 gap-16">
|
<div className="grid grid-cols-2 gap-4 md:hidden">
|
||||||
<h1>Welcome to the European Federation!</h1>
|
<Link href="/page/citizenship" className="col-span-2">
|
||||||
<div className="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">
|
<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>
|
</div>
|
||||||
</Link>
|
</Link>
|
||||||
<div className="grid grid-rows-2 gap-8">
|
<Link href="/page/president">
|
||||||
<Link href="/page/president">
|
<div className="flex items-end h-28 p-2.5 rounded-lg bg-muted">
|
||||||
<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">
|
||||||
<h2 className="flex flex-row items-center gap-2 hover:gap-4 hover:duration-200 cursor-pointer">Learn more about the President</h2>
|
Learn more about the President
|
||||||
</div>
|
</h2>
|
||||||
</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>
|
|
||||||
<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>
|
|
||||||
</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>
|
||||||
|
</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>
|
||||||
<div className="flex flex-col gap-8 mt-8">
|
<div className="flex items-end h-28 p-2.5 rounded-lg bg-muted">
|
||||||
<h1>Recent news</h1>
|
<h2 className="flex flex-row items-center gap-2 hover:gap-4 hover:duration-200 cursor-pointer">
|
||||||
<div className="flex flex-col gap-6">
|
Regions of the Federation
|
||||||
{
|
</h2>
|
||||||
news.length > 0 ? news.map((n) => (
|
</div>
|
||||||
<NewsCard news={n} key={n.id} />
|
<div className="flex items-end h-28 p-2.5 rounded-lg bg-muted">
|
||||||
)) : <h2 className="text-muted-foreground">There are no news yet...</h2>
|
<h2 className="flex flex-row items-center gap-2 hover:gap-4 hover:duration-200 cursor-pointer">
|
||||||
}
|
Receive consular services abroad
|
||||||
</div>
|
</h2>
|
||||||
<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>
|
||||||
</div>
|
</div>
|
||||||
<Footer />
|
<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>
|
||||||
|
</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>
|
||||||
|
</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>
|
||||||
|
<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>
|
||||||
|
</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>
|
||||||
|
<div className="flex flex-col gap-8 mt-4 lg:mt-8">
|
||||||
|
<h1>Recent news</h1>
|
||||||
|
<div className="flex flex-col gap-6">
|
||||||
|
{
|
||||||
|
news.length > 0 ? news.map((n) => (
|
||||||
|
<NewsCard news={n} key={n.id} />
|
||||||
|
)) : <h2 className="text-muted-foreground">There are no news yet...</h2>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
<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>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
"": {
|
"": {
|
||||||
"name": "e-id",
|
"name": "e-id",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@imgly/background-removal": "^1.7.0",
|
||||||
"@prisma/adapter-pg": "^7.8.0",
|
"@prisma/adapter-pg": "^7.8.0",
|
||||||
"@prisma/client": "^7.8.0",
|
"@prisma/client": "^7.8.0",
|
||||||
"@tanstack/react-table": "^8.21.3",
|
"@tanstack/react-table": "^8.21.3",
|
||||||
@@ -42,7 +43,10 @@
|
|||||||
},
|
},
|
||||||
"trustedDependencies": [
|
"trustedDependencies": [
|
||||||
"sharp",
|
"sharp",
|
||||||
|
"@prisma/engines",
|
||||||
|
"prisma",
|
||||||
"unrs-resolver",
|
"unrs-resolver",
|
||||||
|
"protobufjs",
|
||||||
],
|
],
|
||||||
"packages": {
|
"packages": {
|
||||||
"@alloc/quick-lru": ["@alloc/[email protected]", "", {}, "sha512-UrcABB+4bUrFABwbluTIBErXwvbsU/V7TZWfmbgJfbkwiBuziS9gxdODUyuiecfdGQ85jglMW6juS3+z5TsKLw=="],
|
"@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=="],
|
"@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/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=="],
|
"@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=="],
|
"@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/number": ["@radix-ui/[email protected]", "", {}, "sha512-ceTwaxc4I5IOi97DgCotl3pqiyRGvffcc0oOsE2dQYaJOFIDsDt4VWG6xEbg1QePv9QWausCEIppud/tJ1wNig=="],
|
||||||
|
|
||||||
"@radix-ui/primitive": ["@radix-ui/[email protected]", "", {}, "sha512-7AdCK9PQyiljKoBDbN8OuctCbd/esdwZPQ8RtOE3SsyQtUpiPb+ND75q0jEhC1m1ecBI0MFNeLJvwIh9iKHRcQ=="],
|
"@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=="],
|
"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=="],
|
"flatted": ["[email protected]", "", {}, "sha512-PjDse7RzhcPkIJwy5t7KPWQSZ9cAbzQXcafsetQoD7sOJRQlGikNbx7yZp2OotDnJyrDcbyRq3Ttb18iYOqkxA=="],
|
||||||
|
|
||||||
"for-each": ["[email protected]", "", { "dependencies": { "is-callable": "^1.2.7" } }, "sha512-dKx12eRCVIzqCxFGplyFKJMPvLEWgmNtUrpTiJIR5u97zEhRG8ySrtboPHZXx7daLxQVrl643cTzbab2tkQjxg=="],
|
"for-each": ["[email protected]", "", { "dependencies": { "is-callable": "^1.2.7" } }, "sha512-dKx12eRCVIzqCxFGplyFKJMPvLEWgmNtUrpTiJIR5u97zEhRG8ySrtboPHZXx7daLxQVrl643cTzbab2tkQjxg=="],
|
||||||
@@ -935,6 +961,8 @@
|
|||||||
|
|
||||||
"graphmatch": ["[email protected]", "", {}, "sha512-5ykVn/EXM1hF0XCaWh05VbYvEiOL2lY1kBxZtaYsyvjp7cmWOU1XsAdfQBwClraEofXDT197lFbXOEVMHpvQOg=="],
|
"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-bigints": ["[email protected]", "", {}, "sha512-R3pbpkcIqv2Pm3dUwgjclDRVmWpTJW2DcMzcIhEXEx1oh/CEMObMm3KLmRJOdvhM7o4uQBnwr8pzRK2sJWIqfg=="],
|
||||||
|
|
||||||
"has-flag": ["[email protected]", "", {}, "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ=="],
|
"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=="],
|
"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=="],
|
"ip-address": ["[email protected]", "", {}, "sha512-/+S6j4E9AHvW9SWMSEY9Xfy66O5PWvVEJ08O0y5JGyEKQpojb0K0GKpz/v5HJ/G0vi3D2sjGK78119oXZeE0qA=="],
|
||||||
|
|
||||||
"ipaddr.js": ["[email protected]", "", {}, "sha512-9VGk3HGanVE6JoZXHiCpnGy5X0jYDnN4EA4lntFPj+1vIWlFhIylq2CrrCOJH9EAhc5CYhq18F2Av2tgoAPsYQ=="],
|
"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-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-bun-module": ["[email protected]", "", { "dependencies": { "semver": "^7.7.1" } }, "sha512-gNCGbnnnnFAUGKeZ9PdbyeGYJqewpmc2aKHUEMO5nQPWU9lOmv7jcmQIv+qHD8fXW6W7qfuCwX4rY9LNRjXrkQ=="],
|
||||||
|
|
||||||
"is-callable": ["[email protected]", "", {}, "sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA=="],
|
"is-callable": ["[email protected]", "", {}, "sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA=="],
|
||||||
@@ -1133,6 +1165,8 @@
|
|||||||
|
|
||||||
"lodash": ["[email protected]", "", {}, "sha512-dMInicTPVE8d1e5otfwmmjlxkZoUpiVLwyeTdUsi/Caj/gfzzblBcCE5sRHV/AsjuCmxWrte2TNGSYuCeCq+0Q=="],
|
"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=="],
|
"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=="],
|
"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=="],
|
"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=="],
|
"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=="],
|
"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=="],
|
"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=="],
|
"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=="],
|
"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=="],
|
"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=="],
|
"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=="],
|
"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=="],
|
"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=="],
|
"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=="],
|
"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=="],
|
"@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/@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=="],
|
"@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=="],
|
||||||
|
|||||||
@@ -15,25 +15,44 @@ import Link from "next/link";
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { Spinner } from "@/components/ui/spinner";
|
import { Spinner } from "@/components/ui/spinner";
|
||||||
import { PageType } from "@/lib/pages/types";
|
import { PageType } from "@/lib/pages/types";
|
||||||
|
import { useAction } from "@/hooks/useAction";
|
||||||
|
|
||||||
type Draft = { id: string; type: PageType; title: string; slug: string; updatedAt: Date | null };
|
type Draft = { id: string; type: PageType; title: string; slug: string; updatedAt: Date | null };
|
||||||
|
|
||||||
export default function DraftsDialog({ drafts }: { drafts: Draft[]}) {
|
function DraftItem({ draft, onDeleted }: { draft: Draft; onDeleted: (id: string) => void }) {
|
||||||
const [isDeletingId, setIsDeletingId] = useState("");
|
const { run, isPending } = useAction(deletePageAction, {
|
||||||
|
successMessage: "Draft deleted",
|
||||||
|
onSuccess: () => onDeleted(draft.id),
|
||||||
|
});
|
||||||
|
|
||||||
async function deletePage(id: string, type: PageType) {
|
return (
|
||||||
setIsDeletingId(id);
|
<div className="w-full flex flex-row items-center justify-between">
|
||||||
try {
|
<h3 className="w-64 truncate">
|
||||||
await deletePageAction(id, type);
|
{draft.title}
|
||||||
} finally {
|
</h3>
|
||||||
setIsDeletingId("");
|
<div className="flex flex-row items-center gap-2">
|
||||||
}
|
<Link href={`/news/${draft.slug}/edit`}>
|
||||||
|
<Button variant="secondary" size="icon-sm"><PencilIcon /></Button>
|
||||||
|
</Link>
|
||||||
|
<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 (
|
return (
|
||||||
<Dialog>
|
<Dialog>
|
||||||
<DialogTrigger asChild>
|
<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>
|
<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>
|
</DialogTrigger>
|
||||||
<DialogContent className="sm:max-w-md">
|
<DialogContent className="sm:max-w-md">
|
||||||
<DialogHeader>
|
<DialogHeader>
|
||||||
@@ -41,22 +60,10 @@ export default function DraftsDialog({ drafts }: { drafts: Draft[]}) {
|
|||||||
<DialogDescription>Here are drafts of your pages</DialogDescription>
|
<DialogDescription>Here are drafts of your pages</DialogDescription>
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
|
|
||||||
{drafts.length > 0 ? (
|
{items.length > 0 ? (
|
||||||
<div className="flex flex-col items-center gap-2">
|
<div className="flex flex-col items-center gap-2">
|
||||||
{drafts.map((draft) => (
|
{items.map((draft) => (
|
||||||
<div className="w-full flex flex-row items-center justify-between" key={draft.id}>
|
<DraftItem key={draft.id} draft={draft} onDeleted={handleDeleted} />
|
||||||
<h3 className="w-64 truncate">
|
|
||||||
{draft.title}
|
|
||||||
</h3>
|
|
||||||
<div className="flex flex-row items-center gap-2">
|
|
||||||
<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>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
+17
-8
@@ -139,7 +139,7 @@ export default function Editor({ page, initialBlocks = [], onChange, errors }: E
|
|||||||
return (
|
return (
|
||||||
<div className="flex flex-col gap-10">
|
<div className="flex flex-col gap-10">
|
||||||
<FieldSet>
|
<FieldSet>
|
||||||
<h2 className=" mb-6">Meta</h2>
|
<h2 className="md:mb-4">Meta</h2>
|
||||||
<FieldGroup>
|
<FieldGroup>
|
||||||
<Field data-invalid={!!errors?.title?.length}>
|
<Field data-invalid={!!errors?.title?.length}>
|
||||||
<FieldLabel htmlFor="title">Title</FieldLabel>
|
<FieldLabel htmlFor="title">Title</FieldLabel>
|
||||||
@@ -219,12 +219,12 @@ export default function Editor({ page, initialBlocks = [], onChange, errors }: E
|
|||||||
</FieldGroup>
|
</FieldGroup>
|
||||||
</FieldSet>
|
</FieldSet>
|
||||||
|
|
||||||
<div className="flex flex-col gap-1">
|
<div className="flex flex-col gap-4">
|
||||||
<h2 className=" mb-6">Content</h2>
|
<h2 className="md:mb-4">Content</h2>
|
||||||
{blocks.length === 0 && (
|
{blocks.length === 0 && (
|
||||||
<p className="text-sm text-muted-foreground">No blocks yet. Add one below.</p>
|
<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) => (
|
{blocks.map((block, index) => (
|
||||||
<div
|
<div
|
||||||
key={block.id}
|
key={block.id}
|
||||||
@@ -234,7 +234,7 @@ export default function Editor({ page, initialBlocks = [], onChange, errors }: E
|
|||||||
onDrop={() => handleDrop(index)}
|
onDrop={() => handleDrop(index)}
|
||||||
onDragEnd={() => { setDragIndex(null); setDropIndex(null); }}
|
onDragEnd={() => { setDragIndex(null); setDropIndex(null); }}
|
||||||
className={cn(
|
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",
|
dragIndex === index && "opacity-30",
|
||||||
dropIndex === index && dragIndex !== index && "border-t-2 border-primary"
|
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":
|
case "HEADING":
|
||||||
|
const level = (block.content as any).level;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<input
|
<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"
|
placeholder="Heading"
|
||||||
value={(block.content as any).text ?? ""}
|
value={(block.content as any).text ?? ""}
|
||||||
onChange={(e) => onChange({ type: "HEADING", text: e.target.value, level: (block.content as any).level ?? 2 })}
|
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 })}
|
onChange={(e) => onChange({ type: "IMAGE", url: e.target.value })}
|
||||||
/>
|
/>
|
||||||
{(block.content as any).url && (
|
{(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 */}
|
{/* eslint-disable-next-line @next/next/no-img-element */}
|
||||||
<img
|
<img
|
||||||
src={(block.content as any).url}
|
src={(block.content as any).url}
|
||||||
alt="preview"
|
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"; }}
|
onError={(e) => { (e.target as HTMLImageElement).style.display = "none"; }}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import Link from "next/link";
|
|||||||
|
|
||||||
export default function Footer() {
|
export default function Footer() {
|
||||||
return (
|
return (
|
||||||
<footer className="flex flex-col w-full px-16 py-8 gap-8 bg-muted">
|
<footer className="flex flex-col w-full px-4 lg:px-16 py-8 gap-8 bg-muted">
|
||||||
<div className="flex items-center gap-4">
|
<div className="flex flex-col lg:flex-row lg:items-center gap-4">
|
||||||
<Image
|
<Image
|
||||||
src="/emblem.png"
|
src="/emblem.png"
|
||||||
width={28}
|
width={28}
|
||||||
@@ -14,7 +14,7 @@ export default function Footer() {
|
|||||||
/>
|
/>
|
||||||
<h3>This is an official site of the European Federation</h3>
|
<h3>This is an official site of the European Federation</h3>
|
||||||
</div>
|
</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">
|
<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="/" 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>
|
<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/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>
|
<Link href="/page/government" className="text-black/60 cursor-pointer hover:underline underline-offset-8 decoration-2">Federal Government</Link>
|
||||||
</div>
|
</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>
|
</div>
|
||||||
<p>© 2026 European Federation. All rights reserved.</p>
|
<p>© {new Date().getFullYear()} European Federation. All rights reserved.</p>
|
||||||
</footer>
|
</footer>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
+25
-20
@@ -4,38 +4,43 @@ import { login } from "@/lib/user/actions";
|
|||||||
import { getCurrentUser } from "@/lib/user";
|
import { getCurrentUser } from "@/lib/user";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { getNavLinks } from "@/lib/navlinks/repository";
|
import { getNavLinks } from "@/lib/navlinks/repository";
|
||||||
|
import { MobileNav } from "./mobile-nav";
|
||||||
|
|
||||||
export default async function Header() {
|
export default async function Header() {
|
||||||
const user = await getCurrentUser();
|
const user = await getCurrentUser();
|
||||||
const links = await getNavLinks();
|
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 (
|
return (
|
||||||
<header className="relative flex items-center justify-between w-full h-16 px-8 bg-gray-100">
|
<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">
|
<Link href="/" className="flex items-center gap-4 shrink-0">
|
||||||
<Image
|
<Image src="/emblem.png" width={28} height={28} alt="Emblem of the European Federation" />
|
||||||
src="/emblem.png"
|
<h3 className="hidden sm:block">European Federation</h3>
|
||||||
width={28}
|
|
||||||
height={28}
|
|
||||||
alt="Emblem of the European Federation"
|
|
||||||
/>
|
|
||||||
<h3>European Federation</h3>
|
|
||||||
</Link>
|
</Link>
|
||||||
<div className="absolute left-1/2 -translate-x-1/2 flex items-center gap-6">
|
<div className="hidden md:flex absolute left-1/2 -translate-x-1/2 items-center gap-6">
|
||||||
{
|
{navLinks.map((link) => (
|
||||||
links.map((link) => (
|
<Link className="hover:underline underline-offset-8 decoration-2 duration-200" key={link.id} href={link.href}>
|
||||||
<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>
|
<h3>{link.label}</h3>
|
||||||
))
|
</Link>
|
||||||
}
|
))}
|
||||||
</div>
|
</div>
|
||||||
{
|
|
||||||
user ? (
|
<div className="hidden md:block">
|
||||||
|
{user ? (
|
||||||
<Link href="/account"><Button>Account</Button></Link>
|
<Link href="/account"><Button>Account</Button></Link>
|
||||||
) : (
|
) : (
|
||||||
<form action={login}>
|
<form action={login}>
|
||||||
<Button size="lg" type="submit">Sign in with Kotosoft ID</Button>
|
<Button size="lg" type="submit">Sign in with Kotosoft ID</Button>
|
||||||
</form>
|
</form>
|
||||||
)
|
)}
|
||||||
}
|
</div>
|
||||||
|
|
||||||
|
<MobileNav links={navLinks} isAuthenticated={!!user} />
|
||||||
</header>
|
</header>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
@@ -70,7 +70,7 @@ export default function IdentityCard({ data }: { data: IdentityCardData }) {
|
|||||||
const expiryClass = expiryDateClass(data.expiryDate);
|
const expiryClass = expiryDateClass(data.expiryDate);
|
||||||
|
|
||||||
return (
|
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 />
|
<CardPattern />
|
||||||
<div className="relative z-10">
|
<div className="relative z-10">
|
||||||
<div className="flex flex-row items-center justify-between">
|
<div className="flex flex-row items-center justify-between">
|
||||||
@@ -88,12 +88,12 @@ export default function IdentityCard({ data }: { data: IdentityCardData }) {
|
|||||||
<DialogContent>
|
<DialogContent>
|
||||||
<DialogHeader>
|
<DialogHeader>
|
||||||
<div className="flex flex-row gap-3">
|
<div className="flex flex-row gap-3">
|
||||||
<div className="relative w-12 h-14 shrink-0 rounded overflow-hidden">
|
<div className="relative w-12 aspect-4/5 shrink-0 rounded overflow-hidden">
|
||||||
<img src={data.profileUrl} alt="Profile" className="object-cover" />
|
<img src={data.profileUrl} alt="Profile" className="w-full h-full object-cover" />
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-col gap-0 justify-center">
|
<div className="flex flex-col justify-center">
|
||||||
<DialogTitle asChild>
|
<DialogTitle asChild>
|
||||||
<h4 className="uppercase">{data.surname} {data.givenNames}</h4>
|
<h4 className="uppercase">{data.givenNames} {data.surname}</h4>
|
||||||
</DialogTitle>
|
</DialogTitle>
|
||||||
<h4 className="text-muted-foreground">{data.documentNumber}</h4>
|
<h4 className="text-muted-foreground">{data.documentNumber}</h4>
|
||||||
</div>
|
</div>
|
||||||
@@ -103,19 +103,14 @@ export default function IdentityCard({ data }: { data: IdentityCardData }) {
|
|||||||
{DIALOG_FIELDS.map(({ key, label }) => (
|
{DIALOG_FIELDS.map(({ key, label }) => (
|
||||||
<div className="flex flex-col" key={key}>
|
<div className="flex flex-col" key={key}>
|
||||||
<h5 className="text-blue-500">{label}</h5>
|
<h5 className="text-blue-500">{label}</h5>
|
||||||
<h4
|
<h4 className={cn(key === "expiryDate" && expiryClass)}>
|
||||||
className={cn(
|
|
||||||
"leading-6",
|
|
||||||
key === "expiryDate" && expiryClass
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
{formatFieldValue(key, data[key])}
|
{formatFieldValue(key, data[key])}
|
||||||
</h4>
|
</h4>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
<div className="flex flex-col col-span-2">
|
<div className="flex flex-col col-span-2">
|
||||||
<h5 className="text-blue-500">{ADDRESS_FIELD.label}</h5>
|
<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>
|
||||||
</div>
|
</div>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
@@ -123,12 +118,12 @@ export default function IdentityCard({ data }: { data: IdentityCardData }) {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex flex-row gap-8 mt-4">
|
<div className="flex flex-row gap-8 mt-4">
|
||||||
<div className="flex flex-col gap-8 w-24 shrink-0">
|
<div className="flex flex-col gap-4 w-24 shrink-0">
|
||||||
<div className="relative w-24 h-28 shrink-0">
|
<div className="w-24 aspect-4/5 rounded overflow-hidden">
|
||||||
<img src={data.profileUrl} alt="Profile" className="object-cover" />
|
<img src={data.profileUrl} alt="Profile" className="w-full h-full object-cover" />
|
||||||
</div>
|
</div>
|
||||||
<div className="relative w-24 h-12 shrink-0">
|
<div className="w-24 aspect-5/2 rounded overflow-hidden">
|
||||||
<img src={data.signatureUrl} alt="Signature" className="object-contain" />
|
<img src={data.signatureUrl} alt="Signature" className="w-full h-full object-contain" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-col gap-2">
|
<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-wrap gap-x-6 gap-y-2">
|
||||||
<div className="flex flex-col min-w-fit">
|
<div className="flex flex-col min-w-fit">
|
||||||
<h5 className="text-blue-500">Authority</h5>
|
<h5 className="text-blue-500">Authority</h5>
|
||||||
<h4 className="leading-6">{data.authority}</h4>
|
<h4>{data.authority}</h4>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-col min-w-fit">
|
<div className="flex flex-col min-w-fit">
|
||||||
<h5 className="text-blue-500">Nationality</h5>
|
<h5 className="text-blue-500">Nationality</h5>
|
||||||
|
|||||||
@@ -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>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -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>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -10,10 +10,12 @@ export function NewsCard({ news }: { news: PagePublic }) {
|
|||||||
<Link href={`/news/${news.slug}`} className="w-max">
|
<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>
|
<h2 className="hover:underline underline-offset-8 decoration-2 hover:duration-200 cursor-pointer">{news.title}</h2>
|
||||||
</Link>
|
</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">
|
||||||
<p className="flex gap-2 items-center"><CalendarIcon size={16} />{formatDate(news.publishedAt)}</p>
|
<div className="flex flex-row gap-4 md:gap-8">
|
||||||
{(news?.meta as PageMeta)?.location && <p className="flex gap-2 items-center"><Globe2Icon size={16} />{(news.meta as PageMeta)?.location}</p>}
|
<p className="flex gap-2 items-center"><CalendarIcon size={16} />{formatDate(news.publishedAt)}</p>
|
||||||
<div className="flex flex-row gap-4">
|
{(news?.meta as PageMeta)?.location && <p className="flex gap-2 items-center"><Globe2Icon size={16} />{(news.meta as PageMeta)?.location}</p>}
|
||||||
|
</div>
|
||||||
|
<div className="hidden md:flex flex-row gap-4">
|
||||||
{((news.meta as PageMeta)?.tags)?.map((tag) => (
|
{((news.meta as PageMeta)?.tags)?.map((tag) => (
|
||||||
<Badge key={tag}>{tag}</Badge>
|
<Badge key={tag}>{tag}</Badge>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ const buttonVariants = cva(
|
|||||||
size: {
|
size: {
|
||||||
default:
|
default:
|
||||||
"h-8 gap-1.5 px-3 has-data-[icon=inline-end]:pr-2.5 has-data-[icon=inline-start]:pl-2.5",
|
"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",
|
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",
|
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",
|
icon: "size-8",
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ function FieldLegend({
|
|||||||
data-slot="field-legend"
|
data-slot="field-legend"
|
||||||
data-variant={variant}
|
data-variant={variant}
|
||||||
className={cn(
|
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
|
className
|
||||||
)}
|
)}
|
||||||
{...props}
|
{...props}
|
||||||
@@ -43,7 +43,7 @@ function FieldGroup({ className, ...props }: React.ComponentProps<"div">) {
|
|||||||
<div
|
<div
|
||||||
data-slot="field-group"
|
data-slot="field-group"
|
||||||
className={cn(
|
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
|
className
|
||||||
)}
|
)}
|
||||||
{...props}
|
{...props}
|
||||||
@@ -130,11 +130,11 @@ function FieldTitle({ className, ...props }: React.ComponentProps<"div">) {
|
|||||||
|
|
||||||
function FieldDescription({ className, ...props }: React.ComponentProps<"p">) {
|
function FieldDescription({ className, ...props }: React.ComponentProps<"p">) {
|
||||||
return (
|
return (
|
||||||
<p
|
<h5
|
||||||
data-slot="field-description"
|
data-slot="field-description"
|
||||||
className={cn(
|
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",
|
"text-left font-normal text-muted-foreground group-has-data-horizontal/field:text-balance [[data-variant=legend]+&]:-mt-2",
|
||||||
"last:mt-0 nth-last-2:-mt-1",
|
"nth-last-2:-mt-0.5",
|
||||||
"[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",
|
"[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",
|
||||||
className
|
className
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ function Input({ className, type, ...props }: React.ComponentProps<"input">) {
|
|||||||
type={type}
|
type={type}
|
||||||
data-slot="input"
|
data-slot="input"
|
||||||
className={cn(
|
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
|
className
|
||||||
)}
|
)}
|
||||||
{...props}
|
{...props}
|
||||||
|
|||||||
@@ -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 }
|
||||||
@@ -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
|
||||||
+40
-19
@@ -11,7 +11,7 @@ import { createApplication, getActiveCitizenship, getApplicationEligibility } fr
|
|||||||
import { prisma } from "../prisma";
|
import { prisma } from "../prisma";
|
||||||
import { formatAddress } from "@/lib/address";
|
import { formatAddress } from "@/lib/address";
|
||||||
import { Prisma } from "@/lib/generated/prisma/client";
|
import { Prisma } from "@/lib/generated/prisma/client";
|
||||||
import { uploadImage } from "../image";
|
import { removeImage, uploadImage } from "../image";
|
||||||
|
|
||||||
function generateDocumentNumber(): string {
|
function generateDocumentNumber(): string {
|
||||||
const letter = () => String.fromCharCode(65 + Math.floor(Math.random() * 26));
|
const letter = () => String.fromCharCode(65 + Math.floor(Math.random() * 26));
|
||||||
@@ -70,23 +70,37 @@ export const submitCitizenshipApplication = formAction(citizenshipApplicationSch
|
|||||||
customAddress: data.customAddress,
|
customAddress: data.customAddress,
|
||||||
});
|
});
|
||||||
|
|
||||||
const profileKey = await uploadImage(profile, "citizenship/profiles");
|
let profileKey: string | undefined;
|
||||||
const signatureKey = await uploadImage(signature, "citizenship/signatures");
|
let signatureKey: string | undefined;
|
||||||
|
|
||||||
await createApplication(user.id, {
|
try {
|
||||||
surname: user.secondName,
|
const profileKey = await uploadImage(profile, "citizenship/profiles", {
|
||||||
givenNames: user.firstName,
|
maxWidth: 800, maxHeight: 1000, fit: "cover",
|
||||||
sex: user.sex,
|
});
|
||||||
birthDate: user.birthDate!,
|
|
||||||
...applicationData,
|
const signatureKey = await uploadImage(signature, "citizenship/signatures", {
|
||||||
address,
|
maxWidth: 1000, maxHeight: 400, fit: "inside",
|
||||||
regionId: isEuResidentYes ? data.regionId! : null,
|
});
|
||||||
city: isEuResidentYes ? data.city! : null,
|
|
||||||
street: isEuResidentYes ? data.street! : null,
|
await createApplication(user.id, {
|
||||||
customAddress: isEuResidentYes ? null : data.customAddress!,
|
surname: user.secondName,
|
||||||
profileKey,
|
givenNames: user.firstName,
|
||||||
signatureKey
|
sex: user.sex,
|
||||||
});
|
birthDate: user.birthDate!,
|
||||||
|
...applicationData,
|
||||||
|
address,
|
||||||
|
regionId: isEuResidentYes ? data.regionId! : null,
|
||||||
|
city: isEuResidentYes ? data.city! : null,
|
||||||
|
street: isEuResidentYes ? data.street! : null,
|
||||||
|
customAddress: isEuResidentYes ? null : data.customAddress!,
|
||||||
|
profileKey,
|
||||||
|
signatureKey
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
if (profileKey) await removeImage(profileKey);
|
||||||
|
if (signatureKey) await removeImage(signatureKey);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
revalidatePath("/account/citizenship");
|
revalidatePath("/account/citizenship");
|
||||||
redirect("/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.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.");
|
if (application.userId === user.id) throw new AppError("You cannot approve your own application.");
|
||||||
|
|
||||||
const existingCitizenship = await prisma.citizenship.findUnique({ where: { userId: application.userId } });
|
const existingCitizenship = await prisma.citizenship.findFirst({
|
||||||
if (existingCitizenship && !existingCitizenship.revokedAt) {
|
where: { userId: application.userId, revokedAt: null },
|
||||||
|
});
|
||||||
|
if (existingCitizenship) {
|
||||||
throw new AppError("This applicant is already a citizen.");
|
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 },
|
data: { status: "REJECTED", rejectionReason: trimmedReason, reviewedAt: new Date(), reviewedBy: user.id },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await Promise.allSettled([
|
||||||
|
removeImage(application.profileKey),
|
||||||
|
removeImage(application.signatureKey),
|
||||||
|
]);
|
||||||
|
|
||||||
revalidatePath("/account/citizenship/review");
|
revalidatePath("/account/citizenship/review");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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) {
|
if (citizenship && !citizenship.revokedAt) {
|
||||||
return {
|
return {
|
||||||
eligible: false,
|
eligible: false,
|
||||||
@@ -100,7 +100,7 @@ export async function getPendingApplicationsCount(): Promise<number> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function getActiveCitizenship(userId: string) {
|
export async function getActiveCitizenship(userId: string) {
|
||||||
const citizenship = await prisma.citizenship.findUnique({ where: { userId } });
|
return prisma.citizenship.findFirst({
|
||||||
if (!citizenship || citizenship.revokedAt) return null;
|
where: { userId, revokedAt: null },
|
||||||
return citizenship;
|
});
|
||||||
}
|
}
|
||||||
@@ -36,8 +36,6 @@ export type CitizenshipApplication = {
|
|||||||
updatedAt: Date;
|
updatedAt: Date;
|
||||||
profileKey: string;
|
profileKey: string;
|
||||||
signatureKey: string;
|
signatureKey: string;
|
||||||
profile: File;
|
|
||||||
signature: File;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export type CitizenshipApplicationWithWarning = CitizenshipApplication & {
|
export type CitizenshipApplicationWithWarning = CitizenshipApplication & {
|
||||||
|
|||||||
+21
-25
@@ -5,53 +5,49 @@ import { AppError } from "@/lib/action-result";
|
|||||||
import { minioClient } from "@/lib/minio";
|
import { minioClient } from "@/lib/minio";
|
||||||
|
|
||||||
const BUCKET = "uploads";
|
const BUCKET = "uploads";
|
||||||
|
|
||||||
const MAX_FILE_SIZE = 5 * 1024 * 1024;
|
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> {
|
export async function uploadImage(file: File, directory: string, options: { maxWidth: number; maxHeight: number; fit?: "inside" | "cover"; removeBg?: boolean }): Promise<string> {
|
||||||
if (file.size === 0) {
|
if (file.size === 0) throw new AppError("A file is required");
|
||||||
throw new AppError("A file is required");
|
if (file.size > MAX_FILE_SIZE) throw new AppError("Image must be smaller than 5MB");
|
||||||
}
|
|
||||||
|
|
||||||
if (file.size > MAX_FILE_SIZE) {
|
|
||||||
throw new AppError("Image must be smaller than 5MB");
|
|
||||||
}
|
|
||||||
|
|
||||||
const input = Buffer.from(await file.arrayBuffer());
|
const input = Buffer.from(await file.arrayBuffer());
|
||||||
|
|
||||||
let image = sharp(input, {
|
let image = sharp(input, {
|
||||||
failOn: "error",
|
failOn: "error",
|
||||||
|
limitInputPixels: 30_000_000,
|
||||||
});
|
});
|
||||||
|
|
||||||
const metadata = await image.metadata();
|
const metadata = await image.metadata();
|
||||||
|
if (!metadata.format || !ALLOWED_INPUT_FORMATS.has(metadata.format)) {
|
||||||
if (!metadata.format) {
|
|
||||||
throw new AppError("Only JPEG, PNG, or WEBP images are allowed");
|
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
|
const output = await image
|
||||||
.rotate()
|
.rotate()
|
||||||
.webp({
|
.resize({
|
||||||
quality: 80,
|
width: options.maxWidth,
|
||||||
effort: 4,
|
height: options.maxHeight,
|
||||||
|
fit: options.fit ?? "inside",
|
||||||
|
withoutEnlargement: true,
|
||||||
})
|
})
|
||||||
|
.webp({ quality: 80, effort: 4 })
|
||||||
.toBuffer();
|
.toBuffer();
|
||||||
|
|
||||||
const key = `${directory}/${crypto.randomUUID()}.webp`;
|
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;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function removeImage(key: string) {
|
||||||
|
await minioClient.removeObject(BUCKET, key)
|
||||||
|
}
|
||||||
|
|
||||||
export async function getImageUrl(key: string): Promise<string> {
|
export async function getImageUrl(key: string): Promise<string> {
|
||||||
return minioClient.presignedGetObject(
|
return minioClient.presignedGetObject(
|
||||||
BUCKET,
|
BUCKET,
|
||||||
|
|||||||
+15
-9
@@ -3,16 +3,22 @@
|
|||||||
import { revalidatePath } from "next/cache";
|
import { revalidatePath } from "next/cache";
|
||||||
import { addNavLink, deleteNavLinkByPageId } from "./repository";
|
import { addNavLink, deleteNavLinkByPageId } from "./repository";
|
||||||
import { prisma } from "../prisma";
|
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> {
|
||||||
const page = await prisma.page.findUnique({ where: { id: pageId } });
|
return runAction(async () => {
|
||||||
if (!page) throw new Error(`Page not found: ${pageId}`);
|
await requireAdmin();
|
||||||
|
|
||||||
await addNavLink({ pageId });
|
if (isPinned) {
|
||||||
revalidatePath("/", "layout");
|
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 });
|
||||||
|
}
|
||||||
|
|
||||||
export async function unpinPageAction(pageId: string) {
|
revalidatePath("/", "layout");
|
||||||
await deleteNavLinkByPageId(pageId);
|
});
|
||||||
revalidatePath("/", "layout");
|
|
||||||
}
|
}
|
||||||
+35
-22
@@ -6,6 +6,9 @@ import { archivePage, createPage, deletePage, updatePage } from "./repository";
|
|||||||
import { revalidatePath } from "next/cache";
|
import { revalidatePath } from "next/cache";
|
||||||
import { deleteNavLinkByPageId } from "../navlinks/repository";
|
import { deleteNavLinkByPageId } from "../navlinks/repository";
|
||||||
import { validatePage } from "./validation";
|
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: {
|
export async function savePageAction(params: {
|
||||||
id: string | null,
|
id: string | null,
|
||||||
@@ -15,31 +18,41 @@ export async function savePageAction(params: {
|
|||||||
status: PageStatus,
|
status: PageStatus,
|
||||||
blocks: Block[],
|
blocks: Block[],
|
||||||
meta?: PageMeta
|
meta?: PageMeta
|
||||||
}) {
|
}): Promise<ActionResult> {
|
||||||
const parsed = validatePage(params);
|
return runAction(async () => {
|
||||||
if (!parsed.success) {
|
await requireAdmin();
|
||||||
throw new Error(parsed.errors.join("; "));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (params.id) {
|
const parsed = validatePage(params);
|
||||||
await updatePage(params.id, params.title, params.type, params.status, params.blocks, params.meta);
|
if (!parsed.success) {
|
||||||
revalidatePath(`/${params.type.toLowerCase()}/${params.slug}`);
|
throw new Error(parsed.errors.join("; "));
|
||||||
revalidatePath(`/${params.type.toLowerCase()}`);
|
}
|
||||||
} else {
|
|
||||||
const page = await createPage(params.slug, params.title, params.type, params.status, params.blocks, params.meta);
|
if (params.id) {
|
||||||
revalidatePath(`/${params.type.toLowerCase()}`);
|
await updatePage(params.id, params.title, params.type, params.status, params.blocks, params.meta);
|
||||||
redirect(`/${params.type.toLowerCase()}/${page.slug}`);
|
revalidatePath(`/${params.type.toLowerCase()}/${params.slug}`);
|
||||||
}
|
revalidatePath(`/${params.type.toLowerCase()}`);
|
||||||
|
} else {
|
||||||
|
const page = await createPage(params.slug, params.title, params.type, params.status, params.blocks, params.meta);
|
||||||
|
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> {
|
||||||
await archivePage(id);
|
return runAction(async () => {
|
||||||
await deleteNavLinkByPageId(id);
|
await requireAdmin();
|
||||||
revalidatePath(`/${type.toLowerCase()}/${slug}`);
|
await archivePage(id);
|
||||||
revalidatePath(`/${type.toLowerCase()}`);
|
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> {
|
||||||
await deletePage(id);
|
return runAction(async () => {
|
||||||
revalidatePath(`/${type.toLowerCase()}`);
|
await requireAdmin();
|
||||||
|
await deletePage(id);
|
||||||
|
revalidatePath(`/${type.toLowerCase()}`);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
+3
-11
@@ -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) {
|
export async function createPage(slug: string, title: string, type: PageType, status: PageStatus, blocks: Block[], meta?: PageMeta) {
|
||||||
const user = await getCurrentUser();
|
const user = await getCurrentUser();
|
||||||
if (!user) {
|
if (!user) throw new Error("Failed to fetch user");
|
||||||
throw new Error("Failed to fetch user");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!user.isAdmin) {
|
|
||||||
throw new Error("Access denied");
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const page = await prisma.page.create({
|
const page = await prisma.page.create({
|
||||||
@@ -87,7 +81,7 @@ export async function updatePage(
|
|||||||
meta?: PageMeta
|
meta?: PageMeta
|
||||||
) {
|
) {
|
||||||
const user = await getCurrentUser();
|
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 currentPage = await prisma.page.findUnique({ where: { id }, select: { status: true } });
|
||||||
const isNewlyPublished = status === "PUBLISHED" && currentPage?.status !== "PUBLISHED";
|
const isNewlyPublished = status === "PUBLISHED" && currentPage?.status !== "PUBLISHED";
|
||||||
@@ -125,13 +119,11 @@ export async function updatePage(
|
|||||||
|
|
||||||
export async function archivePage(id: string) {
|
export async function archivePage(id: string) {
|
||||||
const user = await getCurrentUser();
|
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 } });
|
await prisma.page.update({ where: { id }, data: { status: "ARCHIVED", updatedBy: user.id } });
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function deletePage(id: string) {
|
export async function deletePage(id: string) {
|
||||||
const user = await getCurrentUser();
|
|
||||||
if (!user?.isAdmin) throw new Error("Access denied");
|
|
||||||
await prisma.page.delete({ where: { id } });
|
await prisma.page.delete({ where: { id } });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-1
@@ -9,7 +9,7 @@ import { deleteUser, updateUser } from "./repository";
|
|||||||
import { getAccessToken } from "@/lib/auth/tokens";
|
import { getAccessToken } from "@/lib/auth/tokens";
|
||||||
import { fetchKotosoftUser } from "@/lib/kotosoft/client";
|
import { fetchKotosoftUser } from "@/lib/kotosoft/client";
|
||||||
import { revalidatePath } from "next/cache";
|
import { revalidatePath } from "next/cache";
|
||||||
import { getCurrentUser } from "../user";
|
import { getCurrentUser, getUser } from "../user";
|
||||||
import { runAction } from "@/lib/run-action";
|
import { runAction } from "@/lib/run-action";
|
||||||
import { AppError, type ActionResult } from "@/lib/action-result";
|
import { AppError, type ActionResult } from "@/lib/action-result";
|
||||||
|
|
||||||
@@ -61,6 +61,10 @@ export async function updateUserAction(): Promise<ActionResult> {
|
|||||||
const userId = await getSessionUserId();
|
const userId = await getSessionUserId();
|
||||||
if (!userId) throw new AppError("Not authenticated");
|
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, {
|
await updateUser(userId, {
|
||||||
email: kotosoftUser.email,
|
email: kotosoftUser.email,
|
||||||
firstName: kotosoftUser.first_name,
|
firstName: kotosoftUser.first_name,
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@ const nextConfig: NextConfig = {
|
|||||||
images: {
|
images: {
|
||||||
remotePatterns: [
|
remotePatterns: [
|
||||||
{
|
{
|
||||||
hostname: process.env.MINIO_URL!,
|
hostname: "**",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
"lint": "eslint"
|
"lint": "eslint"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@imgly/background-removal": "^1.7.0",
|
||||||
"@prisma/adapter-pg": "^7.8.0",
|
"@prisma/adapter-pg": "^7.8.0",
|
||||||
"@prisma/client": "^7.8.0",
|
"@prisma/client": "^7.8.0",
|
||||||
"@tanstack/react-table": "^8.21.3",
|
"@tanstack/react-table": "^8.21.3",
|
||||||
@@ -47,6 +48,10 @@
|
|||||||
"unrs-resolver"
|
"unrs-resolver"
|
||||||
],
|
],
|
||||||
"trustedDependencies": [
|
"trustedDependencies": [
|
||||||
|
"@prisma/engines",
|
||||||
|
"onnxruntime-node",
|
||||||
|
"prisma",
|
||||||
|
"protobufjs",
|
||||||
"sharp",
|
"sharp",
|
||||||
"unrs-resolver"
|
"unrs-resolver"
|
||||||
]
|
]
|
||||||
|
|||||||
+10
-7
@@ -148,14 +148,17 @@ model CitizenshipApplication {
|
|||||||
}
|
}
|
||||||
|
|
||||||
model Citizenship {
|
model Citizenship {
|
||||||
id String @id @default(uuid())
|
id String @id @default(uuid())
|
||||||
userId String @unique
|
userId String
|
||||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
applicationId String @unique
|
||||||
applicationId String @unique
|
issuedAt DateTime @default(now())
|
||||||
application CitizenshipApplication @relation(fields: [applicationId], references: [id])
|
|
||||||
issuedAt DateTime @default(now())
|
|
||||||
revokedAt DateTime?
|
revokedAt DateTime?
|
||||||
documents IdentityDocument[]
|
|
||||||
|
user User @relation(fields: [userId], references: [id])
|
||||||
|
application CitizenshipApplication @relation(fields: [applicationId], references: [id])
|
||||||
|
identityDocuments IdentityDocument[]
|
||||||
|
|
||||||
|
@@index([userId])
|
||||||
}
|
}
|
||||||
|
|
||||||
model IdentityDocument {
|
model IdentityDocument {
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 184 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 23 KiB |
Reference in New Issue
Block a user