Initial commit: Port Nimara CRM (Layers 0-4)
Full CRM rebuild with Next.js 15, TypeScript, Tailwind, Drizzle ORM,
PostgreSQL, Redis, BullMQ, MinIO, and Socket.io. Includes 461 source
files covering clients, berths, interests/pipeline, documents/EOI,
expenses/invoices, email, notifications, dashboard, admin, and
client portal. CI/CD via Gitea Actions with Docker builds.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 11:52:51 +01:00
|
|
|
'use client';
|
|
|
|
|
|
|
|
|
|
import { useQuery } from '@tanstack/react-query';
|
|
|
|
|
|
|
|
|
|
import { apiFetch } from '@/lib/api/client';
|
2026-04-28 12:09:59 +02:00
|
|
|
import { KPITile } from '@/components/ui/kpi-tile';
|
|
|
|
|
import { Skeleton } from '@/components/ui/skeleton';
|
Initial commit: Port Nimara CRM (Layers 0-4)
Full CRM rebuild with Next.js 15, TypeScript, Tailwind, Drizzle ORM,
PostgreSQL, Redis, BullMQ, MinIO, and Socket.io. Includes 461 source
files covering clients, berths, interests/pipeline, documents/EOI,
expenses/invoices, email, notifications, dashboard, admin, and
client portal. CI/CD via Gitea Actions with Docker builds.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 11:52:51 +01:00
|
|
|
import { WidgetErrorBoundary } from './widget-error-boundary';
|
|
|
|
|
|
|
|
|
|
interface KpiData {
|
|
|
|
|
totalClients: number;
|
|
|
|
|
activeInterests: number;
|
|
|
|
|
pipelineValueUsd: number;
|
|
|
|
|
occupancyRate: number;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function formatCurrency(value: number): string {
|
|
|
|
|
return new Intl.NumberFormat('en-US', {
|
|
|
|
|
style: 'currency',
|
|
|
|
|
currency: 'USD',
|
|
|
|
|
maximumFractionDigits: 0,
|
|
|
|
|
}).format(value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function formatPercent(value: number): string {
|
|
|
|
|
return `${value.toFixed(1)}%`;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-28 12:09:59 +02:00
|
|
|
function KpiTileSkeleton() {
|
|
|
|
|
return (
|
2026-04-28 12:24:14 +02:00
|
|
|
<div className="relative overflow-hidden rounded-xl border border-border bg-card p-5 shadow-sm">
|
|
|
|
|
<div className="absolute inset-x-0 top-0 h-1 bg-muted" aria-hidden />
|
2026-04-28 12:09:59 +02:00
|
|
|
<Skeleton className="h-3 w-24" />
|
|
|
|
|
<Skeleton className="mt-3 h-7 w-32" />
|
|
|
|
|
<Skeleton className="mt-2 h-3 w-12" />
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
Initial commit: Port Nimara CRM (Layers 0-4)
Full CRM rebuild with Next.js 15, TypeScript, Tailwind, Drizzle ORM,
PostgreSQL, Redis, BullMQ, MinIO, and Socket.io. Includes 461 source
files covering clients, berths, interests/pipeline, documents/EOI,
expenses/invoices, email, notifications, dashboard, admin, and
client portal. CI/CD via Gitea Actions with Docker builds.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 11:52:51 +01:00
|
|
|
export function KpiCards() {
|
|
|
|
|
const { data, isLoading, isError } = useQuery<KpiData>({
|
|
|
|
|
queryKey: ['dashboard', 'kpis'],
|
|
|
|
|
queryFn: () => apiFetch<KpiData>('/api/v1/dashboard/kpis'),
|
|
|
|
|
staleTime: 60_000,
|
|
|
|
|
retry: 2,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (isLoading) {
|
|
|
|
|
return (
|
|
|
|
|
<>
|
2026-04-28 12:09:59 +02:00
|
|
|
<KpiTileSkeleton />
|
|
|
|
|
<KpiTileSkeleton />
|
|
|
|
|
<KpiTileSkeleton />
|
|
|
|
|
<KpiTileSkeleton />
|
Initial commit: Port Nimara CRM (Layers 0-4)
Full CRM rebuild with Next.js 15, TypeScript, Tailwind, Drizzle ORM,
PostgreSQL, Redis, BullMQ, MinIO, and Socket.io. Includes 461 source
files covering clients, berths, interests/pipeline, documents/EOI,
expenses/invoices, email, notifications, dashboard, admin, and
client portal. CI/CD via Gitea Actions with Docker builds.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 11:52:51 +01:00
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-28 12:09:59 +02:00
|
|
|
const kpis: Array<{
|
|
|
|
|
label: string;
|
|
|
|
|
value: string;
|
|
|
|
|
accent: 'brand' | 'success' | 'warning' | 'mint' | 'teal' | 'purple';
|
|
|
|
|
}> = [
|
Initial commit: Port Nimara CRM (Layers 0-4)
Full CRM rebuild with Next.js 15, TypeScript, Tailwind, Drizzle ORM,
PostgreSQL, Redis, BullMQ, MinIO, and Socket.io. Includes 461 source
files covering clients, berths, interests/pipeline, documents/EOI,
expenses/invoices, email, notifications, dashboard, admin, and
client portal. CI/CD via Gitea Actions with Docker builds.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 11:52:51 +01:00
|
|
|
{
|
|
|
|
|
label: 'Total Clients',
|
|
|
|
|
value: isError ? '—' : String(data?.totalClients ?? 0),
|
2026-04-28 12:09:59 +02:00
|
|
|
accent: 'brand',
|
Initial commit: Port Nimara CRM (Layers 0-4)
Full CRM rebuild with Next.js 15, TypeScript, Tailwind, Drizzle ORM,
PostgreSQL, Redis, BullMQ, MinIO, and Socket.io. Includes 461 source
files covering clients, berths, interests/pipeline, documents/EOI,
expenses/invoices, email, notifications, dashboard, admin, and
client portal. CI/CD via Gitea Actions with Docker builds.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 11:52:51 +01:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: 'Active Interests',
|
|
|
|
|
value: isError ? '—' : String(data?.activeInterests ?? 0),
|
2026-04-28 12:09:59 +02:00
|
|
|
accent: 'teal',
|
Initial commit: Port Nimara CRM (Layers 0-4)
Full CRM rebuild with Next.js 15, TypeScript, Tailwind, Drizzle ORM,
PostgreSQL, Redis, BullMQ, MinIO, and Socket.io. Includes 461 source
files covering clients, berths, interests/pipeline, documents/EOI,
expenses/invoices, email, notifications, dashboard, admin, and
client portal. CI/CD via Gitea Actions with Docker builds.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 11:52:51 +01:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: 'Pipeline Value',
|
|
|
|
|
value: isError ? '—' : formatCurrency(data?.pipelineValueUsd ?? 0),
|
2026-04-28 12:09:59 +02:00
|
|
|
accent: 'success',
|
Initial commit: Port Nimara CRM (Layers 0-4)
Full CRM rebuild with Next.js 15, TypeScript, Tailwind, Drizzle ORM,
PostgreSQL, Redis, BullMQ, MinIO, and Socket.io. Includes 461 source
files covering clients, berths, interests/pipeline, documents/EOI,
expenses/invoices, email, notifications, dashboard, admin, and
client portal. CI/CD via Gitea Actions with Docker builds.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 11:52:51 +01:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: 'Occupancy Rate',
|
|
|
|
|
value: isError ? '—' : formatPercent(data?.occupancyRate ?? 0),
|
2026-04-28 12:09:59 +02:00
|
|
|
accent: 'purple',
|
Initial commit: Port Nimara CRM (Layers 0-4)
Full CRM rebuild with Next.js 15, TypeScript, Tailwind, Drizzle ORM,
PostgreSQL, Redis, BullMQ, MinIO, and Socket.io. Includes 461 source
files covering clients, berths, interests/pipeline, documents/EOI,
expenses/invoices, email, notifications, dashboard, admin, and
client portal. CI/CD via Gitea Actions with Docker builds.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 11:52:51 +01:00
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
2026-04-28 12:09:59 +02:00
|
|
|
{kpis.map(({ label, value, accent }) => (
|
|
|
|
|
<KPITile key={label} title={label} value={value} accent={accent} />
|
Initial commit: Port Nimara CRM (Layers 0-4)
Full CRM rebuild with Next.js 15, TypeScript, Tailwind, Drizzle ORM,
PostgreSQL, Redis, BullMQ, MinIO, and Socket.io. Includes 461 source
files covering clients, berths, interests/pipeline, documents/EOI,
expenses/invoices, email, notifications, dashboard, admin, and
client portal. CI/CD via Gitea Actions with Docker builds.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 11:52:51 +01:00
|
|
|
))}
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function KpiCardsWithBoundary() {
|
|
|
|
|
return (
|
|
|
|
|
<WidgetErrorBoundary>
|
|
|
|
|
<KpiCards />
|
|
|
|
|
</WidgetErrorBoundary>
|
|
|
|
|
);
|
|
|
|
|
}
|