From fa41c78a398289d0d009b1bc55d6e24e9811f664 Mon Sep 17 00:00:00 2001 From: Felipe Coutinho Date: Sat, 11 Apr 2026 18:16:18 +0000 Subject: [PATCH] =?UTF-8?q?feat(navbar):=20copiar=20user=20ID=20ao=20lado?= =?UTF-8?q?=20do=20nome=20no=20menu=20do=20usu=C3=A1rio?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 4.6 --- src/app/(dashboard)/settings/page.tsx | 36 +--- .../settings/components/diagnostics-tab.tsx | 201 ------------------ src/features/settings/diagnostics-queries.ts | 96 --------- .../navigation/navbar/navbar-user.tsx | 8 +- 4 files changed, 6 insertions(+), 335 deletions(-) delete mode 100644 src/features/settings/components/diagnostics-tab.tsx delete mode 100644 src/features/settings/diagnostics-queries.ts diff --git a/src/app/(dashboard)/settings/page.tsx b/src/app/(dashboard)/settings/page.tsx index d8e8b72..55c377b 100644 --- a/src/app/(dashboard)/settings/page.tsx +++ b/src/app/(dashboard)/settings/page.tsx @@ -5,8 +5,6 @@ import { connection } from "next/server"; import { CompanionTab } from "@/features/settings/components/companion-tab"; import { DeleteAccountForm } from "@/features/settings/components/delete-account-form"; -import { DiagnosticsTab } from "@/features/settings/components/diagnostics-tab"; -import { fetchDiagnosticsData } from "@/features/settings/diagnostics-queries"; import { PasskeysForm } from "@/features/settings/components/passkeys-form"; import { PreferencesForm } from "@/features/settings/components/preferences-form"; import { UpdateEmailForm } from "@/features/settings/components/update-email-form"; @@ -39,19 +37,6 @@ export default async function Page() { const { authProvider, userPreferences, userApiTokens } = await fetchSettingsPageData(session.user.id); - const diagnosticsData = await fetchDiagnosticsData( - session.user.id, - { - id: session.user.id, - name: session.user.name ?? "", - email: session.user.email ?? "", - }, - { - createdAt: session.session.createdAt, - expiresAt: session.session.expiresAt, - }, - ); - return (
@@ -65,8 +50,7 @@ export default async function Page() { Alterar senha Passkeys Alterar e-mail - Diagnóstico - + Deletar conta @@ -196,23 +180,7 @@ export default async function Page() { - - -
-
-

Diagnóstico

-

- Informações técnicas sobre sua conta, sessão e estado do - servidor. Nenhuma credencial ou dado sensível é exibido. -

-
- - -
-
-
- - +
diff --git a/src/features/settings/components/diagnostics-tab.tsx b/src/features/settings/components/diagnostics-tab.tsx deleted file mode 100644 index d62a4d9..0000000 --- a/src/features/settings/components/diagnostics-tab.tsx +++ /dev/null @@ -1,201 +0,0 @@ -"use client"; - -import { - RiCheckLine, - RiCloseCircleLine, - RiFileCopyLine, - RiWifiLine, -} from "@remixicon/react"; -import { useState } from "react"; -import { Badge } from "@/shared/components/ui/badge"; -import { Separator } from "@/shared/components/ui/separator"; -import { - Tooltip, - TooltipContent, - TooltipTrigger, -} from "@/shared/components/ui/tooltip"; -import type { DiagnosticsData } from "../diagnostics-queries"; - -function CopyButton({ value }: { value: string }) { - const [copied, setCopied] = useState(false); - - function handleCopy() { - navigator.clipboard.writeText(value); - setCopied(true); - setTimeout(() => setCopied(false), 2000); - } - - return ( - - - - - {copied ? "Copiado!" : "Copiar"} - - ); -} - -function Row({ - label, - children, -}: { - label: string; - children: React.ReactNode; -}) { - return ( -
- {label} - - {children} - -
- ); -} - -function Section({ - title, - children, -}: { - title: string; - children: React.ReactNode; -}) { - return ( -
-

- {title} -

-
{children}
-
- ); -} - -function StatusBadge({ ok, labelOk = "Configurado", labelFail = "Não configurado" }: { ok: boolean; labelOk?: string; labelFail?: string }) { - return ok ? ( - - - {labelOk} - - ) : ( - - - {labelFail} - - ); -} - -function formatDate(date: Date) { - return new Intl.DateTimeFormat("pt-BR", { - dateStyle: "short", - timeStyle: "short", - }).format(new Date(date)); -} - -export function DiagnosticsTab({ data }: { data: DiagnosticsData }) { - return ( -
-
- - {data.identity.userId} - - - {data.identity.name} - {data.identity.email} -
- - - -
- {formatDate(data.session.createdAt)} - {formatDate(data.session.expiresAt)} -
- - - -
- - v{data.app.version} - - - - {data.app.nodeEnv} - - - {data.app.buildSha && ( - - {data.app.buildSha.slice(0, 8)} - - - )} -
- - - -
- - - - - - - - {data.server.publicDomain ? ( - {data.server.publicDomain} - ) : ( - Não definido - )} - -
- - - -
- - {data.health.db === "ok" ? ( - - - Online - {data.health.dbLatencyMs !== null && ( - - · {data.health.dbLatencyMs}ms - - )} - - ) : ( - - - Erro - - )} - -
- - - -
- - {data.usage.transactions.toLocaleString("pt-BR")} - - - {data.usage.attachments.toLocaleString("pt-BR")} - - - {data.usage.notes.toLocaleString("pt-BR")} - - - {data.usage.inboxItems.toLocaleString("pt-BR")} - -
-
- ); -} diff --git a/src/features/settings/diagnostics-queries.ts b/src/features/settings/diagnostics-queries.ts deleted file mode 100644 index 3faa0a5..0000000 --- a/src/features/settings/diagnostics-queries.ts +++ /dev/null @@ -1,96 +0,0 @@ -import { count, eq } from "drizzle-orm"; -import { - attachments, - inboxItems, - notes, - transactions, -} from "@/db/schema"; -import { db } from "@/shared/lib/db"; - -export type DiagnosticsData = { - identity: { - userId: string; - name: string; - email: string; - }; - session: { - createdAt: Date; - expiresAt: Date; - }; - app: { - version: string; - nodeEnv: string; - buildSha: string | null; - }; - server: { - s3Configured: boolean; - emailConfigured: boolean; - publicDomain: string | null; - }; - health: { - db: "ok" | "error"; - dbLatencyMs: number | null; - }; - usage: { - transactions: number; - attachments: number; - notes: number; - inboxItems: number; - }; -}; - -export async function fetchDiagnosticsData( - userId: string, - user: { id: string; name: string; email: string }, - session: { createdAt: Date; expiresAt: Date }, -): Promise { - const dbStart = Date.now(); - let dbStatus: "ok" | "error" = "ok"; - let dbLatencyMs: number | null = null; - - try { - await db.execute("SELECT 1"); - dbLatencyMs = Date.now() - dbStart; - } catch { - dbStatus = "error"; - } - - const [txCount, attachCount, notesCount, inboxCount] = await Promise.all([ - db.select({ value: count() }).from(transactions).where(eq(transactions.userId, userId)), - db.select({ value: count() }).from(attachments).where(eq(attachments.userId, userId)), - db.select({ value: count() }).from(notes).where(eq(notes.userId, userId)), - db.select({ value: count() }).from(inboxItems).where(eq(inboxItems.userId, userId)), - ]); - - return { - identity: { - userId: user.id, - name: user.name, - email: user.email, - }, - session: { - createdAt: session.createdAt, - expiresAt: session.expiresAt, - }, - app: { - version: process.env.npm_package_version ?? "—", - nodeEnv: process.env.NODE_ENV ?? "—", - buildSha: process.env.BUILD_SHA ?? null, - }, - server: { - s3Configured: !!(process.env.S3_ENDPOINT && process.env.S3_ACCESS_KEY_ID), - emailConfigured: !!process.env.RESEND_FROM_EMAIL, - publicDomain: process.env.PUBLIC_DOMAIN ?? null, - }, - health: { - db: dbStatus, - dbLatencyMs, - }, - usage: { - transactions: txCount[0]?.value ?? 0, - attachments: attachCount[0]?.value ?? 0, - notes: notesCount[0]?.value ?? 0, - inboxItems: inboxCount[0]?.value ?? 0, - }, - }; -} diff --git a/src/shared/components/navigation/navbar/navbar-user.tsx b/src/shared/components/navigation/navbar/navbar-user.tsx index 47cfd1d..fe1743c 100644 --- a/src/shared/components/navigation/navbar/navbar-user.tsx +++ b/src/shared/components/navigation/navbar/navbar-user.tsx @@ -119,11 +119,8 @@ export function NavbarUser({ />
- {user.name}
- - {user.email} - + {user.name}
+ + {user.email} +