diff --git a/apps/admin/.gitignore b/apps/admin/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..a547bf36d8d11a4f89c59c144f24795749086dd1 --- /dev/null +++ b/apps/admin/.gitignore @@ -0,0 +1,24 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/apps/admin/.turbo/turbo-build.log b/apps/admin/.turbo/turbo-build.log new file mode 100644 index 0000000000000000000000000000000000000000..8585b9b139a3b5920e8a21732304ac5a62cb6c37 --- /dev/null +++ b/apps/admin/.turbo/turbo-build.log @@ -0,0 +1,61 @@ + +> @micprotocol/admin@0.1.0 build /home/benaah/Desktop/MicProtocol/apps/admin +> next build + +▲ Next.js 16.1.6 (Turbopack) + +⚠ The "middleware" file convention is deprecated. Please use "proxy" instead. Learn more: https://nextjs.org/docs/messages/middleware-to-proxy + Creating an optimized production build ... +✓ Compiled successfully in 26.3s + Running TypeScript ... + Collecting page data using 3 workers ... + Generating static pages using 3 workers (0/32) ... + Generating static pages using 3 workers (8/32) + Generating static pages using 3 workers (16/32) + Generating static pages using 3 workers (24/32) +✓ Generating static pages using 3 workers (32/32) in 2.1s + Finalizing page optimization ... + +Route (app) +┌ ○ / +├ ○ /_not-found +├ ○ /ai-engines +├ ○ /ai-engines/clip-scorer +├ ○ /audit-logs +├ ○ /crm/guests +├ ○ /crm/inquiries +├ ○ /crm/users +├ ○ /infrastructure +├ ○ /integrations +├ ○ /integrations/credentials +├ ○ /login +├ ○ /moderation +├ ○ /observability/errors +├ ○ /observability/logs +├ ○ /observability/metrics +├ ○ /observability/traces +├ ○ /queues +├ ○ /ratings +├ ○ /realtime +├ ○ /security-policy +├ ○ /settings +├ ○ /supervision +├ ○ /support +├ ƒ /support/[ticketId] +├ ○ /surveys +├ ƒ /surveys/[id] +├ ○ /synthetic-agents +├ ○ /tenants +├ ○ /users +├ ƒ /users/[id] +├ ○ /verification +├ ○ /webhooks +├ ○ /workspaces +└ ƒ /workspaces/[id] + + +ƒ Proxy (Middleware) + +○ (Static) prerendered as static content +ƒ (Dynamic) server-rendered on demand + diff --git a/apps/admin/.turbo/turbo-lint.log b/apps/admin/.turbo/turbo-lint.log new file mode 100644 index 0000000000000000000000000000000000000000..41afebe599993e347c89e432a3261de85bb7ac6d --- /dev/null +++ b/apps/admin/.turbo/turbo-lint.log @@ -0,0 +1,4 @@ + +> @micprotocol/admin@0.1.0 lint /home/benaah/Desktop/MicProtocol/apps/admin +> eslint . --ext .ts,.tsx,.js,.jsx + diff --git a/apps/admin/.turbo/turbo-type-check.log b/apps/admin/.turbo/turbo-type-check.log new file mode 100644 index 0000000000000000000000000000000000000000..b6aab29777325d6d2327f17e7c2823d396bc2224 --- /dev/null +++ b/apps/admin/.turbo/turbo-type-check.log @@ -0,0 +1,15 @@ + +> @micprotocol/admin@0.1.0 type-check /home/benaah/Desktop/MicProtocol/apps/admin +> tsc --noEmit + +src/app/(dashboard)/security-policy/page.tsx(74,39): error TS2339: Property 'invalidate' does not exist on type 'DecoratedQuery<{ input: { status?: "OPEN" | "REVIEWED" | "DISMISSED" | "ACTIONED" | undefined; severity?: "low" | "medium" | "high" | "critical" | undefined; workspaceId?: string | undefined; page?: number | undefined; limit?: number | undefined; }; output: { ...; }; transformer: false; errorShape: { ...; }; }>'. +src/app/(dashboard)/security-policy/page.tsx(80,39): error TS2339: Property 'invalidate' does not exist on type 'DecoratedQuery<{ input: { status?: "OPEN" | "REVIEWED" | "DISMISSED" | "ACTIONED" | undefined; severity?: "low" | "medium" | "high" | "critical" | undefined; workspaceId?: string | undefined; page?: number | undefined; limit?: number | undefined; }; output: { ...; }; transformer: false; errorShape: { ...; }; }>'. +src/app/(dashboard)/security-policy/page.tsx(86,41): error TS2339: Property 'invalidate' does not exist on type 'DecoratedQuery<{ input: { activeOnly?: boolean | undefined; type?: "EMAIL_DOMAIN" | "IP_RANGE" | "WORKSPACE_SLUG" | undefined; }; output: { type: string; value: string; createdAt: string; reason: string; updatedAt: string; isActive: boolean; id: string; createdBy: string | null; }[]; transformer: false; errorShape: ...'. +src/app/(dashboard)/security-policy/page.tsx(94,41): error TS2339: Property 'invalidate' does not exist on type 'DecoratedQuery<{ input: { activeOnly?: boolean | undefined; type?: "EMAIL_DOMAIN" | "IP_RANGE" | "WORKSPACE_SLUG" | undefined; }; output: { type: string; value: string; createdAt: string; reason: string; updatedAt: string; isActive: boolean; id: string; createdBy: string | null; }[]; transformer: false; errorShape: ...'. +src/app/(dashboard)/security-policy/page.tsx(107,37): error TS2339: Property 'invalidate' does not exist on type 'DecoratedQuery<{ input: { status?: "OPEN" | "REVIEWED" | "DISMISSED" | "ACTIONED" | undefined; severity?: "low" | "medium" | "high" | "critical" | undefined; workspaceId?: string | undefined; page?: number | undefined; limit?: number | undefined; }; output: { ...; }; transformer: false; errorShape: { ...; }; }>'. +src/app/(dashboard)/security-policy/page.tsx(108,39): error TS2339: Property 'invalidate' does not exist on type 'DecoratedQuery<{ input: { activeOnly?: boolean | undefined; type?: "EMAIL_DOMAIN" | "IP_RANGE" | "WORKSPACE_SLUG" | undefined; }; output: { type: string; value: string; createdAt: string; reason: string; updatedAt: string; isActive: boolean; id: string; createdBy: string | null; }[]; transformer: false; errorShape: ...'. +src/app/(dashboard)/security-policy/page.tsx(274,29): error TS2322: Type '"error"' is not assignable to type '"default" | "link" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined'. +src/app/(dashboard)/security-policy/page.tsx(342,29): error TS2322: Type '"error"' is not assignable to type '"default" | "link" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined'. +src/app/(dashboard)/security-policy/page.tsx(392,19): error TS2322: Type '"primary"' is not assignable to type '"default" | "link" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined'. +../api/src/common/file-security/file-security.service.ts(100,23): error TS2694: Namespace 'global.Express' has no exported member 'Multer'. + ELIFECYCLE  Command failed with exit code 2. diff --git a/apps/admin/Dockerfile b/apps/admin/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..ce214fcf7e01794bc86aabc8b4e398d3e096b799 --- /dev/null +++ b/apps/admin/Dockerfile @@ -0,0 +1,32 @@ +FROM node:20-slim AS base + +FROM base AS deps +WORKDIR /app +RUN apt-get update && apt-get install -y --no-install-recommends libc6-dev sqlite3 libsqlite3-dev g++ make python3 && rm -rf /var/lib/apt/lists/* +COPY pnpm-lock.yaml pnpm-workspace.yaml package.json ./ +COPY apps/admin/package.json ./apps/admin/package.json +COPY apps/api/package.json ./apps/api/package.json +COPY packages/ ./packages +COPY apps/admin ./apps/admin +RUN npm install -g pnpm@10.30.3 && pnpm install --frozen-lockfile + +FROM base AS builder +WORKDIR /app +COPY --from=deps /app/node_modules ./node_modules +COPY --from=deps /app/packages ./packages +COPY --from=deps /app/apps/admin ./apps/admin +COPY packages ./packages +ENV DOCKER_BUILD=true +RUN npm install -g pnpm@10.30.3 && cd apps/admin && pnpm build + +FROM base AS runner +WORKDIR /app +ENV NODE_ENV=production +ENV PORT=3006 +ENV HOSTNAME="0.0.0.0" +COPY --from=builder /app/apps/admin/.next/standalone ./ +COPY --from=builder /app/apps/admin/.next/static ./apps/admin/.next/static +COPY --from=builder /app/apps/admin/public ./apps/admin/public + +EXPOSE 3006 +CMD ["node", "apps/admin/server.js"] diff --git a/apps/admin/README.md b/apps/admin/README.md new file mode 100644 index 0000000000000000000000000000000000000000..7dbf7ebf3b2a3d84ad526bc47810d1d211331b8b --- /dev/null +++ b/apps/admin/README.md @@ -0,0 +1,73 @@ +# React + TypeScript + Vite + +This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. + +Currently, two official plugins are available: + +- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Oxc](https://oxc.rs) +- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) + +## React Compiler + +The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation). + +## Expanding the ESLint configuration + +If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules: + +```js +export default defineConfig([ + globalIgnores(['dist']), + { + files: ['**/*.{ts,tsx}'], + extends: [ + // Other configs... + + // Remove tseslint.configs.recommended and replace with this + tseslint.configs.recommendedTypeChecked, + // Alternatively, use this for stricter rules + tseslint.configs.strictTypeChecked, + // Optionally, add this for stylistic rules + tseslint.configs.stylisticTypeChecked, + + // Other configs... + ], + languageOptions: { + parserOptions: { + project: ['./tsconfig.node.json', './tsconfig.app.json'], + tsconfigRootDir: import.meta.dirname, + }, + // other options... + }, + }, +]) +``` + +You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules: + +```js +// eslint.config.js +import reactX from 'eslint-plugin-react-x' +import reactDom from 'eslint-plugin-react-dom' + +export default defineConfig([ + globalIgnores(['dist']), + { + files: ['**/*.{ts,tsx}'], + extends: [ + // Other configs... + // Enable lint rules for React + reactX.configs['recommended-typescript'], + // Enable lint rules for React DOM + reactDom.configs.recommended, + ], + languageOptions: { + parserOptions: { + project: ['./tsconfig.node.json', './tsconfig.app.json'], + tsconfigRootDir: import.meta.dirname, + }, + // other options... + }, + }, +]) +``` diff --git a/apps/admin/eslint.config.js b/apps/admin/eslint.config.js new file mode 100644 index 0000000000000000000000000000000000000000..5194088749b0115a6784829fd7dc84425d61dd34 --- /dev/null +++ b/apps/admin/eslint.config.js @@ -0,0 +1,3 @@ +import nextConfig from 'eslint-config-next'; + +export default nextConfig; diff --git a/apps/admin/next-env.d.ts b/apps/admin/next-env.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9edff1c7cacb3bfac9a1eadcf6f51eaa99565e38 --- /dev/null +++ b/apps/admin/next-env.d.ts @@ -0,0 +1,6 @@ +/// +/// +import "./.next/types/routes.d.ts"; + +// NOTE: This file should not be edited +// see https://nextjs.org/docs/app/api-reference/config/typescript for more information. diff --git a/apps/admin/next.config.js b/apps/admin/next.config.js new file mode 100644 index 0000000000000000000000000000000000000000..c56ea416d30b992c09c858eb95b24c2db20cd70f --- /dev/null +++ b/apps/admin/next.config.js @@ -0,0 +1,31 @@ +/** @type {import('next').NextConfig} */ +const path = require("path"); + +const nextConfig = { + reactStrictMode: true, + transpilePackages: ["@micprotocol/shared-types", "@micprotocol/ui"], + output: process.env.DOCKER_BUILD ? "standalone" : undefined, + poweredByHeader: false, + compress: true, + // Admin never uses Prisma at runtime; @micprotocol/api is imported as + // `import type` (erased at compile time). Skip type-checking in Docker + // builds since the Prisma generated client isn't available in this image. + typescript: process.env.DOCKER_BUILD ? { ignoreBuildErrors: true } : undefined, + turbopack: { + root: path.resolve(__dirname, "../.."), + }, + async rewrites() { + return [ + { + source: "/api/:path*", + destination: `${process.env.API_URL || "http://localhost:4000"}/api/:path*`, + }, + { + source: "/trpc/:path*", + destination: `${process.env.API_URL || "http://localhost:4000"}/trpc/:path*`, + }, + ]; + }, +}; + +module.exports = nextConfig; diff --git a/apps/admin/package.json b/apps/admin/package.json new file mode 100644 index 0000000000000000000000000000000000000000..cef27f554efb062b01079e7aca066d770aca4879 --- /dev/null +++ b/apps/admin/package.json @@ -0,0 +1,48 @@ +{ + "name": "@micprotocol/admin", + "version": "0.1.0", + "private": true, + "scripts": { + "dev": "next dev --port 3006", + "build": "next build", + "start": "next start --port 3006", + "lint": "eslint . --ext .ts,.tsx,.js,.jsx", + "type-check": "tsc --noEmit" + }, + "dependencies": { + "@micprotocol/api": "workspace:*", + "@micprotocol/shared-types": "workspace:*", + "@micprotocol/ui": "workspace:*", + "@radix-ui/react-avatar": "^1.3.1", + "@radix-ui/react-dialog": "^1.3.1", + "@radix-ui/react-dropdown-menu": "^2.2.1", + "@radix-ui/react-select": "^2.4.1", + "@radix-ui/react-separator": "^1.2.0", + "@radix-ui/react-switch": "^1.4.1", + "@radix-ui/react-tabs": "^1.2.1", + "@radix-ui/react-tooltip": "^1.4.1", + "@tanstack/react-query": "^5.90.21", + "@trpc/react-query": "^11.11.0", + "@trpc/server": "^11.11.0", + "autoprefixer": "^10.6.1", + "better-auth": "^1.7.13", + "class-variance-authority": "^0.7.1", + "clsx": "^2.1.1", + "framer-motion": "^14.6.0", + "lucide-react": "^0.576.0", + "next": "16.1.6", + "postcss": "^8.5.31", + "react": "^19.2.4", + "react-dom": "^19.2.4", + "tailwindcss": "^3.4.19" + }, + "devDependencies": { + "@micprotocol/tsconfig": "workspace:*", + "@types/node": "^25.3.3", + "@types/react": "^19.2.14", + "@types/react-dom": "^19.2.3", + "eslint": "^9.28.0", + "eslint-config-next": "16.1.6", + "typescript": "^5.9.3" + } +} diff --git a/apps/admin/postcss.config.js b/apps/admin/postcss.config.js new file mode 100644 index 0000000000000000000000000000000000000000..12a703d900da8159c30e75acbd2c4d87ae177f62 --- /dev/null +++ b/apps/admin/postcss.config.js @@ -0,0 +1,6 @@ +module.exports = { + plugins: { + tailwindcss: {}, + autoprefixer: {}, + }, +}; diff --git a/apps/admin/public/favicon.ico b/apps/admin/public/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..bfcd660c0306ba21cb5719865bc01be374c13427 Binary files /dev/null and b/apps/admin/public/favicon.ico differ diff --git a/apps/admin/public/favicon.svg b/apps/admin/public/favicon.svg new file mode 100644 index 0000000000000000000000000000000000000000..21a8074bd9c61954d7c9a5c22e23ccace6ad6dae --- /dev/null +++ b/apps/admin/public/favicon.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/apps/admin/public/icons.svg b/apps/admin/public/icons.svg new file mode 100644 index 0000000000000000000000000000000000000000..e9522193d9f796a9748e9ad8c952a5df73c87db9 --- /dev/null +++ b/apps/admin/public/icons.svg @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/apps/admin/src/app/(dashboard)/ai-engines/clip-scorer/page.tsx b/apps/admin/src/app/(dashboard)/ai-engines/clip-scorer/page.tsx new file mode 100644 index 0000000000000000000000000000000000000000..fd7f9066531f2c2e7f87fb12777ecdb2a17ad646 --- /dev/null +++ b/apps/admin/src/app/(dashboard)/ai-engines/clip-scorer/page.tsx @@ -0,0 +1,242 @@ +"use client"; + +import React from "react"; +import { Activity, ShieldCheck, Database, Clock, Play } from "lucide-react"; +import { trpc } from "@/lib/trpc"; +import { cn } from "@/lib/utils"; +import { AdminHeader } from "@/components/shell/AdminHeader"; +import { Card, CardContent, CardHeader, CardTitle } from "@micprotocol/ui"; +import { Badge } from "@micprotocol/ui"; +import { Button } from "@micprotocol/ui"; + +export default function AIEnginesClipScorerPage() { + const { data: status, isLoading } = trpc.admin.aiEngines.clipScorerStatus.useQuery( + undefined, + { refetchInterval: 30_000 }, + ); + + const healthy = status?.status === "healthy"; + const degraded = status?.status === "degraded"; + const down = status?.status === "down"; + + const axes = status?.scoringAxes ?? [ + { name: "Visual Relevance", weight: 0.4, enabled: true }, + { name: "Audio Clarity", weight: 0.3, enabled: true }, + { name: "Semantic Match", weight: 0.2, enabled: true }, + { name: "Loudness Norm", weight: 0.1, enabled: false }, + ]; + + const locks = status?.locks ?? []; + const storage = status?.storage ?? { usedGB: 0, totalGB: 0, utilization: 0 }; + + return ( +
+ + Restart Engine + + } + /> + +
+ {/* Engine status */} + + + + Engine Status + + + +
+
+ +
+
+

