From 58ec75c94870615ec6c83926771709c62b6ab335 Mon Sep 17 00:00:00 2001 From: Ivan Rezchikov Date: Tue, 23 Jun 2026 15:32:52 +0300 Subject: [PATCH] feat: account --- app/[type]/[slug]/edit/client.tsx | 2 +- app/[type]/[slug]/page.tsx | 4 +- app/account/deleteDialog.tsx | 44 ++++++++++++++++ app/account/logoutButton.tsx | 20 +++++++ app/account/page.tsx | 87 +++++++++++++++++++++++++++++++ app/actions/delete.tsx | 9 ++++ app/api/callback/route.ts | 2 +- app/create/client.tsx | 2 +- app/globals.css | 8 +-- app/news/page.tsx | 2 +- app/page.tsx | 18 +++---- components/editor.tsx | 4 +- components/header.tsx | 5 +- components/newsCard.tsx | 2 +- lib/pages/repository.ts | 3 +- lib/user.ts | 2 + lib/user/repository.ts | 16 ++++++ prisma/schema.prisma | 4 +- 18 files changed, 205 insertions(+), 29 deletions(-) create mode 100644 app/account/deleteDialog.tsx create mode 100644 app/account/logoutButton.tsx create mode 100644 app/account/page.tsx create mode 100644 app/actions/delete.tsx diff --git a/app/[type]/[slug]/edit/client.tsx b/app/[type]/[slug]/edit/client.tsx index 036d5de..92c550e 100644 --- a/app/[type]/[slug]/edit/client.tsx +++ b/app/[type]/[slug]/edit/client.tsx @@ -46,7 +46,7 @@ export default function EditPageClient({ page, pageType, initialBlocks = [] }: P return (
-

Edit page

+

Edit page

+ + + +

Are you absolutely sure?

+ + This action cannot be undone. This will permanently delete your account + and remove your data from our servers. + +
+ + + + + + +
+ + ); +} \ No newline at end of file diff --git a/app/account/logoutButton.tsx b/app/account/logoutButton.tsx new file mode 100644 index 0000000..2d5316a --- /dev/null +++ b/app/account/logoutButton.tsx @@ -0,0 +1,20 @@ +"use client" + +import { useTransition } from "react"; +import { Button } from "@/components/ui/button"; +import { Spinner } from "@/components/ui/spinner"; +import logout from "../actions/logout"; + +export function LogoutButton() { + const [isPending, startTransition] = useTransition(); + + return ( + + ); +} \ No newline at end of file diff --git a/app/account/page.tsx b/app/account/page.tsx new file mode 100644 index 0000000..bb754d9 --- /dev/null +++ b/app/account/page.tsx @@ -0,0 +1,87 @@ +import Footer from "@/components/footer"; +import Header from "@/components/header"; +import { Button } from "@/components/ui/button"; +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 "./deleteDialog"; +import { LogoutButton } from "./logoutButton"; + +function ProfileField({ label, value }: { label: string; value: string }) { + return ( +
+

{label}

+

{value}

+
+ ); +} + +export default async function Account() { + const user = await getCurrentUser(); + if (!user) redirect("/"); + + return ( + <> +
+
+
+
+ +

Profile

+
+
+ +

Citizenship

+
+
+ +

Signature

+
+
+
+
+
+

Personal details

+

+ Synced from your Kotosoft ID account. To correct any details, update them there first, then click Update below. +

+
+
+ + + + + {user.isAdmin && } +
+ +
+
+

Update personal details

+

Syncs your name, email, and birthday from Kotosoft ID

+
+ +
+
+
+

Log out

+

Log out from your account on this device

+
+ +
+ +
+
+

Delete account

+

Permanently delete your account and all associated data

+
+ +
+
+
+
+