'use client'; import { useMutation, useQueryClient } from '@tanstack/react-query'; import type { DetailTab } from '@/components/shared/detail-layout'; import { EmptyState } from '@/components/shared/empty-state'; import { InlineEditableField } from '@/components/shared/inline-editable-field'; import { InlineTagEditor } from '@/components/shared/inline-tag-editor'; import { NotesList } from '@/components/shared/notes-list'; import { CompanyMembersTab } from '@/components/companies/company-members-tab'; import { CompanyOwnedYachtsTab } from '@/components/companies/company-owned-yachts-tab'; import { apiFetch } from '@/lib/api/client'; type CompanyPatchField = | 'name' | 'legalName' | 'taxId' | 'registrationNumber' | 'incorporationCountry' | 'incorporationDate' | 'status' | 'billingEmail' | 'notes'; const STATUS_OPTIONS = [ { value: 'active', label: 'Active' }, { value: 'dissolved', label: 'Dissolved' }, ]; interface CompanyTabsCompany { id: string; name: string; legalName: string | null; taxId: string | null; registrationNumber: string | null; incorporationCountry: string | null; incorporationDate: string | null; status: string; billingEmail: string | null; notes: string | null; tags?: Array<{ id: string; name: string; color: string }>; } interface CompanyTabsOptions { companyId: string; portSlug: string; currentUserId?: string; company: CompanyTabsCompany; } function useCompanyPatch(companyId: string) { const qc = useQueryClient(); return useMutation({ mutationFn: async (patch: Partial>) => apiFetch(`/api/v1/companies/${companyId}`, { method: 'PATCH', body: patch, }), onSuccess: () => { qc.invalidateQueries({ queryKey: ['companies', companyId] }); }, }); } function EditableRow({ label, children }: { label: string; children: React.ReactNode }) { return (
{label}
{children}
); } function OverviewTab({ companyId, company }: { companyId: string; company: CompanyTabsCompany }) { const mutation = useCompanyPatch(companyId); const save = (field: CompanyPatchField) => async (next: string | null) => { await mutation.mutateAsync({ [field]: next }); }; return (
{/* Identity */}

Identity

{/* Registration */}

Registration

{/* Contact */}

Contact

{/* Notes */}

Notes

{/* Tags */}

Tags

); } export function getCompanyTabs({ companyId, portSlug, currentUserId, company, }: CompanyTabsOptions): DetailTab[] { return [ { id: 'overview', label: 'Overview', content: , }, { id: 'members', label: 'Members', content: , }, { id: 'owned-yachts', label: 'Owned Yachts', content: , }, { id: 'addresses', label: 'Addresses', content: ( ), }, { id: 'documents', label: 'Documents', content: , }, { id: 'notes', label: 'Notes', content: ( ), }, ]; }