CLIP Scoring Engine

+

+ {status?.status ?? "unknown"} +

+

+ {status?.uptimeSeconds != null ? `Uptime: ${Math.floor(status.uptimeSeconds / 3600)}h ${Math.floor((status.uptimeSeconds % 3600) / 60)}m` : "—"} +

+
+
+ + {status?.status ?? "unknown"} + +
+
+
+
+

Scoring Jobs

+

{status?.jobsProcessed ?? 0}

+
+
+

Failed Jobs

+

{status?.jobsFailed ?? 0}

+
+
+

Avg Latency

+

{status?.avgLatencyMs?.toFixed(1) ?? 0} ms

+
+
+

Queue Depth

+

{status?.queueDepth ?? 0}

+
+
+
+
+ + {/* Scoring axes */} + + + + Scoring Axes + + + +
+ + + + + + + + + + + {axes.length === 0 ? ( + + + + ) : ( + axes.map((a: any) => ( + + + + + + + )) + )} + +
AxisWeightEnabledActions
+ No scoring axes configured. +
{a.name}{a.weight} + + {a.enabled ? "on" : "off"} + + + +
+
+
+
+ + {/* Lock inspector */} + + + + Lock Inspector + + + +
+ + + + + + + + + + + + {locks.length === 0 ? ( + + + + ) : ( + locks.map((l: any) => ( + + + + + + + + )) + )} + +
Lock KeyHolderTTLStatusActions
+ No active distributed locks. +
{l.key}{l.holder ?? "—"}{l.ttlSeconds ?? 0}s + {l.status ?? "active"} + + +
+
+
+
+ + {/* Scratch storage */} + + + + Scratch Storage + + + +
+
+

