Compare commits

..
17 Commits
Author SHA1 Message Date
Ivan Rezchikov 646d6d326d fix: header fix 2026-11-14 15:07:40 +03:00
Ivan Rezchikov cb8d4aeed3 Stop tracking docker-compose.yml 2026-11-14 14:38:48 +03:00
Ivan Rezchikov 04da7c325b migration to rustfs 2026-11-14 14:33:14 +03:00
Ivan Rezchikov 8eefce6534 cd/cd: fix
Build and Deploy / lint-frontend (push) Successful in 20s
Build and Deploy / deploy (push) Successful in 6s
Build and Deploy / build-frontend (push) Successful in 51s
2026-09-15 20:49:37 +03:00
Ivan Rezchikov e4f0d5bca1 cd/cd: fix
Build and Deploy / lint-frontend (push) Successful in 23s
Build and Deploy / build-frontend (push) Successful in 58s
Build and Deploy / deploy (push) Canceled after 0s
2026-09-15 20:46:41 +03:00
Ivan Rezchikov 746e6e57be cd/cd: fix
Build and Deploy / lint-frontend (push) Successful in 18s
Build and Deploy / build-frontend (push) Successful in 4m9s
Build and Deploy / deploy (push) Failing after 4s
2026-09-15 20:39:10 +03:00
Ivan Rezchikov 2a85485de4 cd/cd: fix
Build and Deploy / lint-frontend (push) Successful in 22s
Build and Deploy / build-frontend (push) Failing after 3s
Build and Deploy / deploy (push) Skipped
2026-09-15 20:37:18 +03:00
Ivan Rezchikov db97576fc5 drone config removed, prisma fixed
Build and Deploy / lint-frontend (push) Successful in 31s
Build and Deploy / build-frontend (push) Failing after 41s
Build and Deploy / deploy (push) Skipped
2026-09-15 20:30:35 +03:00
Ivan Rezchikov 669c2027b9 ci: migrate to Gitea Workflows
Build and Deploy / lint-frontend (push) Successful in 25s
Build and Deploy / build-frontend (push) Failing after 24s
Build and Deploy / deploy (push) Skipped
2026-09-15 20:21:08 +03:00
Ivan Rezchikov e826e7b099 fix: services warnings in review 2026-07-26 18:38:52 +03:00
Ivan Rezchikov 2e4ea8a052 fix: services warnings in review 2026-07-26 18:36:12 +03:00
Ivan Rezchikov e46235600b add: news search bar, application history 2026-07-26 18:26:26 +03:00
Ivan Rezchikov 8aeacaf0ea fix: mobile fix 2026-07-22 14:38:23 +03:00
Ivan Rezchikov 00ed4f923b feat: network updates 2026-07-22 13:28:52 +03:00
Ivan Rezchikov 670a7d31c9 fix: docker fix 2026-07-17 12:45:36 +03:00
Ivan Rezchikov 3f03ee0742 fix: docker fix 2026-07-17 12:45:29 +03:00
Ivan Rezchikov e957879212 feat: news page is centered 2026-07-17 12:14:25 +03:00
22 changed files with 778 additions and 783 deletions
-82
View File
@@ -1,82 +0,0 @@
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
- name: appdir
path: /opt/app
commands:
- docker build
-t localhost:5000/eu:latest
-f ./Dockerfile
.
- 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_PUBLIC_URL:
from_secret: KOTOSOFT_ID_API_PUBLIC_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
DOMAIN:
from_secret: DOMAIN
commands:
- apk add --no-cache docker-cli-compose
- mkdir -p /opt/app
- cp docker-compose.yml /opt/app/docker-compose.yml
- cd /opt/app
- docker compose -p eu pull
- docker compose -p eu up -d --remove-orphans
volumes:
- name: dockersock
host:
path: /var/run/docker.sock
- name: appdir
host:
path: /opt/drone/eu
trigger:
branch:
- main
+2
View File
@@ -45,3 +45,5 @@ next-env.d.ts
/lib/generated/prisma /lib/generated/prisma
.prisma/ .prisma/
docker-compose.yml
+2 -4
View File
@@ -16,11 +16,9 @@ COPY --from=builder /app/.next ./.next
COPY --from=builder /app/public ./public COPY --from=builder /app/public ./public
COPY --from=builder /app/prisma ./prisma COPY --from=builder /app/prisma ./prisma
COPY --from=builder /app/next.config.ts ./next.config.ts COPY --from=builder /app/next.config.ts ./next.config.ts
COPY entrypoint.sh /app/entrypoint.sh
RUN chmod +x /app/entrypoint.sh
RUN npm prune --omit=dev RUN npm prune --omit=dev
EXPOSE 80 USER node
ENTRYPOINT ["/app/entrypoint.sh"] EXPOSE 3000
CMD ["npm", "start", "--", "-p", "3000", "-H", "0.0.0.0"] CMD ["npm", "start", "--", "-p", "3000", "-H", "0.0.0.0"]
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD wget -q --spider http://localhost:3000/ || exit 1 CMD wget -q --spider http://localhost:3000/ || exit 1
+24 -14
View File
@@ -14,6 +14,7 @@ import { getNavLinkByPageId } from "@/lib/navlinks/repository";
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
import { Metadata } from "next"; import { Metadata } from "next";
import { getImageUrl } from "@/lib/image"; import { getImageUrl } from "@/lib/image";
import { Badge } from "@/components/ui/badge";
function makeDescription(text?: string, maxLength = 160) { function makeDescription(text?: string, maxLength = 160) {
if (!text) return undefined; if (!text) return undefined;
@@ -127,7 +128,7 @@ function BlockRenderer({ block }: { block: Block }) {
case "CALLOUT": case "CALLOUT":
return ( return (
<Alert className="md:w-max"> <Alert className="max-w-xl">
<InfoIcon /> <InfoIcon />
<AlertTitle>{b.title}</AlertTitle> <AlertTitle>{b.title}</AlertTitle>
<AlertDescription>{b.text}</AlertDescription> <AlertDescription>{b.text}</AlertDescription>
@@ -200,8 +201,8 @@ function BlockRenderer({ block }: { block: Block }) {
return <Separator />; return <Separator />;
case "LINK": case "LINK":
return <Link href={b.href} target="_blank"> return <Link href={b.href} className="w-max " target="_blank">
<Button variant="secondary" className="max-w-full">{b.label}</Button> <Button variant="secondary">{b.label}</Button>
</Link> </Link>
default: default:
@@ -249,6 +250,8 @@ export default async function Page({ params }: { params: Promise<{ type: string;
user?.isAdmin && wasUpdatedByOther && updatedBy user?.isAdmin && wasUpdatedByOther && updatedBy
? `${updatedBy.firstName} ${updatedBy.secondName}` ? `${updatedBy.firstName} ${updatedBy.secondName}`
: null, : null,
tags: isNews ? page.meta.tags : null,
}; };
return ( return (
@@ -273,18 +276,25 @@ export default async function Page({ params }: { params: Promise<{ type: string;
{meta.author && <p className="flex gap-1.5 items-center"><UserIcon size={16} />{meta.author}</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>} {meta.updatedBy && <p className="flex gap-1.5 items-center"><UserIcon size={16} />Last update by {meta.updatedBy}</p>}
</div> </div>
{isNews && (<div className="flex flex-row gap-4">
{((meta as PageMeta)?.tags)?.map((tag) => (
<Badge key={tag}>{tag}</Badge>
))}
</div>)}
</div> </div>
<div className="flex flex-col gap-6"> <div className={cn(isNews && `max-w-2xl mx-auto`)}>
{isArchived && ( <div className="flex flex-col gap-6 [&>a+a]:-my-2.5">
<Alert className="md:w-max"> {isArchived && (
<InfoIcon /> <Alert className="md:w-max">
<AlertTitle>This page is archived</AlertTitle> <InfoIcon />
<AlertDescription>It can be seen only by administrators. Make any edits to make it visible again.</AlertDescription> <AlertTitle>This page is archived</AlertTitle>
</Alert> <AlertDescription>It can be seen only by administrators. Make any edits to make it visible again.</AlertDescription>
)} </Alert>
{resolvedBlocks.map((block) => ( )}
<BlockRenderer key={block.id} block={block} /> {resolvedBlocks.map((block) => (
))} <BlockRenderer key={block.id} block={block} />
))}
</div>
</div> </div>
</div> </div>
); );
@@ -10,8 +10,8 @@ import { Textarea } from "@/components/ui/textarea";
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip"; 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 { cn, formatDate } from "@/lib/utils";
import { TriangleAlertIcon } from "lucide-react"; import { CheckIcon, ClockFadingIcon, PlusIcon, TriangleAlertIcon, XIcon } from "lucide-react";
import { useState } from "react"; import { useState } from "react";
import { toast } from "sonner"; import { toast } from "sonner";
@@ -36,7 +36,6 @@ export default function ApplicationCard({ application, onClose }: { application:
setIsLoading(false) setIsLoading(false)
if (result.success) { if (result.success) {
toast.success("Application approved") toast.success("Application approved")
onClose()
} else { } else {
toast.error(result.error ?? "Failed to approve application") toast.error(result.error ?? "Failed to approve application")
} }
@@ -50,7 +49,6 @@ export default function ApplicationCard({ application, onClose }: { application:
if (result.success) { if (result.success) {
toast.success("Application rejected") toast.success("Application rejected")
setRejectOpen(false) setRejectOpen(false)
onClose()
} else { } else {
toast.error(result.error ?? "Failed to reject application") toast.error(result.error ?? "Failed to reject application")
} }
@@ -64,24 +62,24 @@ 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-3 mb-4"> {application.status !== "REJECTED" && (<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"> <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" /> <img src={application.profileUrl} alt="Profile photo" className="w-full h-full object-cover" />
</div> </div>
<div className="w-40 px-2 aspect-5/2 rounded-md overflow-hidden ring-1 ring-foreground/10 shrink-0 bg-white"> <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" /> <img src={application.signatureUrl} alt="Signature" className="w-full h-full object-contain" />
</div> </div>
</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.status === "PENDING" && application.nameMismatch && (
<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&apos;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.status === "PENDING" && application.previousCitizenship && (
<Alert className="mb-2" variant="warning"> <Alert className="mb-2" variant="warning">
<TriangleAlertIcon /> <TriangleAlertIcon />
<AlertTitle>Previous citizenship holder</AlertTitle> <AlertTitle>Previous citizenship holder</AlertTitle>
@@ -147,17 +145,51 @@ export default function ApplicationCard({ application, onClose }: { application:
</div> </div>
) )
} }
<Separator className="my-2" />
<div className="flex flex-col gap-1">
<h4 className="mb-1">Application history</h4>
</div>
<div className="flex flex-col gap-1">
<div className="flex flex-row gap-2 items-center text-muted-foreground">
<PlusIcon size={16} /><p>Created on {formatDate(application.createdAt)}</p>
</div>
{application.status !== "PENDING" && (<div className="flex flex-row gap-2 items-center text-muted-foreground">
<ClockFadingIcon size={16} /><p>{application.reviewedAt ? `Reviewed on ${formatDate(application.reviewedAt)} by ${application.reviewer?.firstName} ${application.reviewer?.secondName}` : "Reviewed"}</p>
</div>)}
{application.status === "REJECTED" && (
<div className="flex flex-col gap-0.5">
<div className="flex flex-row gap-2 items-center text-destructive">
<XIcon size={16} /><p>Rejected</p>
</div>
<div className="flex flex-col">
<p>Rejection reason</p>
<p className="text-muted-foreground">{application.rejectionReason}</p>
</div>
</div>
)}
{application.status === "APPROVED" && (
<div className="flex flex-row gap-2 items-center">
<CheckIcon size={16} /><p>Approved</p>
</div>
)}
</div>
</div> </div>
</CardContent> </CardContent>
<CardFooter className="gap-2"> {application.status === "PENDING" ? (
<Button onClick={handleApprove} disabled={isloading}> <CardFooter className="gap-2">
{isloading && <Spinner />}Approve <Button onClick={handleApprove} disabled={isloading}>
</Button> {isloading && <Spinner />}Approve
<Button variant="outline" onClick={() => setRejectOpen(true)} disabled={isloading}> </Button>
{isloading && <Spinner />}Reject <Button variant="outline" onClick={() => setRejectOpen(true)} disabled={isloading}>
</Button> {isloading && <Spinner />}Reject
<Button variant="outline" onClick={onClose}>Close</Button> </Button>
</CardFooter> <Button variant="outline" onClick={onClose}>Close</Button>
</CardFooter>
) : (
<CardFooter>
<Button variant="outline" onClick={onClose}>Close</Button>
</CardFooter>
)}
</Card> </Card>
<Dialog open={rejectOpen} onOpenChange={setRejectOpen}> <Dialog open={rejectOpen} onOpenChange={setRejectOpen}>
<DialogContent> <DialogContent>
+9 -1
View File
@@ -5,6 +5,14 @@ import { CitizenshipApplication } from "@/lib/citizenship/types";
import { Badge } from "@/components/ui/badge"; import { Badge } from "@/components/ui/badge";
import { formatDate } from "@/lib/utils"; import { formatDate } from "@/lib/utils";
type BadgeVariant = "default" | "outline" | "destructive";
const variants: Record<string, BadgeVariant> = {
PENDING: "outline",
REJECTED: "destructive",
APPROVED: "default",
}
export const columns: ColumnDef<CitizenshipApplication>[] = [ export const columns: ColumnDef<CitizenshipApplication>[] = [
{ {
accessorKey: "surname", accessorKey: "surname",
@@ -31,7 +39,7 @@ export const columns: ColumnDef<CitizenshipApplication>[] = [
header: "Status", header: "Status",
cell: ({ row }) => { cell: ({ row }) => {
const status = row.getValue("status") as string const status = row.getValue("status") as string
return <Badge variant={status === "PENDING" ? "outline" : "default"}>{status}</Badge> return <Badge variant={variants[status] ?? "default"}>{status}</Badge>
}, },
}, },
] ]
+23 -12
View File
@@ -2,9 +2,10 @@ import ReviewPageClient from "./client";
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";
import { getPendingApplications } from "@/lib/citizenship/repository"; import { getAllApplications } from "@/lib/citizenship/repository";
import { getImageUrl } from "@/lib/image"; import { getImageUrl } from "@/lib/image";
import { Metadata } from "next"; import { Metadata } from "next";
import { findUserById } from "@/lib/user/repository";
export const metadata: Metadata = { export const metadata: Metadata = {
title: "Review citizenship applications", title: "Review citizenship applications",
@@ -18,21 +19,31 @@ export default async function ReviewPage() {
const user = await getCurrentUser(); const user = await getCurrentUser();
if (!user?.isAdmin) redirect("/account/citizenship"); if (!user?.isAdmin) redirect("/account/citizenship");
const applications = await getPendingApplications(); const applications = await getAllApplications();
const applicationsWithWarning = await Promise.all( const applicationsWithWarning = await Promise.all(
applications.map(async (application) => ({ applications.map(async (application) => {
...application, const reviewerUser = application.reviewedBy
profileUrl: await getImageUrl(application.profileKey), ? await findUserById(application.reviewedBy)
signatureUrl: await getImageUrl(application.signatureKey), : null;
nameMismatch: return {
application.givenNames !== application.user.firstName || ...application,
application.surname !== application.user.secondName, profileUrl: await getImageUrl(application.profileKey),
signatureUrl: await getImageUrl(application.signatureKey),
previousCitizenship: nameMismatch:
application.user._count.citizenships > 0, application.givenNames !== application.user.firstName ||
})) application.surname !== application.user.secondName,
previousCitizenship:
application.user._count.citizenships > 0,
reviewer: reviewerUser
? { firstName: reviewerUser.firstName, secondName: reviewerUser.secondName }
: null,
};
})
); );
return ( return (
+5
View File
@@ -0,0 +1,5 @@
export const dynamic = "force-dynamic";
export function GET() {
return Response.json({ ok: true });
}
+17 -6
View File
@@ -5,13 +5,23 @@ import { getPages } from "@/lib/pages/repository";
import { getCurrentUser } from "@/lib/user"; import { getCurrentUser } from "@/lib/user";
import { Metadata } from "next"; import { Metadata } from "next";
import Link from "next/link"; import Link from "next/link";
import SearchBar from "./searchBar";
export const metadata: Metadata = { title: "News" }; export const metadata: Metadata = { title: "News" };
export default async function News() { export default async function News({ searchParams }: { searchParams: Promise<{ q?: string }> }) {
const { q } = await searchParams;
const user = await getCurrentUser(); const user = await getCurrentUser();
const news = await getPages("NEWS", "PUBLISHED"); const news = await getPages("NEWS", "PUBLISHED");
const query = q?.trim().toLowerCase() ?? "";
const filteredNews = query
? news.filter((n) =>
`${n.title.toLowerCase()} ${n.meta.tags?.join(" ").toLowerCase() ?? ""}`.includes(query)
)
: news;
const newsDrafts = await getPages("NEWS", "DRAFT"); const newsDrafts = await getPages("NEWS", "DRAFT");
const pageDrafts = await getPages("PAGE", "DRAFT"); const pageDrafts = await getPages("PAGE", "DRAFT");
@@ -21,6 +31,7 @@ export default async function News() {
<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 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"> <div className="flex flex-col gap-4 md:flex-row md:items-center justify-between">
<h1>News</h1> <h1>News</h1>
<SearchBar />
<div className="flex flex-row items-center gap-4"> <div className="flex flex-row items-center gap-4">
{user?.isAdmin && ( {user?.isAdmin && (
<div className="flex flex-row items-center gap-4"> <div className="flex flex-row items-center gap-4">
@@ -31,11 +42,11 @@ export default async function News() {
</div> </div>
</div> </div>
<div className="flex flex-col gap-6"> <div className="flex flex-col gap-6">
{ {
news.length > 0 ? news.map((n) => ( filteredNews.length > 0 ? filteredNews.map((n) => (
<NewsCard news={n} key={n.id} /> <NewsCard news={n} key={n.id} />
)) : <h2 className="text-muted-foreground">There are no news yet...</h2> )) : <h2 className="text-muted-foreground">There are no news yet...</h2>
} }
</div> </div>
</div> </div>
); );
+45
View File
@@ -0,0 +1,45 @@
"use client"
import { SearchIcon } from "lucide-react";
import { InputGroup, InputGroupAddon, InputGroupInput } from "@/components/ui/input-group";
import { Field } from "@/components/ui/field";
import { usePathname, useRouter, useSearchParams } from "next/navigation";
import { useState, useTransition } from "react";
export default function SearchBar() {
const router = useRouter();
const pathname = usePathname();
const searchParams = useSearchParams();
const [value, setValue] = useState(searchParams.get("q") ?? "");
const [, startTransition] = useTransition();
function handleChange(next: string) {
setValue(next);
const params = new URLSearchParams(searchParams.toString());
if (next) {
params.set("q", next);
} else {
params.delete("q");
}
startTransition(() => {
router.replace(`${pathname}?${params.toString()}`, { scroll: false });
});
}
return (
<Field className="max-w-sm">
<InputGroup>
<InputGroupInput
placeholder="Search..."
value={value}
onChange={(e) => handleChange(e.target.value)}
/>
<InputGroupAddon align="inline-start">
<SearchIcon className="text-muted-foreground" />
</InputGroupAddon>
</InputGroup>
</Field>
)
}
+1
View File
@@ -1,6 +1,7 @@
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";
import Image from "next/image";
import Link from "next/link"; import Link from "next/link";
export default async function Home() { export default async function Home() {
+464 -521
View File
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -7,8 +7,8 @@ import { formatDate } from "@/lib/utils";
export function NewsCard({ news }: { news: PagePublic }) { export function NewsCard({ news }: { news: PagePublic }) {
return ( return (
<div className="flex flex-col gap-1"> <div className="flex flex-col gap-1">
<Link href={`/news/${news.slug}`} className="w-max"> <Link href={`/news/${news.slug}`} className="max-w-vh">
<h2 className="hover:underline underline-offset-8 decoration-2 cursor-pointer">{news.title}</h2> <h2 className="hover:underline underline-offset-8 decoration-2 cursor-pointer truncate">{news.title}</h2>
</Link> </Link>
<div className="flex flex-col md:flex-row gap-2 md:gap-8 md:items-center"> <div className="flex flex-col md:flex-row gap-2 md:gap-8 md:items-center">
<div className="flex flex-row gap-4 md:gap-8"> <div className="flex flex-row gap-4 md:gap-8">
-37
View File
@@ -1,37 +0,0 @@
services:
eu:
image: localhost:5000/eu:latest
restart: unless-stopped
extra_hosts:
- "assets.dusiburg.ru:172.18.0.4"
environment:
PUBLIC_URL: ${PUBLIC_URL}
DATABASE_URL: ${DATABASE_URL}
KOTOSOFT_ID_API_PUBLIC_URL: ${KOTOSOFT_ID_API_PUBLIC_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_ACCESS_KEY: ${MINIO_ACCESS_KEY}
MINIO_SECRET_KEY: ${MINIO_SECRET_KEY}
MINIO_PUBLIC_URL: ${MINIO_PUBLIC_URL}
VIRTUAL_HOST: ${DOMAIN}
VIRTUAL_PORT: 3000
LETSENCRYPT_HOST: ${DOMAIN}
LETSENCRYPT_EMAIL: ${LETSENCRYPT_EMAIL}
expose:
- "3000"
networks:
- proxy
- eu_net
networks:
proxy:
external: true
eu_net:
external: true
-19
View File
@@ -1,19 +0,0 @@
#!/bin/sh
set -e
NGINX_PROXY_NAME="${NGINX_PROXY_CONTAINER_NAME:-nginx-proxy}"
TARGET_DOMAIN=$(echo "$MINIO_PUBLIC_URL" | sed -E 's#^https?://##; s#/.*##; s#:.*##')
if [ -n "$TARGET_DOMAIN" ]; then
IP=$(getent hosts "$NGINX_PROXY_NAME" | awk '{ print $1 }' | head -n1)
if [ -n "$IP" ]; then
echo "$IP $TARGET_DOMAIN" >> /etc/hosts
echo "[entrypoint] resolved $NGINX_PROXY_NAME -> $IP for $TARGET_DOMAIN"
else
echo "[entrypoint] WARNING: could not resolve $NGINX_PROXY_NAME, using public DNS as fallback"
fi
fi
exec "$@"
+1 -2
View File
@@ -77,9 +77,8 @@ export async function getUserApplications(userId: string) {
}); });
} }
export async function getPendingApplications() { export async function getAllApplications() {
return prisma.citizenshipApplication.findMany({ return prisma.citizenshipApplication.findMany({
where: { status: "PENDING" },
orderBy: { createdAt: "desc" }, orderBy: { createdAt: "desc" },
include: { include: {
user: { user: {
+1
View File
@@ -43,4 +43,5 @@ export type CitizenshipApplicationWithWarning = CitizenshipApplication & {
previousCitizenship: boolean; previousCitizenship: boolean;
profileUrl: string; profileUrl: string;
signatureUrl: string; signatureUrl: string;
reviewer: { firstName: string; secondName: string } | null;
}; };
+37 -12
View File
@@ -1,29 +1,42 @@
import crypto from "crypto"; import crypto from "crypto";
import sharp from "sharp"; import sharp from "sharp";
import { DeleteObjectCommand, GetObjectCommand, PutObjectCommand } from "@aws-sdk/client-s3";
import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
import { AppError } from "@/lib/action-result"; import { AppError } from "@/lib/action-result";
import { getMinioClient } from "@/lib/minio"; import { BUCKET, getInternalClient, getPublicClient } from "@/lib/storage";
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"]); const ALLOWED_INPUT_FORMATS = new Set(["jpeg", "png", "webp"]);
export async function uploadImage(file: File, directory: string, options: { maxWidth?: number; maxHeight?: number; fit?: "inside" | "cover" }): Promise<string> { const DIRECTORY_RE = /^[a-z0-9][a-z0-9_-]*(\/[a-z0-9][a-z0-9_-]*)*$/;
const KEY_RE = /^[a-z0-9][a-z0-9_-]*(\/[a-z0-9][a-z0-9_-]*)*\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\.webp$/;
const URL_WINDOW_SEC = 60 * 60;
const URL_EXPIRES_SEC = URL_WINDOW_SEC * 2;
export async function uploadImage(
file: File,
directory: string,
options: { maxWidth?: number; maxHeight?: number; fit?: "inside" | "cover" } = {},
): Promise<string> {
if (!DIRECTORY_RE.test(directory)) throw new Error("Invalid upload directory");
if (file.size === 0) throw new AppError("A file is required"); if (file.size === 0) throw new AppError("A file is required");
if (file.size > MAX_FILE_SIZE) throw new AppError("Image must be smaller than 5MB"); 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());
if (input.length > MAX_FILE_SIZE) throw new AppError("Image must be smaller than 5MB");
const image = sharp(input, { const image = sharp(input, {
failOn: "error", failOn: "error",
limitInputPixels: 30_000_000, limitInputPixels: 30_000_000,
sequentialRead: true,
}); });
const metadata = await image.metadata(); const metadata = await image.metadata();
if (!metadata.format || !ALLOWED_INPUT_FORMATS.has(metadata.format)) { if (!metadata.format || !ALLOWED_INPUT_FORMATS.has(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) { if (!metadata.width || !metadata.height || metadata.width < 100 || metadata.height < 100) {
throw new AppError("Image is too small"); throw new AppError("Image is too small");
} }
@@ -41,19 +54,31 @@ export async function uploadImage(file: File, directory: string, options: { maxW
.webp({ quality: 80, effort: 4 }) .webp({ quality: 80, effort: 4 })
.toBuffer(); .toBuffer();
const key = `${directory}/${crypto.randomUUID()}.webp`; const key = `${directory}/${crypto.randomUUID()}.webp`;
await getMinioClient().putObject(BUCKET, key, output, output.length, { "Content-Type": "image/webp" }); await getInternalClient().send(
new PutObjectCommand({
Bucket: BUCKET,
Key: key,
Body: output,
ContentLength: output.length,
ContentType: "image/webp",
CacheControl: "public, max-age=31536000, immutable",
}),
);
return key; return key;
} }
export async function removeImage(key: string) { export async function removeImage(key: string) {
await getMinioClient().removeObject(BUCKET, key) if (!KEY_RE.test(key)) throw new Error("Invalid image key");
await getInternalClient().send(new DeleteObjectCommand({ Bucket: BUCKET, Key: key }));
} }
export async function getImageUrl(key: string): Promise<string> { export async function getImageUrl(key: string): Promise<string> {
return getMinioClient().presignedGetObject( if (!KEY_RE.test(key)) throw new Error("Invalid image key");
BUCKET, const windowMs = URL_WINDOW_SEC * 1000;
key, const signingDate = new Date(Math.floor(Date.now() / windowMs) * windowMs);
60 * 5 return getSignedUrl(getPublicClient(), new GetObjectCommand({ Bucket: BUCKET, Key: key }), {
); expiresIn: URL_EXPIRES_SEC,
signingDate,
});
} }
-17
View File
@@ -1,17 +0,0 @@
import { Client } from "minio";
let _client: Client | null = null;
export function getMinioClient(): Client {
if (!_client) {
const url = new URL(process.env.MINIO_PUBLIC_URL!);
_client = new Client({
endPoint: url.hostname,
port: url.port ? Number(url.port) : 443,
useSSL: url.protocol === "https:",
accessKey: process.env.MINIO_ACCESS_KEY!,
secretKey: process.env.MINIO_SECRET_KEY!,
});
}
return _client;
}
+46
View File
@@ -0,0 +1,46 @@
import "server-only";
import { S3Client } from "@aws-sdk/client-s3";
function env(name: string): string {
const value = process.env[name];
if (!value) throw new Error(`Missing environment variable: ${name}`);
return value;
}
export const BUCKET = process.env.RUSTFS_BUCKET ?? "uploads";
const REGION = process.env.RUSTFS_REGION ?? "us-east-1";
let internalClient: S3Client | null = null;
let publicClient: S3Client | null = null;
const credentials = () => ({
accessKeyId: env("RUSTFS_ACCESS_KEY"),
secretAccessKey: env("RUSTFS_SECRET_KEY"),
});
export function getInternalClient(): S3Client {
internalClient ??= new S3Client({
endpoint: `http://${env("RUSTFS_INTERNAL_HOST")}:${process.env.RUSTFS_INTERNAL_PORT ?? 9000}`,
region: REGION,
credentials: credentials(),
forcePathStyle: true,
requestChecksumCalculation: "WHEN_REQUIRED",
responseChecksumValidation: "WHEN_REQUIRED",
maxAttempts: 3,
requestHandler: { connectionTimeout: 3_000, requestTimeout: 15_000 },
});
return internalClient;
}
export function getPublicClient(): S3Client {
publicClient ??= new S3Client({
endpoint: new URL(env("RUSTFS_PUBLIC_URL")).origin,
region: REGION,
credentials: credentials(),
forcePathStyle: true,
requestChecksumCalculation: "WHEN_REQUIRED",
responseChecksumValidation: "WHEN_REQUIRED",
});
return publicClient;
}
+13 -9
View File
@@ -1,22 +1,26 @@
import type { NextConfig } from "next"; import type { NextConfig } from "next";
const minioHost = process.env.MINIO_PUBLIC_URL ? new URL(process.env.MINIO_PUBLIC_URL).hostname : "localhost"; const publicUrl = process.env.RUSTFS_PUBLIC_URL ? new URL(process.env.RUSTFS_PUBLIC_URL) : null;
const minioPort = process.env.MINIO_PUBLIC_URL ? new URL(process.env.MINIO_PUBLIC_URL).port : undefined;
const nextConfig: NextConfig = { const nextConfig: NextConfig = {
images: { images: {
remotePatterns: [ remotePatterns: publicUrl
{ ? [
hostname: minioHost, {
...(minioPort ? { port: minioPort } : {}), protocol: publicUrl.protocol === "https:" ? "https" : "http",
}, hostname: publicUrl.hostname,
], ...(publicUrl.port ? { port: publicUrl.port } : {}),
pathname: `/${process.env.RUSTFS_BUCKET ?? "uploads"}/**`,
},
]
: [],
}, },
experimental: { experimental: {
serverActions: { serverActions: {
bodySizeLimit: "5mb", bodySizeLimit: "6mb",
}, },
}, },
output: "standalone",
}; };
export default nextConfig; export default nextConfig;
+34 -25
View File
@@ -9,39 +9,41 @@
"lint": "eslint" "lint": "eslint"
}, },
"dependencies": { "dependencies": {
"@aws-sdk/client-s3": "^3.1169.0",
"@aws-sdk/s3-request-presigner": "^3.1169.0",
"@imgly/background-removal": "^1.7.0", "@imgly/background-removal": "^1.7.0",
"@prisma/adapter-pg": "^7.8.0", "@prisma/adapter-pg": "^7.10.1",
"@prisma/client": "^7.8.0", "@prisma/client": "^7.10.1",
"@tanstack/react-table": "^8.21.3", "@tanstack/react-table": "^8.21.3",
"class-variance-authority": "^0.7.1", "class-variance-authority": "^0.7.1",
"clsx": "^2.1.1", "clsx": "^2.1.1",
"jose": "^6.2.3", "jose": "^6.2.17",
"lucide-react": "^1.20.0", "lucide-react": "^1.73.0",
"minio": "^8.0.7", "next": "16.4.6",
"next": "16.2.9", "pg": "^8.23.1",
"pg": "^8.21.0", "radix-ui": "^1.8.1",
"radix-ui": "^1.6.0",
"react": "19.2.4", "react": "19.2.4",
"react-dom": "19.2.4", "react-dom": "19.2.4",
"shadcn": "^4.11.0", "server-only": "^0.0.1",
"sharp": "^0.35.3", "sharp": "^0.35.5",
"sonner": "^2.0.7", "sonner": "^2.0.8",
"tailwind-merge": "^3.6.0", "tailwind-merge": "^3.7.0",
"tw-animate-css": "^1.4.0", "tw-animate-css": "^1.4.0",
"uuid": "^14.0.0", "uuid": "^14.0.3",
"zod": "^4.4.3" "zod": "^4.6.7"
}, },
"devDependencies": { "devDependencies": {
"@tailwindcss/postcss": "^4", "@tailwindcss/postcss": "^4.3.5",
"@types/node": "^20", "@types/node": "^20.19.43",
"@types/pg": "^8.20.0", "@types/pg": "^8.23.1",
"@types/react": "^19", "@types/react": "^19.3.0",
"@types/react-dom": "^19", "@types/react-dom": "^19.3.0",
"eslint": "^9", "eslint": "^9.39.5",
"eslint-config-next": "16.2.9", "eslint-config-next": "16.4.6",
"prisma": "^7.8.0", "prisma": "^7.10.1",
"tailwindcss": "^4", "shadcn": "^4.23.0",
"typescript": "^5" "tailwindcss": "^4.3.5",
"typescript": "^5.9.3"
}, },
"ignoreScripts": [ "ignoreScripts": [
"sharp", "sharp",
@@ -54,5 +56,12 @@
"protobufjs", "protobufjs",
"sharp", "sharp",
"unrs-resolver" "unrs-resolver"
] ],
"overrides": {
"fast-xml-parser": "^5.10.1",
"source-map-js": "^1.2.2",
"baseline-browser-mapping": "^2.11.0",
"fast-uri": "^3.1.6",
"zod": "^4.6.7"
}
} }