This commit is contained in:
Ivan Rezchikov
2026-07-11 21:40:18 +03:00
parent 6667cc55b2
commit e4844f741c
7 changed files with 30 additions and 34 deletions
+5 -3
View File
@@ -44,6 +44,10 @@ export default function EditPageClient({ page, pageType, initialBlocks = [] }: P
}); });
} }
const handleChange = (data: EditorData) => {
dataRef.current = data;
};
return ( return (
<div className="flex flex-col p-4 md:p-16 gap-6 md:gap-12 mb-4 md:mb-0"> <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">
@@ -62,9 +66,7 @@ export default function EditPageClient({ page, pageType, initialBlocks = [] }: P
page={page} page={page}
type={pageType} type={pageType}
initialBlocks={initialBlocks} initialBlocks={initialBlocks}
onChange={(data) => { onChange={handleChange}
dataRef.current = data;
}}
/> />
</div> </div>
); );
+1 -1
View File
@@ -27,7 +27,7 @@ export async function HasCitizenship({ userId }: { userId: string }) {
<TriangleAlertIcon /> <TriangleAlertIcon />
<AlertTitle>Citizenship record unavailable</AlertTitle> <AlertTitle>Citizenship record unavailable</AlertTitle>
<AlertDescription> <AlertDescription>
We couldn't verify your active citizenship record. Contact the competent authority. We couldn&apos;t verify your active citizenship record. Contact the competent authority.
</AlertDescription> </AlertDescription>
</Alert> </Alert>
); );
@@ -12,7 +12,6 @@ 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";
import { TriangleAlertIcon } from "lucide-react"; import { TriangleAlertIcon } from "lucide-react";
import Image from "next/image";
import { useState } from "react"; import { useState } from "react";
import { toast } from "sonner"; import { toast } from "sonner";
@@ -79,7 +78,7 @@ export default function ApplicationCard({ application, onClose }: { application:
<Alert className="mb-2" variant="warning"> <Alert className="mb-2" variant="warning">
<TriangleAlertIcon /> <TriangleAlertIcon />
<AlertTitle>Name mismatch</AlertTitle> <AlertTitle>Name mismatch</AlertTitle>
<AlertDescription className="w-fit max-w-full">The name on this application differs from the applicant's Kotosoft ID. Verify before approving.</AlertDescription> <AlertDescription className="w-fit max-w-full">The name on this application differs from the applicant&apos;s Kotosoft ID. Verify before approving.</AlertDescription>
</Alert> </Alert>
)} )}
{ application.previousCitizenship && ( { application.previousCitizenship && (
+22 -24
View File
@@ -11,13 +11,11 @@ import { Globe2Icon, PlusIcon, Trash2Icon, XIcon, ChevronDownIcon, ChevronUpIcon
import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue } from "./ui/select"; import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue } from "./ui/select";
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@/components/ui/dropdown-menu"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@/components/ui/dropdown-menu";
import { cn } from "@/lib/utils"; import { cn } from "@/lib/utils";
import { Input } from "./ui/input";
import { Separator } from "./ui/separator"; import { Separator } from "./ui/separator";
import { Alert } from "./ui/alert"; import { Alert } from "./ui/alert";
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
import { uploadPageImage, getImagePreviewUrl } from "@/lib/pages/actions"; import { uploadPageImage, getImagePreviewUrl } from "@/lib/pages/actions";
import { ImageUploader } from "@/components/image-uploader"; import { ImageUploader } from "@/components/image-uploader";
import { Spinner } from "@/components/ui/spinner";
export type EditorData = { export type EditorData = {
title: string; title: string;
@@ -319,13 +317,13 @@ function BlockInput({ block, onChange, previewUrls, onPreviewReady }: { block: B
<AutoResizeTextarea <AutoResizeTextarea
className="w-full bg-transparent resize-none outline-none leading-relaxed placeholder:text-muted-foreground" className="w-full bg-transparent resize-none outline-none leading-relaxed placeholder:text-muted-foreground"
placeholder="Start writing..." placeholder="Start writing..."
value={(block.content as any).text ?? ""} value={(block.content as { type: "PARAGRAPH"; text: string }).text ?? ""}
onChange={(e) => onChange({ type: "PARAGRAPH", text: e.target.value })} onChange={(e) => onChange({ type: "PARAGRAPH", text: e.target.value })}
/> />
); );
case "HEADING": case "HEADING":
const level = (block.content as any).level; const level = (block.content as { type: "HEADING"; text: string; level: 1 | 2 | 3 }).level;
return ( return (
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
@@ -339,12 +337,12 @@ function BlockInput({ block, onChange, previewUrls, onPreviewReady }: { block: B
} }
)} )}
placeholder="Heading" placeholder="Heading"
value={(block.content as any).text ?? ""} value={(block.content as { type: "HEADING"; text: string; level: 1 | 2 | 3 }).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 { type: "HEADING"; text: string; level: 1 | 2 | 3 }).level ?? 2 })}
/> />
<Select <Select
value={String((block.content as any).level ?? 2)} value={String((block.content as { type: "HEADING"; text: string; level: 1 | 2 | 3 }).level ?? 2)}
onValueChange={(v) => onChange({ type: "HEADING", text: (block.content as any).text ?? "", level: Number(v) as 1 | 2 | 3 })} onValueChange={(v) => onChange({ type: "HEADING", text: (block.content as { type: "HEADING"; text: string; level: 1 | 2 | 3 }).text ?? "", level: Number(v) as 1 | 2 | 3 })}
> >
<SelectTrigger className="w-16 h-7 opacity-0 group-hover:opacity-100 transition-opacity"> <SelectTrigger className="w-16 h-7 opacity-0 group-hover:opacity-100 transition-opacity">
<SelectValue /> <SelectValue />
@@ -364,14 +362,14 @@ function BlockInput({ block, onChange, previewUrls, onPreviewReady }: { block: B
<AutoResizeTextarea <AutoResizeTextarea
className="w-full bg-transparent resize-none outline-none leading-relaxed placeholder:text-muted-foreground" className="w-full bg-transparent resize-none outline-none leading-relaxed placeholder:text-muted-foreground"
placeholder="Quote text..." placeholder="Quote text..."
value={(block.content as any).text ?? ""} value={(block.content as { type: "QUOTE"; text: string; author?: string }).text ?? ""}
onChange={(e) => onChange({ type: "QUOTE", text: e.target.value, author: (block.content as any).author })} onChange={(e) => onChange({ type: "QUOTE", text: e.target.value, author: (block.content as { type: "QUOTE"; text: string; author?: string }).author })}
/> />
<input <input
className="w-full bg-transparent outline-none text-sm text-muted-foreground placeholder:text-muted-foreground/60" className="w-full bg-transparent outline-none text-sm text-muted-foreground placeholder:text-muted-foreground/60"
placeholder="— Author" placeholder="— Author"
value={(block.content as any).author ?? ""} value={(block.content as { type: "QUOTE"; text: string; author?: string }).author ?? ""}
onChange={(e) => onChange({ type: "QUOTE", text: (block.content as any).text, author: e.target.value })} onChange={(e) => onChange({ type: "QUOTE", text: (block.content as { type: "QUOTE"; text: string; author?: string }).text, author: e.target.value })}
/> />
</div> </div>
); );
@@ -383,14 +381,14 @@ function BlockInput({ block, onChange, previewUrls, onPreviewReady }: { block: B
<input <input
className="w-full bg-transparent outline-none text-sm font-medium placeholder:text-muted-foreground" className="w-full bg-transparent outline-none text-sm font-medium placeholder:text-muted-foreground"
placeholder="Callout title" placeholder="Callout title"
value={(block.content as any).title ?? ""} value={(block.content as { type: "CALLOUT"; title: string; text: string }).title ?? ""}
onChange={(e) => onChange({ type: "CALLOUT", title: e.target.value, text: (block.content as any).text ?? "" })} onChange={(e) => onChange({ type: "CALLOUT", title: e.target.value, text: (block.content as { type: "CALLOUT"; title: string; text: string }).text ?? "" })}
/> />
<AutoResizeTextarea <AutoResizeTextarea
className="w-full bg-transparent resize-none outline-none text-sm leading-relaxed text-muted-foreground placeholder:text-muted-foreground/60" className="w-full bg-transparent resize-none outline-none text-sm leading-relaxed text-muted-foreground placeholder:text-muted-foreground/60"
placeholder="Callout text..." placeholder="Callout text..."
value={(block.content as any).text ?? ""} value={(block.content as { type: "CALLOUT"; title: string; text: string }).text ?? ""}
onChange={(e) => onChange({ type: "CALLOUT", title: (block.content as any).title ?? "", text: e.target.value })} onChange={(e) => onChange({ type: "CALLOUT", title: (block.content as { type: "CALLOUT"; title: string; text: string }).title ?? "", text: e.target.value })}
/> />
</Alert> </Alert>
); );
@@ -409,10 +407,10 @@ function BlockInput({ block, onChange, previewUrls, onPreviewReady }: { block: B
return <Separator />; return <Separator />;
case "LIST": case "LIST":
return <ListEditor content={block.content as any} onChange={(c) => onChange(c)} />; return <ListEditor content={block.content as { type: "LIST"; style: "BULLET" | "ORDERED"; items: string[] }} onChange={(c) => onChange(c)} />;
case "TABLE": case "TABLE":
return <TableEditor content={block.content as any} onChange={(c) => onChange(c)} />; return <TableEditor content={block.content as { type: "TABLE"; headers: string[]; rows: string[][] }} onChange={(c) => onChange(c)} />;
case "LINK": case "LINK":
return ( return (
@@ -422,12 +420,12 @@ function BlockInput({ block, onChange, previewUrls, onPreviewReady }: { block: B
<input <input
className="w-full bg-transparent outline-none text-sm" className="w-full bg-transparent outline-none text-sm"
placeholder="Link label" placeholder="Link label"
value={(block.content as any).label ?? ""} value={(block.content as { type: "LINK"; label: string; href: string }).label ?? ""}
onChange={(e) => onChange={(e) =>
onChange({ onChange({
type: "LINK", type: "LINK",
label: e.target.value, label: e.target.value,
href: (block.content as any).href ?? "", href: (block.content as { type: "LINK"; label: string; href: string }).href ?? "",
}) })
} }
/> />
@@ -435,11 +433,11 @@ function BlockInput({ block, onChange, previewUrls, onPreviewReady }: { block: B
<input <input
className="w-full bg-transparent outline-none text-sm text-muted-foreground" className="w-full bg-transparent outline-none text-sm text-muted-foreground"
placeholder="URL" placeholder="URL"
value={(block.content as any).href ?? ""} value={(block.content as { type: "LINK"; label: string; href: string }).href ?? ""}
onChange={(e) => onChange={(e) =>
onChange({ onChange({
type: "LINK", type: "LINK",
label: (block.content as any).label ?? "", label: (block.content as { type: "LINK"; label: string; href: string }).label ?? "",
href: e.target.value, href: e.target.value,
}) })
} }
@@ -453,7 +451,7 @@ function BlockInput({ block, onChange, previewUrls, onPreviewReady }: { block: B
} }
} }
function ListEditor({ content, onChange }: { content: { type: "LIST"; style: "BULLET" | "ORDERED"; items: string[] }; onChange: (c: any) => void }) { function ListEditor({ content, onChange }: { content: { type: "LIST"; style: "BULLET" | "ORDERED"; items: string[] }; onChange: (c: { type: "LIST"; style: "BULLET" | "ORDERED"; items: string[] }) => void }) {
const items = content.items ?? [""]; const items = content.items ?? [""];
function updateItem(index: number, value: string) { function updateItem(index: number, value: string) {
@@ -531,7 +529,7 @@ function ListEditor({ content, onChange }: { content: { type: "LIST"; style: "BU
); );
} }
function TableEditor({ content, onChange }: { content: { type: "TABLE"; headers: string[]; rows: string[][] }; onChange: (c: any) => void }) { function TableEditor({ content, onChange }: { content: { type: "TABLE"; headers: string[]; rows: string[][] }; onChange: (c: { type: "TABLE"; headers: string[]; rows: string[][] }) => void }) {
const headers = content.headers ?? ["Column 1"]; const headers = content.headers ?? ["Column 1"];
const rows = content.rows ?? []; const rows = content.rows ?? [];
-1
View File
@@ -1,5 +1,4 @@
import Image from "next/image"; import Image from "next/image";
import { Button } from "./ui/button";
import Link from "next/link"; import Link from "next/link";
export default function Footer() { export default function Footer() {
+1 -1
View File
@@ -51,7 +51,7 @@ export const submitCitizenshipApplication = formAction(citizenshipApplicationSch
if (!eligibility.eligible) throw new AppError(eligibility.reason!); if (!eligibility.eligible) throw new AppError(eligibility.reason!);
const isEuResidentYes = data.isEuResident === "yes"; const isEuResidentYes = data.isEuResident === "yes";
const { profile, signature, isEuResident, ...applicationData } = data; const { profile, signature, ...applicationData } = data;
let regionName: string | null = null; let regionName: string | null = null;
if (isEuResidentYes) { if (isEuResidentYes) {
-2
View File
@@ -1,7 +1,5 @@
import { getSessionUserId } from "@/lib/auth/session"; import { getSessionUserId } from "@/lib/auth/session";
import { findUserById, findUsersByIds } from "@/lib/user/repository"; import { findUserById, findUsersByIds } from "@/lib/user/repository";
import { fetchKotosoftUser } from "./kotosoft/client";
import { cookies } from "next/headers";
export async function getCurrentUser() { export async function getCurrentUser() {
const userId = await getSessionUserId(); const userId = await getSessionUserId();