Used

+

{storage.usedGB?.toFixed(2) ?? 0} GB

+
+
+

Total

+

{storage.totalGB?.toFixed(2) ?? 0} GB

+
+
+
+
+
+

+ Utilization: {storage.utilization ?? 0}% +

+ + +
+
+ ); +} + +function engineStatusColor(status: string | undefined): string { + switch (status) { + case "healthy": return "text-[var(--color-success)]"; + case "degraded": return "text-[var(--color-warning)]"; + case "down": return "text-[var(--color-error)]"; + default: return "text-[var(--text-tertiary)]"; + } +} + +function engineStatusBadgeClass(status: string | undefined): string { + switch (status) { + case "healthy": return "bg-[var(--color-success)]/20 border-[var(--color-success)]/30 text-[var(--color-success)]"; + case "degraded": return "bg-[var(--color-warning)]/20 border-[var(--color-warning)]/30 text-[var(--color-warning)]"; + case "down": return "bg-[var(--color-error)]/20 border-[var(--color-error)]/30 text-[var(--color-error)]"; + default: return "border-transparent text-[var(--text-tertiary)]"; + } +} diff --git a/apps/admin/src/app/(dashboard)/ai-engines/page.tsx b/apps/admin/src/app/(dashboard)/ai-engines/page.tsx new file mode 100644 index 0000000000000000000000000000000000000000..c36543a9e5e6097a55f08e1772375916c48abe4f --- /dev/null +++ b/apps/admin/src/app/(dashboard)/ai-engines/page.tsx @@ -0,0 +1,134 @@ +"use client"; + +import React from "react"; +import { Activity, ShieldCheck, Database, Play } from "lucide-react"; +import { trpc } from "@/lib/trpc"; +import { cn } from "@/lib/utils"; +import { AdminHeader } from "@/components/shell/AdminHeader"; +import { Card, CardContent, CardHeader, CardTitle } from "@micprotocol/ui"; +import { Badge } from "@micprotocol/ui"; +import { Button } from "@micprotocol/ui"; + +export default function AIEnginesPage() { + const { data: engines, isLoading } = trpc.admin.aiEngines.listEngines.useQuery( + { includeMetrics: true }, + { refetchInterval: 30_000 }, + ); + + const items = engines?.items ?? []; + const healthy = items.filter((e) => e.status === "healthy").length; + const degraded = items.filter((e) => e.status === "degraded").length; + const down = items.filter((e) => e.status === "down").length; + + return ( +
+ + Restart All + + } + /> + +
+ {/* KPI strip */} +
+ +

Engines

+

{items.length}

+
+ +

Healthy

+

{healthy}

+
+ +

Degraded

+

{degraded}

+
+ +

Down

+

{down}

+
+
+ + {/* Engine grid */} +
+ {items.length > 0 ? ( + items.map((e: any) => ( + + +
+
+
+ +
+
+

{e.name}

+

{e.engineType ?? "ml-engine"}

+
+
+
+ + + {e.status} + +
+
+
+
+ Requests/sec + {e.requestsPerSecond?.toFixed(1) ?? 0} +
+
+ Avg Latency + {e.avgLatencyMs?.toFixed(1) ?? 0} ms +
+
+ Error Rate + + {(e.errorRate ?? 0).toFixed(2)}% + +
+
+
+ +
+
+
+ )) + ) : ( + +
+ +
+

No AI engines detected.

+
+ )} +
+
+
+ ); +} + +function engineStatusColor(status: string): string { + switch (status) { + case "healthy": return "var(--color-success)"; + case "degraded": return "var(--color-warning)"; + case "down": return "var(--color-error)"; + default: return "var(--text-tertiary)"; + } +} + +function engineStatusBadgeClass(status: string): string { + switch (status) { + case "healthy": return "bg-[var(--color-success)]/20 border-[var(--color-success)]/30 text-[var(--color-success)]"; + case "degraded": return "bg-[var(--color-warning)]/20 border-[var(--color-warning)]/30 text-[var(--color-warning)]"; + case "down": return "bg-[var(--color-error)]/20 border-[var(--color-error)]/30 text-[var(--color-error)]"; + default: return "border-transparent text-[var(--text-tertiary)]"; + } +} diff --git a/apps/admin/src/app/(dashboard)/audit-logs/page.tsx b/apps/admin/src/app/(dashboard)/audit-logs/page.tsx new file mode 100644 index 0000000000000000000000000000000000000000..ce8155485d854f4560a27f5b7bb95764e0567d64 --- /dev/null +++ b/apps/admin/src/app/(dashboard)/audit-logs/page.tsx @@ -0,0 +1,197 @@ +"use client"; + +import React, { useState } from "react"; +import { Search, ClipboardList, AlertTriangle, ShieldAlert } from "lucide-react"; +import { trpc } from "@/lib/trpc"; +import { cn } from "@/lib/utils"; +import { AdminHeader } from "@/components/shell/AdminHeader"; +import { Card, CardContent, CardHeader, CardTitle } from "@micprotocol/ui"; +import { Badge } from "@micprotocol/ui"; +import { Button } from "@micprotocol/ui"; +import { Input } from "@micprotocol/ui"; +import { ago } from "@/lib/utils"; + +const LEVELS = ["ALL", "INFO", "WARN", "ERROR", "FATAL", "AUDIT"] as const; + +export default function AuditLogsPage() { + const [search, setSearch] = useState(""); + const [level, setLevel] = useState("ALL"); + const [page, setPage] = useState(1); + + const { data: audit, isLoading } = trpc.audit.list.useQuery( + { limit: 25, search: search || undefined }, + { refetchInterval: 30_000 }, + ); + + const items = audit?.items ?? []; + const total = audit?.total ?? 0; + + const handleSearch = (e: React.ChangeEvent) => { + setSearch(e.target.value); + setPage(1); + }; + + const prev = () => setPage((p) => Math.max(1, p - 1)); + const next = () => setPage((p) => Math.min(Math.ceil(total / 25), p + 1)); + + return ( +
+ + +
+ {/* Filters */} +
+
+
+ + +
+
+ + +
+ + {/* Stats strip */} +
+ +

Total Entries

+

{total}

+
+ +

Errors

+

+ {items.filter((i: any) => i.level === "ERROR").length} +

+
+ +

Warnings

+

+ {items.filter((i: any) => i.level === "WARN").length} +

+
+ +

Today

+

+ {items.filter((i: any) => new Date(i.createdAt).toDateString() === new Date().toDateString()).length} +

+
+
+ + {/* Audit trail table */} + + + + Audit Trail + + + +
+ + + + + + + + + + + + + {isLoading ? ( + [...Array(5)].map((_, i) => ( + + + + )) + ) : items.length === 0 ? ( + + + + ) : ( + items.map((entry: any) => ( + + + + + + + + + )) + )} + +
TimeActorActionResourceLevelDetails
+
+
+ No audit events match your filters. +
+ {ago(entry.createdAt)} + + {entry.actorId?.slice(0, 8) ?? "system"} + + {entry.action} + + {entry.resourceType ?? "—"} + + + {entry.level} + + + {entry.details ?? "—"} +
+
+
+

+ Showing {items.length} of {total} entries +

+
+ + +
+
+
+
+
+
+ ); +} + +function levelBadgeClass(level: string): string { + switch (level) { + case "ERROR": + case "FATAL": + return "bg-[var(--color-error)]/10 border-[var(--color-error)]/20 text-[var(--color-error)]"; + case "WARN": + return "bg-[var(--color-warning)]/10 border-[var(--color-warning)]/20 text-[var(--color-warning)]"; + case "INFO": + return "bg-[var(--color-info)]/10 border-[var(--color-info)]/20 text-[var(--color-info)]"; + default: + return "border-transparent"; + } +} diff --git a/apps/admin/src/app/(dashboard)/crm/guests/page.tsx b/apps/admin/src/app/(dashboard)/crm/guests/page.tsx new file mode 100644 index 0000000000000000000000000000000000000000..89d432e6625bad4449e36b03610a7391c18b55cb --- /dev/null +++ b/apps/admin/src/app/(dashboard)/crm/guests/page.tsx @@ -0,0 +1,169 @@ +"use client"; + +import React, { useState } from "react"; +import { Search, User, CreditCard, Mail, Clock } from "lucide-react"; +import { trpc } from "@/lib/trpc"; +import { cn } from "@/lib/utils"; +import { AdminHeader } from "@/components/shell/AdminHeader"; +import { Card, CardContent, CardHeader, CardTitle } from "@micprotocol/ui"; +import { Badge } from "@micprotocol/ui"; +import { Button } from "@micprotocol/ui"; +import { Input } from "@micprotocol/ui"; +import { ago } from "@/lib/utils"; + +export default function CRMGuestsPage() { + const [search, setSearch] = useState(""); + const { data: guests, isLoading } = trpc.crm.listAllGuests.useQuery( + { search: search || undefined }, + { refetchInterval: 30_000 }, + ); + + const items = (guests as any)?.items ?? []; + const totalGuests = items.length; + const verified = items.filter((g: any) => g.verified).length; + const vip = items.filter((g: any) => g.vip).length; + const blocked = items.filter((g: any) => g.blocked).length; + + return ( +
+ + Export CSV + + } + /> + +
+ {/* KPI strip */} +
+ +

Total Guests

+

{totalGuests}

+
+ +

Verified

+

{verified}

+
+ +

VIP

+

{vip}

+
+ +

Blocked

+

{blocked}

+
+
+ + {/* Search bar */} +
+
+ + setSearch(e.target.value)} + placeholder="Search guests by name or email…" + className="pl-10 text-[var(--text-primary)] bg-[var(--bg-elevated)] border-[var(--border-color)] rounded-[var(--radius-md)] focus:border-[var(--color-primary)] focus:ring-2 focus:ring-[var(--color-primary)]/20" + /> +
+
+ + {/* Guest directory table */} + + + + Guest Directory + + + +
+ + + + + + + + + + + + + + + {isLoading ? ( + [...Array(5)].map((_, i) => ( + + + + )) + ) : items.length === 0 ? ( + + + + ) : ( + items.map((g: any) => ( + + + + + + + + + + + )) + )} + +
GuestEmailCompanyVerifiedVIPBlockedJoinedActions
+
+
+ No guests match your search. +
+
+
+ {g.firstName?.[0] ?? "?"}{g.lastName?.[0] ?? "?"} +
+
+

