prod
This commit is contained in:
@@ -1,23 +1,25 @@
|
||||
"use client";
|
||||
|
||||
import { useTransition } from "react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { ArchiveIcon } from "lucide-react";
|
||||
import { Spinner } from "@/components/ui/spinner";
|
||||
import { archivePageAction } from "@/lib/pages/actions";
|
||||
import { PageType } from "@/lib/pages/types";
|
||||
import { useAction } from "@/hooks/useAction";
|
||||
|
||||
export function ArchiveButton({ pageId, slug, type }: { pageId: string, slug: string, type: PageType }) {
|
||||
const [isPending, startTransition] = useTransition();
|
||||
const { run, isPending } = useAction(archivePageAction, {
|
||||
successMessage: "Page archived",
|
||||
});
|
||||
|
||||
return (
|
||||
<Button
|
||||
variant="secondary"
|
||||
size="icon-sm"
|
||||
disabled={isPending}
|
||||
onClick={() => startTransition(() => archivePageAction(pageId, slug, type))}
|
||||
onClick={() => run(pageId, slug, type)}
|
||||
>
|
||||
{isPending ? <Spinner /> : <ArchiveIcon />}
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
"use client";
|
||||
|
||||
import { useRef, useState, useTransition } from "react";
|
||||
import { useRef } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import Editor, { EditorData } from "@/components/editor";
|
||||
import { savePageAction } from "@/lib/pages/actions";
|
||||
import { validatePage } from "@/lib/pages/validation";
|
||||
import { Block, Page, PageMeta, PageType } from "@/lib/pages/types";
|
||||
import { Loader2 } from "lucide-react";
|
||||
import { toast } from "sonner";
|
||||
import { Spinner } from "@/components/ui/spinner";
|
||||
import { useAction } from "@/hooks/useAction";
|
||||
|
||||
type Props = {
|
||||
page: Page | null;
|
||||
@@ -18,8 +17,10 @@ type Props = {
|
||||
|
||||
export default function EditPageClient({ page, pageType, initialBlocks = [] }: Props) {
|
||||
const router = useRouter();
|
||||
const [isPending, startTransition] = useTransition();
|
||||
const [fieldErrors, setFieldErrors] = useState<{ title?: string[]; slug?: string[] }>({});
|
||||
const { run, isPending } = useAction(savePageAction, {
|
||||
successMessage: "Page saved",
|
||||
onSuccess: () => router.push(`/${pageType.toLowerCase()}/${dataRef.current.slug}`),
|
||||
});
|
||||
|
||||
const dataRef = useRef<EditorData>({
|
||||
title: page?.title ?? "",
|
||||
@@ -31,47 +32,20 @@ export default function EditPageClient({ page, pageType, initialBlocks = [] }: P
|
||||
});
|
||||
|
||||
function handleSave(status: "DRAFT" | "PUBLISHED") {
|
||||
startTransition(async () => {
|
||||
const data = dataRef.current;
|
||||
const payload = {
|
||||
id: page?.id ?? null,
|
||||
slug: data.slug || data.title.toLowerCase().replace(/\s+/g, "-"),
|
||||
title: data.title,
|
||||
type: pageType,
|
||||
status,
|
||||
blocks: data.blocks,
|
||||
meta: { location: data.location, tags: data.tags },
|
||||
};
|
||||
|
||||
const parsed = validatePage(payload);
|
||||
if (!parsed.success) {
|
||||
const errors: { title?: string[]; slug?: string[] } = {};
|
||||
for (const msg of parsed.errors) {
|
||||
if (msg.toLowerCase().includes("title")) {
|
||||
(errors.title ??= []).push(msg);
|
||||
} else if (msg.toLowerCase().includes("slug")) {
|
||||
(errors.slug ??= []).push(msg);
|
||||
}
|
||||
}
|
||||
setFieldErrors(errors);
|
||||
toast.error(parsed.errors.join(", "));
|
||||
return;
|
||||
}
|
||||
|
||||
setFieldErrors({});
|
||||
|
||||
try {
|
||||
await savePageAction(payload);
|
||||
toast.success("Page saved");
|
||||
router.push(`/${pageType.toLowerCase()}/${data.slug}`);
|
||||
} catch (e) {
|
||||
toast.error(e instanceof Error ? e.message : "Failed to save page");
|
||||
}
|
||||
const data = dataRef.current;
|
||||
run({
|
||||
id: page?.id ?? null,
|
||||
slug: data.slug || data.title.toLowerCase().replace(/\s+/g, "-"),
|
||||
title: data.title,
|
||||
type: pageType,
|
||||
status,
|
||||
blocks: data.blocks,
|
||||
meta: { location: data.location, tags: data.tags },
|
||||
});
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex flex-col p-16 gap-12">
|
||||
<div className="flex flex-col p-4 md:p-16 gap-6 md:gap-12 mb-4 md:mb-0">
|
||||
<div className="flex flex-row items-center justify-between">
|
||||
<h1>Edit page</h1>
|
||||
<div className="flex flex-row gap-3">
|
||||
@@ -79,7 +53,7 @@ export default function EditPageClient({ page, pageType, initialBlocks = [] }: P
|
||||
disabled={isPending}
|
||||
onClick={() => handleSave("PUBLISHED")}
|
||||
>
|
||||
{isPending && <Loader2 size={14} className="animate-spin mr-1" />}
|
||||
{isPending && <Spinner />}
|
||||
Save
|
||||
</Button>
|
||||
</div>
|
||||
@@ -88,12 +62,10 @@ export default function EditPageClient({ page, pageType, initialBlocks = [] }: P
|
||||
page={page}
|
||||
type={pageType}
|
||||
initialBlocks={initialBlocks}
|
||||
errors={fieldErrors}
|
||||
onChange={(data) => {
|
||||
dataRef.current = data;
|
||||
setFieldErrors({});
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import Header from "@/components/header";
|
||||
import Footer from "@/components/footer";
|
||||
import { getPageBySlug, getBlocksByPageId } from "@/lib/pages/repository";
|
||||
import { getCurrentUser } from "@/lib/user";
|
||||
import { redirect, notFound } from "next/navigation";
|
||||
@@ -20,10 +18,6 @@ export default async function EditPage({ params }: { params: Promise<{ type: str
|
||||
const blocks = page ? await getBlocksByPageId(page.id) : [];
|
||||
|
||||
return (
|
||||
<>
|
||||
<Header />
|
||||
<EditPageClient page={page ?? null} pageType={pageType} initialBlocks={blocks} />
|
||||
<Footer />
|
||||
</>
|
||||
<EditPageClient page={page ?? null} pageType={pageType} initialBlocks={blocks} />
|
||||
);
|
||||
}
|
||||
+38
-42
@@ -53,7 +53,7 @@ function BlockRenderer({ block }: { block: Block }) {
|
||||
|
||||
case "CALLOUT":
|
||||
return (
|
||||
<Alert className="w-max">
|
||||
<Alert className="md:w-max">
|
||||
<InfoIcon />
|
||||
<AlertTitle>{b.title}</AlertTitle>
|
||||
<AlertDescription>{b.text}</AlertDescription>
|
||||
@@ -68,11 +68,11 @@ function BlockRenderer({ block }: { block: Block }) {
|
||||
alt={b.caption || "Image"}
|
||||
width={1200}
|
||||
height={800}
|
||||
className="rounded-md border max-w-200 h-auto object-contain"
|
||||
className="w-full md:w-auto md:max-w-200 h-auto rounded-md border object-contain"
|
||||
/>
|
||||
|
||||
{b.caption && (
|
||||
<figcaption className="text-sm text-muted-foreground">
|
||||
<figcaption className="text-xs md:text-sm text-muted-foreground">
|
||||
{b.caption}
|
||||
</figcaption>
|
||||
)}
|
||||
@@ -83,13 +83,13 @@ function BlockRenderer({ block }: { block: Block }) {
|
||||
return b.style === "ORDERED" ? (
|
||||
<div className="flex flex-col gap-2">
|
||||
{b.items.map((item: string, index: number) => (
|
||||
<p className="flex flex-row gap-1 items-center" key={index}><span className="text-muted-foreground">{index+1}.</span> {item}</p>
|
||||
<p className="flex flex-row gap-2 md:items-center" key={index}><span className="text-muted-foreground">{index+1}.</span> {item}</p>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex flex-col gap-2">
|
||||
{b.items.map((item: string, index: number) => (
|
||||
<p className="flex flex-row gap-1 items-center" key={index}><DotIcon className="text-muted-foreground" /> {item}</p>
|
||||
<div className="flex flex-row gap-0.5 md:gap-1 md:items-center" key={index}><div><DotIcon className="text-muted-foreground" /></div><p>{item}</p></div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
@@ -124,7 +124,7 @@ function BlockRenderer({ block }: { block: Block }) {
|
||||
|
||||
case "LINK":
|
||||
return <Link href={b.href} target="_blank">
|
||||
<Button variant="secondary" className="w-max">{b.label}</Button>
|
||||
<Button variant="secondary" className="max-w-full">{b.label}</Button>
|
||||
</Link>
|
||||
|
||||
default:
|
||||
@@ -166,44 +166,40 @@ export default async function Page({ params }: { params: Promise<{ type: string;
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Header />
|
||||
<div className="flex flex-col p-16 gap-12">
|
||||
<div className={cn("flex flex-col gap-4 justify-center", isNews && "items-center")}>
|
||||
<div className="flex flex-row items-center gap-6">
|
||||
<h1>{page?.title}</h1>
|
||||
{user?.isAdmin && (
|
||||
<div className="flex flex-row gap-2 items-center">
|
||||
<Link href={`/${page.type.toLowerCase()}/${page.slug}/edit`}>
|
||||
<Button variant="secondary" size="icon-sm"><PencilIcon /></Button>
|
||||
</Link>
|
||||
{!isArchived && <ArchiveButton pageId={page.id} slug={page.slug} type={page.type} />}
|
||||
{!isArchived && <PinToggleButton label={page.title} pageId={page.id} isPinned={!!navlink} />}
|
||||
</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>
|
||||
<div className="flex flex-col p-4 md:p-16 gap-6 md:gap-12 mb-4 md:mb-0">
|
||||
<div className={cn("flex flex-col gap-8 md:gap-4 justify-center", isNews && "md:items-center")}>
|
||||
<div className="flex flex-col md:flex-row items-center gap-2 md:gap-6">
|
||||
<h1>{page?.title}</h1>
|
||||
{user?.isAdmin && (
|
||||
<div className="flex flex-row gap-2 items-center">
|
||||
<Link href={`/${page.type.toLowerCase()}/${page.slug}/edit`}>
|
||||
<Button variant="secondary" size="icon-sm"><PencilIcon /></Button>
|
||||
</Link>
|
||||
{!isArchived && <ArchiveButton pageId={page.id} slug={page.slug} type={page.type} />}
|
||||
{!isArchived && <PinToggleButton pageId={page.id} isPinned={!!navlink} />}
|
||||
</div>
|
||||
)}
|
||||
{blocks.map((block) => (
|
||||
<BlockRenderer key={block.id} block={block} />
|
||||
))}
|
||||
</div>
|
||||
<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>
|
||||
<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,23 +1,19 @@
|
||||
"use client";
|
||||
|
||||
import { useTransition } from "react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { PinIcon, PinOffIcon } from "lucide-react";
|
||||
import { Spinner } from "@/components/ui/spinner";
|
||||
import { pinPageAction, unpinPageAction } from "@/lib/navlinks/actions";
|
||||
import { togglePinAction } from "@/lib/navlinks/actions";
|
||||
import { useAction } from "@/hooks/useAction";
|
||||
|
||||
export function PinToggleButton({ label, pageId, isPinned }: { label: string; pageId: string; isPinned: boolean }) {
|
||||
const [isPending, startTransition] = useTransition();
|
||||
|
||||
const handleClick = () => {
|
||||
startTransition(() =>
|
||||
isPinned ? unpinPageAction(pageId) : pinPageAction(pageId)
|
||||
);
|
||||
};
|
||||
export function PinToggleButton({ pageId, isPinned }: { pageId: string; isPinned: boolean }) {
|
||||
const { run, isPending } = useAction(togglePinAction, {
|
||||
successMessage: isPinned ? "Page unpinned" : "Page pinned",
|
||||
});
|
||||
|
||||
return (
|
||||
<Button variant={isPinned ? "secondary" : "secondary"} size="icon-sm" disabled={isPending} onClick={handleClick}>
|
||||
<Button variant="secondary" size="icon-sm" disabled={isPending} onClick={() => run(pageId, isPinned)}>
|
||||
{isPending ? <Spinner /> : isPinned ? <PinOffIcon /> : <PinIcon />}
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ export function AccountMenu() {
|
||||
const pathname = usePathname();
|
||||
|
||||
return (
|
||||
<div className="flex flex-col w-56 gap-2 mx-16 shrink-0">
|
||||
<div className="flex flex-col md:w-56 gap-2 md:mx-16 shrink-0">
|
||||
{menuItems.map((item) => {
|
||||
const Icon = item.icon;
|
||||
const active = pathname === item.href;
|
||||
|
||||
@@ -64,7 +64,7 @@ export function CitizenshipApplicationForm({ firstName, secondName, sex, birthDa
|
||||
<FieldGroup>
|
||||
<FieldSet>
|
||||
<FieldLegend>Personal information</FieldLegend>
|
||||
<Alert variant="warning">
|
||||
<Alert className="mt-2" variant="warning">
|
||||
<InfoIcon />
|
||||
<AlertTitle>Important notice</AlertTitle>
|
||||
<AlertDescription>
|
||||
@@ -251,7 +251,7 @@ export function CitizenshipApplicationForm({ firstName, secondName, sex, birthDa
|
||||
<FieldLegend>Additional information</FieldLegend>
|
||||
<FieldDescription>Provide details required for your identity document.</FieldDescription>
|
||||
<FieldGroup>
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<div className="grid md:grid-cols-2 gap-4">
|
||||
<Field data-invalid={!!errors.height?.length}>
|
||||
<FieldLabel htmlFor="height">Height (in cm)</FieldLabel>
|
||||
<Input
|
||||
@@ -293,6 +293,8 @@ export function CitizenshipApplicationForm({ firstName, secondName, sex, birthDa
|
||||
label="Profile"
|
||||
description="Select a profile image to upload. The image should be taken on a neutral background."
|
||||
error={errors.profile?.[0]}
|
||||
previewClassName="aspect-4/5"
|
||||
removeBg
|
||||
/>
|
||||
<ImageUploadField
|
||||
id="signature"
|
||||
@@ -300,6 +302,7 @@ export function CitizenshipApplicationForm({ firstName, secondName, sex, birthDa
|
||||
label="Signature"
|
||||
description="Select a signature to upload."
|
||||
error={errors.signature?.[0]}
|
||||
previewClassName="aspect-5/2"
|
||||
/>
|
||||
</FieldGroup>
|
||||
</FieldSet>
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { useRef, useState } from "react";
|
||||
import { Field, FieldDescription, FieldError, FieldLabel } from "@/components/ui/field";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { XIcon, ImageIcon } from "lucide-react";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { removeBackground } from "@imgly/background-removal";
|
||||
import { Spinner } from "@/components/ui/spinner";
|
||||
|
||||
type Props = {
|
||||
id: string;
|
||||
@@ -11,41 +15,74 @@ type Props = {
|
||||
label: string;
|
||||
description: string;
|
||||
error?: string;
|
||||
previewClassName?: string;
|
||||
removeBg?: boolean;
|
||||
};
|
||||
|
||||
export function ImageUploadField({ id, name, label, description, error }: Props) {
|
||||
const MAX_SIZE = 5 * 1024 * 1024;
|
||||
const ACCEPTED_TYPES = ["image/jpeg", "image/png", "image/webp"];
|
||||
|
||||
function formatFileSize(bytes: number): string {
|
||||
return bytes < 1024 * 1024 ? `${Math.round(bytes / 1024)} KB` : `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
||||
}
|
||||
|
||||
export function ImageUploadField({ id, name, label, description, error, previewClassName, removeBg }: Props) {
|
||||
const inputRef = useRef<HTMLInputElement>(null);
|
||||
const [previewUrl, setPreviewUrl] = useState<string | null>(null);
|
||||
const [fileInfo, setFileInfo] = useState<{ name: string; size: number } | null>(null);
|
||||
const [clientError, setClientError] = useState<string | null>(null);
|
||||
const [isProcessing, setIsProcessing] = useState(false);
|
||||
|
||||
const MAX_SIZE = 5 * 1024 * 1024;
|
||||
const ACCEPTED_TYPES = ["image/jpeg", "image/png", "image/webp"];
|
||||
|
||||
function handleChange(e: React.ChangeEvent<HTMLInputElement>) {
|
||||
const file = e.target.files?.[0];
|
||||
function reset() {
|
||||
if (previewUrl) URL.revokeObjectURL(previewUrl);
|
||||
setPreviewUrl(null);
|
||||
setFileInfo(null);
|
||||
if (inputRef.current) inputRef.current.value = "";
|
||||
}
|
||||
|
||||
if (!file) {
|
||||
setPreviewUrl(null);
|
||||
setClientError(null);
|
||||
return;
|
||||
}
|
||||
async function handleChange(e: React.ChangeEvent<HTMLInputElement>) {
|
||||
const file = e.target.files?.[0];
|
||||
if (!file) { reset(); setClientError(null); return; }
|
||||
|
||||
if (!ACCEPTED_TYPES.includes(file.type)) {
|
||||
setClientError("Only JPEG, PNG, or WEBP images are allowed.");
|
||||
setPreviewUrl(null);
|
||||
e.target.value = "";
|
||||
reset();
|
||||
return;
|
||||
}
|
||||
|
||||
if (file.size > MAX_SIZE) {
|
||||
setClientError("Image must be smaller than 5MB.");
|
||||
setPreviewUrl(null);
|
||||
e.target.value = "";
|
||||
reset();
|
||||
return;
|
||||
}
|
||||
|
||||
setClientError(null);
|
||||
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;
|
||||
@@ -53,27 +90,47 @@ export function ImageUploadField({ id, name, label, description, error }: Props)
|
||||
return (
|
||||
<Field data-invalid={!!displayedError}>
|
||||
<FieldLabel htmlFor={id}>{label}</FieldLabel>
|
||||
<div className="flex items-center gap-4">
|
||||
{previewUrl && (
|
||||
<img
|
||||
src={previewUrl}
|
||||
alt=""
|
||||
className={cn(
|
||||
"w-16 h-16 rounded-md object-cover ring-1 ring-foreground/10 shrink-0"
|
||||
)}
|
||||
<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-4/5"
|
||||
)}
|
||||
>
|
||||
{isProcessing ? (
|
||||
<Spinner className="text-muted-foreground" />
|
||||
) : previewUrl ? (
|
||||
<img src={previewUrl} alt="" className="w-full h-full object-cover" />
|
||||
) : (
|
||||
<ImageIcon className="text-muted-foreground" size={24} />
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col gap-1 flex-1 min-w-0">
|
||||
<Input
|
||||
ref={inputRef}
|
||||
id={id}
|
||||
name={name}
|
||||
type="file"
|
||||
accept="image/jpeg,image/png,image/webp"
|
||||
aria-invalid={!!displayedError}
|
||||
onChange={handleChange}
|
||||
disabled={isProcessing}
|
||||
required={!fileInfo}
|
||||
/>
|
||||
)}
|
||||
<Input
|
||||
id={id}
|
||||
name={name}
|
||||
type="file"
|
||||
accept="image/jpeg,image/png,image/webp"
|
||||
aria-invalid={!!displayedError}
|
||||
onChange={handleChange}
|
||||
required
|
||||
/>
|
||||
{fileInfo && (
|
||||
<div className="flex items-center gap-2 text-sm text-muted-foreground w-full min-w-0">
|
||||
<span className="flex-1 min-w-0 truncate">
|
||||
{fileInfo.name} ({formatFileSize(fileInfo.size)})
|
||||
</span>
|
||||
<Button type="button" variant="ghost" size="icon" className="h-6 w-6" onClick={reset} disabled={isProcessing}>
|
||||
<XIcon size={14} />
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
<FieldDescription className="mt-1">{description}</FieldDescription>
|
||||
</div>
|
||||
</div>
|
||||
<FieldDescription>{description}</FieldDescription>
|
||||
{displayedError && <FieldError>{displayedError}</FieldError>}
|
||||
</Field>
|
||||
);
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import Footer from "@/components/footer";
|
||||
import Header from "@/components/header";
|
||||
import { getCurrentUser } from "@/lib/user";
|
||||
import { redirect } from "next/navigation";
|
||||
import { AccountMenu } from "../../account-menu";
|
||||
@@ -17,34 +15,30 @@ export default async function CitizenshipApplication() {
|
||||
const regions = await prisma.region.findMany({ orderBy: { name: "asc" } });
|
||||
|
||||
return (
|
||||
<>
|
||||
<Header />
|
||||
<div className="flex flex-row py-16 gap-8">
|
||||
<AccountMenu />
|
||||
<div className="flex flex-col gap-8">
|
||||
<div className="flex flex-col gap-6">
|
||||
<h2>Citizenship application</h2>
|
||||
<div className="w-96 flex flex-col gap-6">
|
||||
{!eligibility.eligible ? (
|
||||
<Alert variant="warning">
|
||||
<InfoIcon />
|
||||
<AlertTitle>Cannot submit application</AlertTitle>
|
||||
<AlertDescription>{eligibility.reason}</AlertDescription>
|
||||
</Alert>
|
||||
) : (
|
||||
<CitizenshipApplicationForm
|
||||
firstName={user.firstName}
|
||||
secondName={user.secondName}
|
||||
sex={user.sex}
|
||||
birthDate={user.birthDate!}
|
||||
regions={regions}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
<div className="flex flex-col md:flex-row p-4 md:p-16 gap-8 md:gap-16 mb-4 md:mb-0">
|
||||
<AccountMenu />
|
||||
<div className="flex flex-col gap-8 w-full">
|
||||
<div className="flex flex-col gap-6">
|
||||
<h2>Citizenship application</h2>
|
||||
<div className="max-w-96 w-full flex flex-col gap-6">
|
||||
{!eligibility.eligible ? (
|
||||
<Alert variant="warning">
|
||||
<InfoIcon />
|
||||
<AlertTitle>Cannot submit application</AlertTitle>
|
||||
<AlertDescription>{eligibility.reason}</AlertDescription>
|
||||
</Alert>
|
||||
) : (
|
||||
<CitizenshipApplicationForm
|
||||
firstName={user.firstName}
|
||||
secondName={user.secondName}
|
||||
sex={user.sex}
|
||||
birthDate={user.birthDate!}
|
||||
regions={regions}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<Footer />
|
||||
</>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -34,11 +34,9 @@ export async function HasCitizenship({ userId }: { userId: string }) {
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-8">
|
||||
<div className="flex flex-col gap-6 md:gap-8">
|
||||
<IdentityCard data={identityDocument} />
|
||||
<div className="flex flex-col gap-2">
|
||||
<RenunciationDialog citizenship={citizenship} />
|
||||
</div>
|
||||
<RenunciationDialog citizenship={citizenship} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -25,13 +25,13 @@ export async function NoCitizenship({ userId }: { userId: string }) {
|
||||
</AlertDescription>
|
||||
</Alert>
|
||||
|
||||
<div className="flex flex-col gap-3">
|
||||
<div className="flex flex-row gap-3 w-max">
|
||||
<div className="flex flex-col gap-3 w-full">
|
||||
<div className="flex flex-col md:flex-row gap-3">
|
||||
<Link href="/page/citizenship">
|
||||
<Button variant="secondary">Learn more about citizenship</Button>
|
||||
<Button variant="secondary" className="w-full">Learn more about citizenship</Button>
|
||||
</Link>
|
||||
<Link href="/account/citizenship/apply">
|
||||
<Button>Apply for citizenship</Button>
|
||||
<Button className="w-full">Apply for citizenship</Button>
|
||||
</Link>
|
||||
</div>
|
||||
{applications.length > 0 && <ApplicationsDialog applications={applications} />}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import Footer from "@/components/footer";
|
||||
import Header from "@/components/header";
|
||||
import { getCurrentUser } from "@/lib/user";
|
||||
import { redirect } from "next/navigation";
|
||||
import { AccountMenu } from "../account-menu";
|
||||
@@ -17,30 +15,26 @@ export default async function Citizenship() {
|
||||
const pendingCount = user.isAdmin ? await getPendingApplicationsCount() : 0
|
||||
|
||||
return (
|
||||
<>
|
||||
<Header />
|
||||
<div className="flex flex-row py-16 gap-8">
|
||||
<AccountMenu />
|
||||
<div className="flex flex-col gap-8 max-w-lg">
|
||||
<div className="flex flex-col gap-6 w-min">
|
||||
<h2>Citizenship</h2>
|
||||
<div className="flex flex-col md:flex-row p-4 md:p-16 gap-8 md:gap-16 mb-4 md:mb-0">
|
||||
<AccountMenu />
|
||||
<div className="flex flex-col gap-8 max-w-lg">
|
||||
<div className="flex flex-col gap-6 md: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 && (
|
||||
<Link href="/account/citizenship/review">
|
||||
<Button variant="secondary" className="w-full">
|
||||
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">
|
||||
{pendingCount}
|
||||
</div>
|
||||
</Button>
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
{user.isAdmin && (
|
||||
<Link href="/account/citizenship/review">
|
||||
<Button variant="secondary" className="w-full">
|
||||
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">
|
||||
{pendingCount}
|
||||
</div>
|
||||
</Button>
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<Footer />
|
||||
</>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -45,7 +45,7 @@ export function RenunciationDialog({ citizenship }: { citizenship: Citizenship }
|
||||
<DialogClose asChild>
|
||||
<Button variant="secondary">Cancel</Button>
|
||||
</DialogClose>
|
||||
<Button variant="destructive" disabled={isPending} onClick={() => run()}>
|
||||
<Button disabled={isPending} onClick={() => run()}>
|
||||
{isPending && <Spinner />}Renounce citizenship
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
|
||||
@@ -7,6 +7,7 @@ import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, D
|
||||
import { Separator } from "@/components/ui/separator";
|
||||
import { Spinner } from "@/components/ui/spinner";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
|
||||
import { approveApplication, rejectApplication } from "@/lib/citizenship/actions";
|
||||
import { CitizenshipApplicationWithWarning } from "@/lib/citizenship/types";
|
||||
import { formatDate } from "@/lib/utils";
|
||||
@@ -22,7 +23,7 @@ export default function ApplicationCard({ application, onClose }: { application:
|
||||
|
||||
if (!application?.id) {
|
||||
return (
|
||||
<div className="w-sm flex items-center justify-center ring-1 ring-foreground/10 rounded-xl text-muted-foreground px-4">
|
||||
<div className="max-w-sm w-full flex items-center justify-center ring-1 ring-foreground/10 rounded-xl text-muted-foreground px-4 py-1">
|
||||
Click on a row to see the application
|
||||
</div>
|
||||
)
|
||||
@@ -64,18 +65,14 @@ export default function ApplicationCard({ application, onClose }: { application:
|
||||
<CardDescription>{application.applicationType === "PREVIOUS_CITIZENSHIP" ? "Previous citizenship application" : "Naturalization application"}</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent className="max-w-sm">
|
||||
<div className="flex flex-row gap-2 mb-2">
|
||||
<img
|
||||
src={application.profileUrl}
|
||||
alt="Profile"
|
||||
className={"w-18 h-24 rounded-md object-cover ring-1 ring-foreground/10 shrink-0"}
|
||||
/>
|
||||
<img
|
||||
src={application.signatureUrl}
|
||||
alt="Profile"
|
||||
className={"w-36 h-18 rounded-md object-cover ring-1 ring-foreground/10 shrink-0"}
|
||||
/>
|
||||
<div className="flex flex-row gap-3 mb-4">
|
||||
<div className="w-20 aspect-4/5 rounded-md overflow-hidden ring-1 ring-foreground/10 shrink-0">
|
||||
<img src={application.profileUrl} alt="Profile photo" className="w-full h-full object-cover" />
|
||||
</div>
|
||||
<div className="w-40 px-2 aspect-5/2 rounded-md overflow-hidden ring-1 ring-foreground/10 shrink-0 bg-white">
|
||||
<img src={application.signatureUrl} alt="Signature" className="w-full h-full object-contain" />
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex flex-col gap-1">
|
||||
<h4 className="mb-1">Personal information</h4>
|
||||
{ application.nameMismatch && (
|
||||
@@ -110,7 +107,14 @@ export default function ApplicationCard({ application, onClose }: { application:
|
||||
</div>
|
||||
<div className="flex flex-col gap-0.5">
|
||||
<p className="text-muted-foreground">Address</p>
|
||||
<p className="truncate">{application.address}</p>
|
||||
<Tooltip>
|
||||
<TooltipTrigger>
|
||||
<p className="text-start truncate">{application.address}</p>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>
|
||||
<p>{application.address}</p>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
</div>
|
||||
<div className="flex flex-row gap-4 items-center">
|
||||
<p className="text-muted-foreground">Height</p>
|
||||
@@ -169,7 +173,7 @@ export default function ApplicationCard({ application, onClose }: { application:
|
||||
/>
|
||||
<DialogFooter>
|
||||
<Button variant="outline" onClick={() => setRejectOpen(false)}>Cancel</Button>
|
||||
<Button variant="destructive" onClick={handleReject} disabled={!reason.trim() || isloading}>
|
||||
<Button onClick={handleReject} disabled={!reason.trim() || isloading}>
|
||||
{isloading && <Spinner />}Confirm rejection
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
|
||||
@@ -12,7 +12,7 @@ export default function ReviewPageClient({ applications }: { applications: Citiz
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="flex flex-row gap-16">
|
||||
<div className="flex flex-col-reverse md:flex-row gap-8 md:gap-16">
|
||||
<div className="flex flex-col gap-8">
|
||||
<div className="flex flex-col gap-6">
|
||||
<h2>Review citizenship applications</h2>
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import Header from "@/components/header";
|
||||
import Footer from "@/components/footer";
|
||||
import ReviewPageClient from "./client";
|
||||
import { getCurrentUser } from "@/lib/user";
|
||||
import { redirect } from "next/navigation";
|
||||
@@ -29,13 +27,9 @@ export default async function ReviewPage() {
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Header />
|
||||
<div className="flex flex-row py-16 gap-8">
|
||||
<AccountMenu />
|
||||
<ReviewPageClient applications={applicationsWithWarning} />
|
||||
</div>
|
||||
<Footer />
|
||||
</>
|
||||
<div className="flex flex-col md:flex-row p-4 md:p-16 gap-8 md:gap-16 mb-4 md:mb-0">
|
||||
<AccountMenu />
|
||||
<ReviewPageClient applications={applicationsWithWarning} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
+37
-44
@@ -1,9 +1,6 @@
|
||||
import Footer from "@/components/footer";
|
||||
import Header from "@/components/header";
|
||||
import { Separator } from "@/components/ui/separator";
|
||||
import { getCurrentUser } from "@/lib/user";
|
||||
import { formatDate } from "@/lib/utils";
|
||||
import { BookOpenTextIcon, SignatureIcon, UserIcon } from "lucide-react";
|
||||
import { redirect } from "next/navigation";
|
||||
import { DeleteDialog } from "./delete-dialog";
|
||||
import { LogoutButton } from "./logout-button";
|
||||
@@ -24,52 +21,48 @@ export default async function Account() {
|
||||
if (!user) redirect("/");
|
||||
|
||||
return (
|
||||
<>
|
||||
<Header />
|
||||
<div className="flex flex-row py-16 gap-8">
|
||||
<AccountMenu />
|
||||
<div className="flex flex-col gap-8 max-w-lg">
|
||||
<div className="flex flex-col gap-6">
|
||||
<div className="flex flex-col gap-1">
|
||||
<h2>Personal details</h2>
|
||||
<p className="text-muted-foreground text-sm">
|
||||
Synced from your Kotosoft ID account. To correct any details, update them there first, then click Update below.
|
||||
</p>
|
||||
<div className="flex flex-col md:flex-row p-4 md:p-16 gap-8 md:gap-16 mb-4 md:mb-0">
|
||||
<AccountMenu />
|
||||
<div className="flex flex-col gap-8 max-w-lg">
|
||||
<div className="flex flex-col gap-6">
|
||||
<div className="flex flex-col gap-1">
|
||||
<h2>Personal details</h2>
|
||||
<p className="text-muted-foreground text-sm">
|
||||
Synced from your Kotosoft ID account. To correct any details, update them there first, then click Update below.
|
||||
</p>
|
||||
</div>
|
||||
<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 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" />}
|
||||
<UpdateButton />
|
||||
</div>
|
||||
<div className="flex flex-row items-center justify-between gap-2">
|
||||
<div className="flex flex-col">
|
||||
<h4>Log out</h4>
|
||||
<p className="text-muted-foreground">Log out from your account on this device</p>
|
||||
</div>
|
||||
<Separator />
|
||||
<div className="flex flex-row items-center justify-between">
|
||||
<div className="flex flex-col">
|
||||
<h4>Update personal details</h4>
|
||||
<p className="text-muted-foreground">Syncs your name, email, and birthday from Kotosoft ID</p>
|
||||
</div>
|
||||
<UpdateButton />
|
||||
</div>
|
||||
<div className="flex flex-row items-center justify-between">
|
||||
<div className="flex flex-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 />
|
||||
<LogoutButton />
|
||||
</div>
|
||||
<Separator />
|
||||
<div className="flex flex-row items-center justify-between gap-2">
|
||||
<div className="flex flex-col">
|
||||
<h4>Delete account</h4>
|
||||
<p className="text-muted-foreground">Permanently delete your account and all associated data</p>
|
||||
</div>
|
||||
<DeleteDialog />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<Footer />
|
||||
</>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
+21
-48
@@ -1,18 +1,20 @@
|
||||
"use client";
|
||||
|
||||
import { useRef, useState, useTransition } from "react";
|
||||
import { useRef } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import Editor, { EditorData } from "@/components/editor";
|
||||
import { savePageAction } from "@/lib/pages/actions";
|
||||
import { validatePage } from "@/lib/pages/validation";
|
||||
import { Loader2 } from "lucide-react";
|
||||
import { toast } from "sonner";
|
||||
import { Spinner } from "@/components/ui/spinner";
|
||||
import { useAction } from "@/hooks/useAction";
|
||||
|
||||
export default function CreatePageClient() {
|
||||
const router = useRouter();
|
||||
const [isPending, startTransition] = useTransition();
|
||||
const [fieldErrors, setFieldErrors] = useState<{ title?: string[]; slug?: string[] }>({});
|
||||
const { run, isPending } = useAction(savePageAction, {
|
||||
successMessage: "Page saved",
|
||||
onSuccess: () => router.push("/news"),
|
||||
});
|
||||
|
||||
const dataRef = useRef<EditorData>({
|
||||
title: "",
|
||||
type: "NEWS",
|
||||
@@ -23,47 +25,20 @@ export default function CreatePageClient() {
|
||||
});
|
||||
|
||||
function handleSave(status: "DRAFT" | "PUBLISHED") {
|
||||
startTransition(async () => {
|
||||
const data = dataRef.current;
|
||||
const payload = {
|
||||
id: null,
|
||||
slug: data.slug || data.title.toLowerCase().replace(/\s+/g, "-"),
|
||||
title: data.title,
|
||||
type: data.type,
|
||||
status,
|
||||
blocks: data.blocks,
|
||||
meta: { location: data.location, tags: data.tags },
|
||||
};
|
||||
|
||||
const parsed = validatePage(payload);
|
||||
if (!parsed.success) {
|
||||
const errors: { title?: string[]; slug?: string[] } = {};
|
||||
for (const msg of parsed.errors) {
|
||||
if (msg.toLowerCase().includes("title")) {
|
||||
(errors.title ??= []).push(msg);
|
||||
} else if (msg.toLowerCase().includes("slug")) {
|
||||
(errors.slug ??= []).push(msg);
|
||||
}
|
||||
}
|
||||
setFieldErrors(errors);
|
||||
toast.error(parsed.errors.join(", "));
|
||||
return;
|
||||
}
|
||||
|
||||
setFieldErrors({});
|
||||
|
||||
try {
|
||||
await savePageAction(payload);
|
||||
toast.success("Page saved");
|
||||
router.push("/news");
|
||||
} catch (e) {
|
||||
toast.error(e instanceof Error ? e.message : "Failed to save page");
|
||||
}
|
||||
const data = dataRef.current;
|
||||
run({
|
||||
id: null,
|
||||
slug: data.slug || data.title.toLowerCase().replace(/\s+/g, "-"),
|
||||
title: data.title,
|
||||
type: data.type,
|
||||
status,
|
||||
blocks: data.blocks,
|
||||
meta: { location: data.location, tags: data.tags },
|
||||
});
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex flex-col p-16 gap-12">
|
||||
<div className="flex flex-col p-4 md:p-16 gap-6 md:gap-12 mb-4 md:mb-0">
|
||||
<div className="flex flex-row items-center justify-between">
|
||||
<h1>Create page</h1>
|
||||
<div className="flex flex-row gap-3">
|
||||
@@ -72,11 +47,11 @@ export default function CreatePageClient() {
|
||||
disabled={isPending}
|
||||
onClick={() => handleSave("DRAFT")}
|
||||
>
|
||||
{isPending && <Loader2 size={14} className="animate-spin mr-1" />}
|
||||
{isPending && <Spinner />}
|
||||
Save as draft
|
||||
</Button>
|
||||
<Button disabled={isPending} onClick={() => handleSave("PUBLISHED")}>
|
||||
{isPending && <Loader2 size={14} className="animate-spin mr-1" />}
|
||||
{isPending && <Spinner />}
|
||||
Publish
|
||||
</Button>
|
||||
</div>
|
||||
@@ -84,10 +59,8 @@ export default function CreatePageClient() {
|
||||
<Editor
|
||||
onChange={(data) => {
|
||||
dataRef.current = data;
|
||||
setFieldErrors({});
|
||||
}}
|
||||
errors={fieldErrors}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-7
@@ -1,5 +1,3 @@
|
||||
import Header from "@/components/header";
|
||||
import Footer from "@/components/footer";
|
||||
import { getCurrentUser } from "@/lib/user";
|
||||
import { redirect } from "next/navigation";
|
||||
import CreatePageClient from "./client";
|
||||
@@ -9,10 +7,6 @@ export default async function CreatePage() {
|
||||
if (!user?.isAdmin) redirect("/");
|
||||
|
||||
return (
|
||||
<>
|
||||
<Header />
|
||||
<CreatePageClient />
|
||||
<Footer />
|
||||
</>
|
||||
<CreatePageClient />
|
||||
);
|
||||
}
|
||||
@@ -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 *));
|
||||
|
||||
@theme {
|
||||
--text-xs--line-height: 1.5;
|
||||
--text-sm--line-height: 1.45;
|
||||
--text-base--line-height: 1.5;
|
||||
--text-lg--line-height: 1.4;
|
||||
--text-xl--line-height: 1.35;
|
||||
--text-2xl--line-height: 1.3;
|
||||
--text-3xl--line-height: 1.25;
|
||||
}
|
||||
|
||||
@theme inline {
|
||||
--color-background: var(--background);
|
||||
--color-foreground: var(--foreground);
|
||||
@@ -133,29 +143,44 @@
|
||||
}
|
||||
|
||||
h1 {
|
||||
@apply text-3xl tracking-tight underline underline-offset-8 decoration-2
|
||||
font-size: clamp(1.5rem, 1.3446rem + 0.663vw, 1.875rem);
|
||||
line-height: 1.15;
|
||||
letter-spacing: -0.03em;
|
||||
@apply underline underline-offset-4 sm:underline-offset-8 decoration-2;
|
||||
}
|
||||
|
||||
h2 {
|
||||
@apply text-2xl tracking-tight
|
||||
font-size: clamp(1.25rem, 1.1464rem + 0.442vw, 1.5rem);
|
||||
line-height: 1.2;
|
||||
letter-spacing: -0.025em;
|
||||
}
|
||||
|
||||
h3 {
|
||||
@apply text-xl tracking-tight
|
||||
font-size: clamp(1.125rem, 1.0732rem + 0.221vw, 1.25rem);
|
||||
line-height: 1.3;
|
||||
letter-spacing: -0.02em;
|
||||
}
|
||||
|
||||
h4 {
|
||||
@apply text-lg tracking-tight
|
||||
}
|
||||
|
||||
p {
|
||||
@apply text-base tracking-tight
|
||||
font-size: clamp(1rem, 0.9482rem + 0.221vw, 1.125rem);
|
||||
line-height: 1.35;
|
||||
letter-spacing: -0.02em;
|
||||
}
|
||||
|
||||
h5 {
|
||||
@apply text-sm tracking-tight
|
||||
font-size: clamp(0.875rem, 0.6982rem + 0.221vw, 0.875rem);
|
||||
line-height: 1.4;
|
||||
letter-spacing: -0.015em;
|
||||
}
|
||||
|
||||
h6 {
|
||||
@apply text-xs tracking-tight
|
||||
font-size: clamp(0.6875rem, 0.6616rem + 0.111vw, 0.75rem);
|
||||
line-height: 1.4;
|
||||
letter-spacing: -0.01em;
|
||||
}
|
||||
|
||||
p {
|
||||
font-size: 1rem;
|
||||
line-height: 1.5;
|
||||
letter-spacing: -0.011em;
|
||||
}
|
||||
+8
-1
@@ -3,6 +3,9 @@ import localFont from "next/font/local"
|
||||
import "./globals.css";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { Toaster } from "@/components/ui/sonner";
|
||||
import { TooltipProvider } from "@/components/ui/tooltip";
|
||||
import Header from "@/components/header";
|
||||
import Footer from "@/components/footer";
|
||||
|
||||
const helvetica = localFont({
|
||||
src: "../public/fonts/HelveticaNeue-Medium.otf",
|
||||
@@ -25,7 +28,11 @@ export default function RootLayout({
|
||||
className={cn("h-full", "antialiased", helvetica.className, "font-sans")}
|
||||
>
|
||||
<body className="min-h-full flex flex-col">
|
||||
{children}
|
||||
<TooltipProvider>
|
||||
<Header />
|
||||
<div className="flex-1">{children}</div>
|
||||
<Footer />
|
||||
</TooltipProvider>
|
||||
<Toaster />
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+18
-24
@@ -1,6 +1,4 @@
|
||||
import DraftsDialog from "@/components/drafts-dialog";
|
||||
import Footer from "@/components/footer";
|
||||
import Header from "@/components/header";
|
||||
import { NewsCard } from "@/components/news-card";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { getPages } from "@/lib/pages/repository";
|
||||
@@ -17,29 +15,25 @@ export default async function News() {
|
||||
const drafts = [...newsDrafts, ...pageDrafts];
|
||||
|
||||
return (
|
||||
<>
|
||||
<Header />
|
||||
<div className="flex flex-col p-16 gap-16">
|
||||
<div className="flex flex-row items-center justify-between">
|
||||
<h1>News</h1>
|
||||
<div className="flex flex-row items-center gap-4">
|
||||
{user?.isAdmin && (
|
||||
<div className="flex flex-row items-center gap-4">
|
||||
<DraftsDialog drafts={drafts} />
|
||||
<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 className="flex flex-col p-4 md:p-16 gap-8 md:gap-16 mb-4 md:mb-0">
|
||||
<div className="flex flex-col gap-4 md:flex-row md:items-center justify-between">
|
||||
<h1>News</h1>
|
||||
<div className="flex flex-row items-center gap-4">
|
||||
{user?.isAdmin && (
|
||||
<div className="flex flex-row items-center gap-4">
|
||||
<DraftsDialog drafts={drafts} />
|
||||
<Link href="/create/"><Button variant="secondary">Create a new page</Button></Link>
|
||||
</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 { getPages } from "@/lib/pages/repository";
|
||||
import { ArrowRightIcon } from "lucide-react";
|
||||
@@ -9,48 +7,85 @@ export default async function Home() {
|
||||
const news = await getPages("NEWS", "PUBLISHED", 5);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Header />
|
||||
<div className="flex flex-col p-16 gap-16">
|
||||
<h1>Welcome to the European Federation!</h1>
|
||||
<div className="grid grid-cols-[2fr_1fr_1fr_1fr] gap-8">
|
||||
<Link href="/page/citizenship">
|
||||
<div className="flex flex-col p-4 md:p-16 gap-8 md:gap-16 mb-4 md:mb-0">
|
||||
<h1>Welcome to the European Federation!</h1>
|
||||
<div className="grid grid-cols-2 gap-4 md:hidden">
|
||||
<Link href="/page/citizenship" className="col-span-2">
|
||||
<div className="flex items-end h-64 p-4 rounded-lg bg-primary text-primary-foreground">
|
||||
<h1 className="flex flex-row items-center gap-2 hover:gap-4 hover:duration-200 cursor-pointer">Become a citizen<ArrowRightIcon size={30} /></h1>
|
||||
<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>
|
||||
</Link>
|
||||
<Link href="/page/president">
|
||||
<div className="flex items-end h-28 p-2.5 rounded-lg bg-muted">
|
||||
<h2 className="flex flex-row items-center gap-2 hover:gap-4 hover:duration-200 cursor-pointer">
|
||||
Learn more about the President
|
||||
</h2>
|
||||
</div>
|
||||
</Link>
|
||||
<div className="flex items-end h-28 p-2.5 rounded-lg bg-muted">
|
||||
<h2 className="flex flex-row items-center gap-2 hover:gap-4 hover:duration-200 cursor-pointer">
|
||||
Acknowledge with the Federal Government
|
||||
</h2>
|
||||
</div>
|
||||
<div className="flex flex-col gap-8 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 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>
|
||||
<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>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user