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';
|
|
|
|
|
|
2026-05-02 23:01:15 +02:00
|
|
|
import { useEffect, useState } from 'react';
|
|
|
|
|
import { useSearchParams, useRouter } from 'next/navigation';
|
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 { useQuery } from '@tanstack/react-query';
|
|
|
|
|
|
|
|
|
|
import { DetailLayout } from '@/components/shared/detail-layout';
|
2026-05-01 15:46:32 +02:00
|
|
|
import { useMobileChrome } from '@/components/layout/mobile/mobile-layout-provider';
|
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 { apiFetch } from '@/lib/api/client';
|
|
|
|
|
import { useRealtimeInvalidation } from '@/hooks/use-realtime-invalidation';
|
|
|
|
|
import { BerthDetailHeader } from './berth-detail-header';
|
2026-05-02 23:01:15 +02:00
|
|
|
import { BerthForm } from './berth-form';
|
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 { buildBerthTabs } from './berth-tabs';
|
|
|
|
|
|
|
|
|
|
interface BerthDetailProps {
|
|
|
|
|
berthId: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function BerthDetail({ berthId }: BerthDetailProps) {
|
2026-03-26 12:29:55 +01:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
|
|
|
const { data, isLoading } = useQuery<any>({
|
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
|
|
|
queryKey: ['berth', berthId],
|
|
|
|
|
queryFn: () =>
|
2026-03-26 12:29:55 +01:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
|
|
|
apiFetch<{ data: any }>(`/api/v1/berths/${berthId}`).then((r) => r.data),
|
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
|
|
|
});
|
|
|
|
|
|
|
|
|
|
useRealtimeInvalidation({
|
|
|
|
|
'berth:updated': [['berth', berthId]],
|
|
|
|
|
'berth:statusChanged': [['berth', berthId]],
|
|
|
|
|
});
|
|
|
|
|
|
2026-05-01 15:46:32 +02:00
|
|
|
const { setChrome } = useMobileChrome();
|
2026-05-12 14:50:58 +02:00
|
|
|
const titleForChrome: string | null = data?.mooringNumber ? `Berth ${data.mooringNumber}` : null;
|
2026-05-01 15:46:32 +02:00
|
|
|
useEffect(() => {
|
|
|
|
|
setChrome({ title: titleForChrome, showBackButton: true });
|
|
|
|
|
return () => setChrome({ title: null, showBackButton: false });
|
|
|
|
|
}, [titleForChrome, setChrome]);
|
|
|
|
|
|
2026-05-02 23:01:15 +02:00
|
|
|
// Auto-open edit sheet when ?edit=true is present in the URL
|
|
|
|
|
const searchParams = useSearchParams();
|
|
|
|
|
const router = useRouter();
|
|
|
|
|
const [editOpen, setEditOpen] = useState(false);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (searchParams.get('edit') === 'true') {
|
|
|
|
|
setEditOpen(true);
|
|
|
|
|
// Strip the param without adding a history entry
|
|
|
|
|
const params = new URLSearchParams(searchParams.toString());
|
|
|
|
|
params.delete('edit');
|
|
|
|
|
const newUrl = params.toString() ? `?${params.toString()}` : window.location.pathname;
|
|
|
|
|
// typedRoutes can't statically validate this dynamic path; cast is safe
|
|
|
|
|
// because we're always replacing within the same route segment.
|
|
|
|
|
router.replace(newUrl as never);
|
|
|
|
|
}
|
|
|
|
|
// Only run once on mount / when searchParams changes
|
|
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
|
|
|
}, [searchParams]);
|
|
|
|
|
|
2026-03-26 12:29:55 +01:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
|
|
|
const berth = data as any;
|
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-05-02 23:01:15 +02:00
|
|
|
<>
|
|
|
|
|
<DetailLayout
|
|
|
|
|
isLoading={isLoading}
|
|
|
|
|
header={berth ? <BerthDetailHeader berth={berth} /> : null}
|
|
|
|
|
tabs={berth ? buildBerthTabs(berth) : []}
|
|
|
|
|
defaultTab="overview"
|
|
|
|
|
/>
|
|
|
|
|
{berth ? <BerthForm berth={berth} open={editOpen} onOpenChange={setEditOpen} /> : null}
|
|
|
|
|
</>
|
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
|
|
|
);
|
|
|
|
|
}
|