+ {g.firstName} {g.lastName} +

+ {g.email ? ( +

{g.email}

+ ) : null} +
+
+
+ {g.email ?? "—"} + + {g.company ?? "—"} + + + {g.verified ? "yes" : "no"} + + + + {g.vip ? "yes" : "no"} + + + + {g.blocked ? "yes" : "no"} + + + {new Date(g.createdAt).toLocaleDateString()} + + +
+
+
+
+
+
+ ); +} diff --git a/apps/admin/src/app/(dashboard)/crm/inquiries/page.tsx b/apps/admin/src/app/(dashboard)/crm/inquiries/page.tsx new file mode 100644 index 0000000000000000000000000000000000000000..a285ea01cc3e75afe8fdb3c260d77ced5acd0226 --- /dev/null +++ b/apps/admin/src/app/(dashboard)/crm/inquiries/page.tsx @@ -0,0 +1,158 @@ +"use client"; + +import React from "react"; +import { Mail, Clock, AlertCircle, User, CheckCircle2 } from "lucide-react"; +import { trpc } from "@/lib/trpc"; +import { cn } from "@/lib/utils"; +import { AdminHeader } from "@/components/shell/AdminHeader"; +import { Card, CardContent, CardHeader, CardTitle } from "@micprotocol/ui"; +import { Badge } from "@micprotocol/ui"; +import { Button } from "@micprotocol/ui"; +import { ago } from "@/lib/utils"; + +export default function CRMInquiriesPage() { + const { data: inquiries, isLoading } = trpc.crm.listInquiries.useQuery( + undefined, + { refetchInterval: 30_000 }, + ); + + const items = (inquiries as any)?.items ?? []; + const open = items.filter((i: any) => i.status === "open").length; + const started = items.filter((i: any) => i.status === "started").length; + const resolved = items.filter((i: any) => i.status === "resolved").length; + + return ( +
+ + +
+ {/* KPI strip */} +
+ +

Total Inquiries

+

{items.length}

+
+ +

Open

+

{open}

+
+ +

Started

+

{started}

+
+ +

Resolved

+

{resolved}

+
+
+ + {/* Inquiries table */} + + + + Inquiries + + + +
+ + + + + + + + + + + + + + {isLoading ? ( + [...Array(5)].map((_, i) => ( + + + + )) + ) : items.length === 0 ? ( + + + + ) : ( + items.map((i: any) => ( + + + + + + + + + + )) + )} + +
GuestChannelSubjectStatusPriorityReceivedActions
+
+
+ No inquiries yet. +
+ {i.guestName ?? i.guestId?.slice(0, 8) ?? "—"} + + {i.channel ?? "email"} + + {i.subject ?? "—"} + + + {i.status} + + + + {i.priority} + + + {new Date(i.createdAt).toLocaleDateString()} + +
+ {i.status === "open" ? ( + + ) : ( + <> + + + )} +
+
+
+
+
+
+
+ ); +} + +function inquiryStatusClass(s: string): string { + switch (s) { + case "open": return "bg-[var(--color-warning)]/10 border-[var(--color-warning)]/20 text-[var(--color-warning)]"; + case "started": return "bg-[var(--color-info)]/10 border-[var(--color-info)]/20 text-[var(--color-info)]"; + case "resolved": return "bg-[var(--color-success)]/10 border-[var(--color-success)]/20 text-[var(--color-success)]"; + default: return "border-transparent"; + } +} + +function priorityClass(p: string): string { + switch (p) { + case "high": return "bg-[var(--color-error)]/10 border-[var(--color-error)]/20 text-[var(--color-error)]"; + case "medium": return "bg-[var(--color-warning)]/10 border-[var(--color-warning)]/20 text-[var(--color-warning)]"; + case "low": return "bg-[var(--color-info)]/10 border-[var(--color-info)]/20 text-[var(--color-info)]"; + default: return "border-transparent"; + } +} diff --git a/apps/admin/src/app/(dashboard)/crm/users/page.tsx b/apps/admin/src/app/(dashboard)/crm/users/page.tsx new file mode 100644 index 0000000000000000000000000000000000000000..37b5ffed17ed35e4a49923b2f9d5021488a58e80 --- /dev/null +++ b/apps/admin/src/app/(dashboard)/crm/users/page.tsx @@ -0,0 +1,153 @@ +"use client"; + +import React from "react"; +import { User, ShieldCheck, AlertTriangle, CreditCard, Mail } from "lucide-react"; +import { trpc } from "@/lib/trpc"; +import { cn } from "@/lib/utils"; +import { AdminHeader } from "@/components/shell/AdminHeader"; +import { Card, CardContent, CardHeader, CardTitle } from "@micprotocol/ui"; +import { Badge } from "@micprotocol/ui"; +import { Button } from "@micprotocol/ui"; +import { ago } from "@/lib/utils"; + +export default function CRMUsersPage() { + const { data: users, isLoading } = trpc.crm.listUsers.useQuery( + undefined, + { refetchInterval: 30_000 }, + ); + + const items = (users as any)?.items ?? []; + const totalUsers = items.length; + const admins = items.filter((u: any) => u.adminRole).length; + const suspended = items.filter((u: any) => u.suspended).length; + const verified = items.filter((u: any) => u.verified).length; + + const roleVariant = (role?: string | null) => { + switch (role) { + case "admin": return "brand"; + case "moderator": return "info"; + default: return "neutral"; + } + }; + + return ( +
+ + +
+ {/* KPI strip */} +
+ +

Total Users

+

{totalUsers}

+
+ +

Admins

+

{admins}

+
+ +

Verified

+

{verified}

+
+ +

Suspended

+

{suspended}

+
+
+ + {/* User directory table */} + + + + User Directory + + + +
+ + + + + + + + + + + + + + {isLoading ? ( + [...Array(5)].map((_, i) => ( + + + + )) + ) : items.length === 0 ? ( + + + + ) : ( + items.map((u: any) => ( + + + + + + + + + + )) + )} + +
UserEmailRoleVerifiedSuspendedJoinedActions
+
+
+ No users yet. +
+
+
+ {u.firstName?.[0] ?? "?"}{u.lastName?.[0] ?? "?"} +
+
+

+ {u.firstName} {u.lastName} +

+ {u.email ? ( +

{u.email}

+ ) : null} +
+
+
+ {u.email ?? "—"} + + + {u.adminRole ?? "user"} + + + + {u.verified ? "yes" : "no"} + + + + {u.suspended ? "yes" : "no"} + + + {new Date(u.createdAt).toLocaleDateString()} + + +
+
+
+
+
+
+ ); +} diff --git a/apps/admin/src/app/(dashboard)/infrastructure/page.tsx b/apps/admin/src/app/(dashboard)/infrastructure/page.tsx new file mode 100644 index 0000000000000000000000000000000000000000..5449f27f18ec421e8e81e133b533316f50b090b3 --- /dev/null +++ b/apps/admin/src/app/(dashboard)/infrastructure/page.tsx @@ -0,0 +1,191 @@ +"use client"; + +import React from "react"; +import { BrainCircuit, RefreshCw, Layers } from "lucide-react"; +import { trpc } from "@/lib/trpc"; +import { AdminHeader } from "@/components/shell/AdminHeader"; +import { + Card, CardContent, CardHeader, CardTitle, CardDescription, + Badge, Button, +} from "@micprotocol/ui"; + +interface ServiceRow { + label: string; + status: "healthy" | "degraded" | "unhealthy"; + detail: string; +} + +function StatusDot({ status }: { status: "healthy" | "degraded" | "unhealthy" }) { + const color = + status === "healthy" ? "var(--color-success)" : + status === "degraded" ? "var(--color-warning)" : "var(--color-error)"; + return ( + + ); +} + +export default function InfrastructurePage() { + const { data: health, isLoading, refetch, isFetching } = + trpc.admin.operations.systemHealth.useQuery(undefined, { + refetchInterval: 30_000, + }); + + const { data: queueHealth } = trpc.admin.operations.queueHealth.useQuery( + undefined, + { refetchInterval: 30_000 }, + ); + + const overallStatus = + health && health.database === "up" && health.redis === "up" + ? "up" + : health && health.database === "down" && health.redis === "down" + ? "down" + : "degraded"; + + const serviceRows: ServiceRow[] = []; + if (health) { + serviceRows.push( + { label: "Database", status: health.database === "up" ? "healthy" : "unhealthy", detail: "PostgreSQL via Prisma" }, + { label: "Redis", status: health.redis === "up" ? "healthy" : "unhealthy", detail: "Queues + distributed locks" }, + ); + } + if (queueHealth) { + for (const q of queueHealth) { + serviceRows.push({ + label: `Queue: ${q.name}`, + status: q.failed > 10 ? ("unhealthy" as const) : ("healthy" as const), + detail: `${q.waiting} waiting · ${q.active} active · ${q.failed} failed`, + }); + } + } + + return ( +
+ + {overallStatus.toUpperCase()} + + } + /> +
+ + + + System Health + + + Real-time platform telemetry from the operations service. Database and Redis + status are checked live; queue health is sampled from BullMQ every 30s. + + + + {isLoading ? ( +
+ {[1, 2, 3, 4].map((i) => ( +
+ Service {i} +
+
+ ))} +
+ ) : ( +
+ {serviceRows.map((row) => ( +
+
+ {row.label} + +
+ + {row.detail} + +
+ ))} +
+ )} +
+ + Last refreshed {new Date().toLocaleTimeString()} + + +
+ + + + + + + Queue Depth + + + BullMQ queue backlog per worker queue. Failed jobs above 10 are flagged critical. + + + + {queueHealth ? ( +
+ {queueHealth.map((q) => ( + 10 ? "border-[var(--color-error)]/30" : ""}`} + > + +
+
+

+ {q.name} +

+

+ {q.waiting + q.active + q.delayed + q.failed} +

+

+ {q.completed} completed +

+
+
+ 0 ? "error" : "success"} variant="subtle" size="sm"> + {q.failed} failed + + + {q.waiting} waiting + +
+
+
+
+
+ + + ))} +
+ ) : ( +

Loading queue health…

+ )} +
+
+
+
+ ); +} diff --git a/apps/admin/src/app/(dashboard)/integrations/credentials/page.tsx b/apps/admin/src/app/(dashboard)/integrations/credentials/page.tsx new file mode 100644 index 0000000000000000000000000000000000000000..9dfc1c7f014ad5282d202c09c7fbcaff83dff476 --- /dev/null +++ b/apps/admin/src/app/(dashboard)/integrations/credentials/page.tsx @@ -0,0 +1,184 @@ +"use client"; + +import React, { useState } from "react"; +import { Key, ShieldCheck, CreditCard, Lock, Eye, EyeOff } from "lucide-react"; +import { trpc } from "@/lib/trpc"; +import { cn } from "@/lib/utils"; +import { AdminHeader } from "@/components/shell/AdminHeader"; +import { Card, CardContent, CardHeader, CardTitle } from "@micprotocol/ui"; +import { Badge } from "@micprotocol/ui"; +import { Button } from "@micprotocol/ui"; + +const TIERS = ["starter", "professional", "enterprise"] as const; + +const tierAccess: Record> = { + stripe: { starter: true, professional: true, enterprise: true }, + sendgrid: { starter: false, professional: true, enterprise: true }, + aws: { starter: false, professional: false, enterprise: true }, + slack: { starter: true, professional: true, enterprise: true }, + github: { starter: true, professional: true, enterprise: true }, + google: { starter: true, professional: true, enterprise: true }, + calDotCom: { starter: false, professional: true, enterprise: true }, + zoom: { starter: false, professional: true, enterprise: true }, + meilisearch: { starter: false, professional: false, enterprise: true }, + redis: { starter: false, professional: true, enterprise: true }, +}; + +export default function IntegrationsCredentialsPage() { + const { data: credentials, isLoading } = trpc.integrations.getAllProviders.useQuery( + undefined, + { refetchInterval: 60_000 }, + ); + + const [showSecrets, setShowSecrets] = useState(false); + + const items = credentials ?? []; + + return ( +
+ + {showSecrets ? ( + <> + Hide Secrets + + ) : ( + <> + Show Secrets + + )} + + } + /> + +
+ {/* Tier access matrix */} + + + + Tier Access Matrix + + + +
+ + + + + {TIERS.map((t) => ( + + ))} + + + + {Object.entries(tierAccess).map(([integration, access]) => ( + + + {TIERS.map((t) => ( + + ))} + + ))} + +
Integration + {t.charAt(0).toUpperCase() + t.slice(1)} +
{integration === "calDotCom" ? "cal.com" : integration} + {access[t] ? ( + ✓ + ) : ( + — + )} +
+
+
+
+ + {/* Credentials table */} + + + + Stored Credentials + + + +
+ + + + + + + + + + + + + {isLoading ? ( + [...Array(5)].map((_, i) => ( + + + + )) + ) : items.length === 0 ? ( + + + + ) : ( + items.map((c: any) => ( + + + + + + + + + )) + )} + +
IntegrationTypeScopeStatusUpdatedActions
+
+
+ No credentials stored yet. +
{c.name}{c.isOAuth ? "OAuth" : "API Key"}{c.isConfigured ? "read/write" : "—"} + + {c.isConfigured ? "active" : "disconnected"} + + + {new Date().toLocaleDateString()} + +
+ +
+
+
+
+
+ + {/* Secret toggle notice */} + + +
+ +
+

+ Secret values are masked by default +

+

+ Toggle "Show Secrets" in the header to reveal decrypted secret values. +

+
+
+
+
+
+
+ ); +} diff --git a/apps/admin/src/app/(dashboard)/integrations/page.tsx b/apps/admin/src/app/(dashboard)/integrations/page.tsx new file mode 100644 index 0000000000000000000000000000000000000000..307af7000b9c836a9fef80afcb01fe4f8238eefd --- /dev/null +++ b/apps/admin/src/app/(dashboard)/integrations/page.tsx @@ -0,0 +1,113 @@ +"use client"; + +import React from "react"; +import { Link as ExternalLink, Server, ShieldCheck, Globe, Database } from "lucide-react"; +import Link from "next/link"; +import { trpc } from "@/lib/trpc"; +import { AdminHeader } from "@/components/shell/AdminHeader"; +import { Card, CardContent, CardHeader, CardTitle } from "@micprotocol/ui"; +import { Badge } from "@micprotocol/ui"; +import { Button } from "@micprotocol/ui"; + +export default function IntegrationsPage() { + const { data: integrations, isLoading } = trpc.integrations.getAllProviders.useQuery( + undefined, + { refetchInterval: 60_000 }, + ); + + const items = integrations ?? []; + const active = items.filter((i: any) => i.isConfigured).length; + const pending = 0; + const error = items.filter((i: any) => !i.isConfigured).length; + + return ( +
+ + +
+ {/* KPI strip */} +
+ +

Installed

+

{items.length}

+
+ +

Active

+

{active}

+
+ +

Pending

+

{pending}

+
+ +

Errors

+

{error}

+
+
+ + {/* Integration cards */} +
+ {items.map((i: any) => ( + + +
+
+
+ +
+
+

{i.name}

+ {i.isConfigured ? ( + + Active + + ) : ( + + Disconnected + + )} +
+

{i.description ?? "No description"}

+
+
+ {i.isOAuth ? "OAuth" : "API Key"} +
+

Endpoint

+

+ {i.docsUrl ?? "—"} +

+
+
+
+
+ + {i.docsUrl ? ( + + ) : null} +
+
+
+ ))} + {items.length === 0 && ( + +
+ +
+

No integrations installed yet.

+
+ )} +
+
+
+ ); +} diff --git a/apps/admin/src/app/(dashboard)/layout.tsx b/apps/admin/src/app/(dashboard)/layout.tsx new file mode 100644 index 0000000000000000000000000000000000000000..00d2130296c33de69e2a68c278fae8dc6414c9ac --- /dev/null +++ b/apps/admin/src/app/(dashboard)/layout.tsx @@ -0,0 +1,41 @@ +"use client"; + +import { useSession } from "@/lib/auth-client"; +import { useRouter } from "next/navigation"; +import { useEffect } from "react"; +import { AdminSidebar } from "@/components/shell/AdminSidebar"; + +export default function DashboardLayout({ children }: { children: React.ReactNode }) { + const session = useSession(); + const router = useRouter(); + + // Redirect unauthenticated users to login after mount (avoid SSR flash) + useEffect(() => { + if (!session.isPending && !session.data) { + router.replace("/login"); + } + }, [session, router]); + + // While session is still loading, show a neutral shell + if (session.isPending) { + return ( +
+
+
+

Signing in…

+
+
+ ); + } + + if (!session.data) { + return null; + } + + return ( +
+ +
{children}
+
+ ); +} diff --git a/apps/admin/src/app/(dashboard)/moderation/page.tsx b/apps/admin/src/app/(dashboard)/moderation/page.tsx new file mode 100644 index 0000000000000000000000000000000000000000..857de20c4fc628eeda63e1ab148e0a978c275750 --- /dev/null +++ b/apps/admin/src/app/(dashboard)/moderation/page.tsx @@ -0,0 +1,231 @@ +"use client"; + +import React, { useState } from "react"; +import { Mail, ShieldCheck, X, Clock } from "lucide-react"; +import { trpc } from "@/lib/trpc"; +import { cn } from "@/lib/utils"; +import { AdminHeader } from "@/components/shell/AdminHeader"; +import { Card, CardContent, CardHeader, CardTitle } from "@micprotocol/ui"; +import { Badge } from "@micprotocol/ui"; +import { Button } from "@micprotocol/ui"; +import { Input } from "@micprotocol/ui"; +import { Textarea } from "@micprotocol/ui"; +import { Modal, ModalHeader, ModalTitle, ModalBody, ModalFooter } from "@micprotocol/ui"; +import { ago } from "@/lib/utils"; + +export default function ModerationPage() { + const [resolveModal, setResolveModal] = useState<{ id: string; title: string } | null>(null); + const [takedownModal, setTakedownModal] = useState<{ id: string; title: string } | null>(null); + const [resolveReason, setResolveReason] = useState(""); + + const { data: reports, isLoading } = trpc.admin.moderation.listReports.useQuery( + { limit: 25 }, + { refetchInterval: 30_000 }, + ); + + const items = (reports?.items ?? []) as any[]; + const open = items.filter((i) => i.status === "OPEN").length; + const resolved = items.filter((i) => i.status === "RESOLVED").length; + const dismissed = items.filter((i) => i.status === "DISMISSED").length; + + const resolveReport = trpc.admin.moderation.resolve.useMutation({ + onSuccess: () => { setResolveModal(null); setResolveReason(""); }, + }); + const takedownContent = trpc.admin.moderation.takedown.useMutation({}); + + return ( +
+ + +
+ {/* KPI strip */} +
+ +

Total Reports

+

{items.length}

+
+ +

Open

+

{open}

+
+ +

Resolved

+

{resolved}

+
+ +

Dismissed

+

{dismissed}

+
+
+ + {/* Reports table */} + + + + Reported Content + + + +
+ + + + + + + + + + + + + + {isLoading ? ( + [...Array(5)].map((_, i) => ( + + + + )) + ) : items.length === 0 ? ( + + + + ) : ( + items.map((r: any) => ( + + + + + + + + + + )) + )} + +
Report IDContentTypePriorityStatusReportedActions
+
+
+ No reports yet. +
+ {r.id.slice(0, 8)}… + + {r.contentTitle ?? r.contentId?.slice(0, 8) ?? "—"} + + {r.contentType ?? "content"} + + + {r.priority} + + + {r.status} + + {new Date(r.createdAt).toLocaleDateString()} + +
+ {r.status === "OPEN" ? ( + <> + + + + ) : ( + + )} +
+
+
+
+
+ + {/* Resolve modal */} + {resolveModal && ( + setResolveModal(null)} size="md"> + + Resolve Report + + +
{ + e.preventDefault(); + resolveReport.mutate({ reportId: resolveModal!.id, resolution: resolveReason }); + setResolveModal(null); + }} + className="space-y-4" + > +
+ +