fix(ux): popover collision padding, PWA manifest, webhook toasts, portal toast, dashboard error boundary, GDPR poll backoff, empty-state CTA
Grab-bag of UX gaps from audit-pass-#2 + #3. Each one is a small, focused fix; bundled because they touch different surfaces. - Popover: collisionPadding={16} + responsive w-[min(calc(100vw-2rem),18rem)] so popovers stop clipping past the viewport on iPhone 12 portrait. - public/manifest.json (was missing) + manifest reference in layout.tsx — PWA installability now works; icons (192/512/512- maskable) were already present. - Admin webhooks page: 4 silent `// ignore` catches in load/delete/ toggle/regenerate replaced with toast.error / toast.success. Users no longer see a stale list with no feedback when an op fails. - Portal document-download button: blocking alert() → toast.error(). - src/app/(dashboard)/error.tsx: branded error boundary with retry + back-to-dashboard, replacing Next.js's default uncaught-error UI. - GDPR export modal: refetchInterval was a flat 5s while the modal was open. Switched to a function that only polls (every 15s) when a job is actually pending/building; settled exports stop polling entirely. - client-yachts-tab empty state gains a CTA wired to the existing Add-yacht dialog, instead of just saying "No yachts". Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
30
public/manifest.json
Normal file
30
public/manifest.json
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
{
|
||||||
|
"name": "Port Nimara CRM",
|
||||||
|
"short_name": "Port Nimara",
|
||||||
|
"description": "Marina/port management CRM",
|
||||||
|
"start_url": "/",
|
||||||
|
"display": "standalone",
|
||||||
|
"background_color": "#f2f2f2",
|
||||||
|
"theme_color": "#0f172a",
|
||||||
|
"orientation": "any",
|
||||||
|
"icons": [
|
||||||
|
{
|
||||||
|
"src": "/icon-192.png",
|
||||||
|
"sizes": "192x192",
|
||||||
|
"type": "image/png",
|
||||||
|
"purpose": "any"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "/icon-512.png",
|
||||||
|
"sizes": "512x512",
|
||||||
|
"type": "image/png",
|
||||||
|
"purpose": "any"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "/icon-512-maskable.png",
|
||||||
|
"sizes": "512x512",
|
||||||
|
"type": "image/png",
|
||||||
|
"purpose": "maskable"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { useCallback, useEffect, useState } from 'react';
|
import { useCallback, useEffect, useState } from 'react';
|
||||||
|
import { toast } from 'sonner';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { PageHeader } from '@/components/shared/page-header';
|
import { PageHeader } from '@/components/shared/page-header';
|
||||||
import { Badge } from '@/components/ui/badge';
|
import { Badge } from '@/components/ui/badge';
|
||||||
@@ -47,8 +48,8 @@ export default function WebhooksPage() {
|
|||||||
try {
|
try {
|
||||||
const result = await apiFetch<{ data: Webhook[] }>('/api/v1/admin/webhooks');
|
const result = await apiFetch<{ data: Webhook[] }>('/api/v1/admin/webhooks');
|
||||||
setWebhooks(result.data);
|
setWebhooks(result.data);
|
||||||
} catch {
|
} catch (err) {
|
||||||
// ignore
|
toast.error(err instanceof Error ? err.message : 'Failed to load webhooks');
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
@@ -63,9 +64,10 @@ export default function WebhooksPage() {
|
|||||||
try {
|
try {
|
||||||
await apiFetch(`/api/v1/admin/webhooks/${deleteTarget.id}`, { method: 'DELETE' });
|
await apiFetch(`/api/v1/admin/webhooks/${deleteTarget.id}`, { method: 'DELETE' });
|
||||||
setDeleteTarget(null);
|
setDeleteTarget(null);
|
||||||
|
toast.success('Webhook deleted');
|
||||||
void loadWebhooks();
|
void loadWebhooks();
|
||||||
} catch {
|
} catch (err) {
|
||||||
// ignore
|
toast.error(err instanceof Error ? err.message : 'Failed to delete webhook');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,8 +80,8 @@ export default function WebhooksPage() {
|
|||||||
);
|
);
|
||||||
setNewSecret({ webhookId, secret: result.data.secret, masked: result.data.secretMasked });
|
setNewSecret({ webhookId, secret: result.data.secret, masked: result.data.secretMasked });
|
||||||
void loadWebhooks();
|
void loadWebhooks();
|
||||||
} catch {
|
} catch (err) {
|
||||||
// ignore
|
toast.error(err instanceof Error ? err.message : 'Failed to regenerate secret');
|
||||||
} finally {
|
} finally {
|
||||||
setRegenerating(null);
|
setRegenerating(null);
|
||||||
}
|
}
|
||||||
@@ -91,9 +93,10 @@ export default function WebhooksPage() {
|
|||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
body: { isActive: !webhook.isActive },
|
body: { isActive: !webhook.isActive },
|
||||||
});
|
});
|
||||||
|
toast.success(webhook.isActive ? 'Webhook disabled' : 'Webhook enabled');
|
||||||
void loadWebhooks();
|
void loadWebhooks();
|
||||||
} catch {
|
} catch (err) {
|
||||||
// ignore
|
toast.error(err instanceof Error ? err.message : 'Failed to toggle webhook');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
55
src/app/(dashboard)/error.tsx
Normal file
55
src/app/(dashboard)/error.tsx
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import { useEffect } from 'react';
|
||||||
|
import Link from 'next/link';
|
||||||
|
import { AlertCircle, RotateCcw } from 'lucide-react';
|
||||||
|
|
||||||
|
import { Button } from '@/components/ui/button';
|
||||||
|
|
||||||
|
interface ErrorProps {
|
||||||
|
error: Error & { digest?: string };
|
||||||
|
reset: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function DashboardError({ error, reset }: ErrorProps) {
|
||||||
|
useEffect(() => {
|
||||||
|
// Forward to the browser console so the dev sees the stack while the
|
||||||
|
// user sees the friendly UI. The server already wrote an error_events
|
||||||
|
// row through the page-level error pipeline.
|
||||||
|
|
||||||
|
console.error('Dashboard render error:', error);
|
||||||
|
}, [error]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="flex items-start justify-center min-h-[60vh] p-6">
|
||||||
|
<div className="max-w-md w-full bg-background border rounded-lg p-6 shadow-sm">
|
||||||
|
<div className="flex items-center gap-3 mb-4">
|
||||||
|
<div className="rounded-full bg-red-100 p-2">
|
||||||
|
<AlertCircle className="h-5 w-5 text-red-600" />
|
||||||
|
</div>
|
||||||
|
<h1 className="text-lg font-semibold">Something went wrong</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p className="text-sm text-muted-foreground mb-4">
|
||||||
|
The page hit an unexpected error. The team has been notified
|
||||||
|
{error.digest ? ' (ref: ' : '.'}
|
||||||
|
{error.digest ? <code className="font-mono text-xs">{error.digest}</code> : null}
|
||||||
|
{error.digest ? ').' : ''}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<Button onClick={reset} size="sm">
|
||||||
|
<RotateCcw className="h-3.5 w-3.5 mr-1.5" />
|
||||||
|
Try again
|
||||||
|
</Button>
|
||||||
|
<Link
|
||||||
|
href={'/' as never}
|
||||||
|
className="text-sm text-muted-foreground hover:text-foreground underline"
|
||||||
|
>
|
||||||
|
Back to dashboard
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { Download, Loader2 } from 'lucide-react';
|
import { Download, Loader2 } from 'lucide-react';
|
||||||
|
import { toast } from 'sonner';
|
||||||
|
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
|
|
||||||
interface DocumentDownloadButtonProps {
|
interface DocumentDownloadButtonProps {
|
||||||
@@ -16,25 +18,20 @@ export function DocumentDownloadButton({ documentId }: DocumentDownloadButtonPro
|
|||||||
try {
|
try {
|
||||||
const res = await fetch(`/api/portal/documents/${documentId}/download`);
|
const res = await fetch(`/api/portal/documents/${documentId}/download`);
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
alert('Unable to download document. Please try again.');
|
toast.error('Unable to download document. Please try again.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const data = await res.json() as { url: string };
|
const data = (await res.json()) as { url: string };
|
||||||
window.open(data.url, '_blank', 'noopener,noreferrer');
|
window.open(data.url, '_blank', 'noopener,noreferrer');
|
||||||
} catch {
|
} catch {
|
||||||
alert('Unable to download document. Please check your connection.');
|
toast.error('Unable to download document. Please check your connection.');
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Button
|
<Button variant="outline" size="sm" onClick={handleDownload} disabled={loading}>
|
||||||
variant="outline"
|
|
||||||
size="sm"
|
|
||||||
onClick={handleDownload}
|
|
||||||
disabled={loading}
|
|
||||||
>
|
|
||||||
{loading ? (
|
{loading ? (
|
||||||
<Loader2 className="h-3.5 w-3.5 animate-spin" />
|
<Loader2 className="h-3.5 w-3.5 animate-spin" />
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ export const metadata: Metadata = {
|
|||||||
],
|
],
|
||||||
apple: '/apple-touch-icon.png',
|
apple: '/apple-touch-icon.png',
|
||||||
},
|
},
|
||||||
|
manifest: '/manifest.json',
|
||||||
};
|
};
|
||||||
|
|
||||||
export default async function RootLayout({ children }: { children: React.ReactNode }) {
|
export default async function RootLayout({ children }: { children: React.ReactNode }) {
|
||||||
|
|||||||
@@ -49,7 +49,11 @@ export function ClientYachtsTab({ clientId: _clientId, yachts }: ClientYachtsTab
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{yachts.length === 0 ? (
|
{yachts.length === 0 ? (
|
||||||
<EmptyState title="No yachts" description="No yachts owned by this client yet." />
|
<EmptyState
|
||||||
|
title="No yachts yet"
|
||||||
|
description="Track every yacht this client owns or charters here. Linked yachts pre-fill EOIs and surface in the recommender."
|
||||||
|
action={{ label: 'Add yacht', onClick: () => setCreateOpen(true) }}
|
||||||
|
/>
|
||||||
) : (
|
) : (
|
||||||
<div className="rounded-md border">
|
<div className="rounded-md border">
|
||||||
<Table>
|
<Table>
|
||||||
|
|||||||
@@ -62,7 +62,15 @@ export function GdprExportButton({ clientId }: { clientId: string }) {
|
|||||||
queryKey,
|
queryKey,
|
||||||
queryFn: () => apiFetch<ListResp>(`/api/v1/clients/${clientId}/gdpr-export`),
|
queryFn: () => apiFetch<ListResp>(`/api/v1/clients/${clientId}/gdpr-export`),
|
||||||
enabled: open && allowed,
|
enabled: open && allowed,
|
||||||
refetchInterval: open && allowed ? 5_000 : false,
|
// Poll only when the user is watching AND a job is in flight. GDPR
|
||||||
|
// exports take ~30s; 15s is the rule-of-thumb minimum that doesn't
|
||||||
|
// burn CPU. When everything's already settled, stop polling.
|
||||||
|
refetchInterval: (q) => {
|
||||||
|
if (!open || !allowed) return false;
|
||||||
|
const rows = q.state.data?.data ?? [];
|
||||||
|
const hasInFlight = rows.some((r) => r.status === 'pending' || r.status === 'building');
|
||||||
|
return hasInFlight ? 15_000 : false;
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const request = useMutation({
|
const request = useMutation({
|
||||||
|
|||||||
@@ -1,33 +1,37 @@
|
|||||||
"use client"
|
'use client';
|
||||||
|
|
||||||
import * as React from "react"
|
import * as React from 'react';
|
||||||
import * as PopoverPrimitive from "@radix-ui/react-popover"
|
import * as PopoverPrimitive from '@radix-ui/react-popover';
|
||||||
|
|
||||||
import { cn } from "@/lib/utils"
|
import { cn } from '@/lib/utils';
|
||||||
|
|
||||||
const Popover = PopoverPrimitive.Root
|
const Popover = PopoverPrimitive.Root;
|
||||||
|
|
||||||
const PopoverTrigger = PopoverPrimitive.Trigger
|
const PopoverTrigger = PopoverPrimitive.Trigger;
|
||||||
|
|
||||||
const PopoverAnchor = PopoverPrimitive.Anchor
|
const PopoverAnchor = PopoverPrimitive.Anchor;
|
||||||
|
|
||||||
const PopoverContent = React.forwardRef<
|
const PopoverContent = React.forwardRef<
|
||||||
React.ElementRef<typeof PopoverPrimitive.Content>,
|
React.ElementRef<typeof PopoverPrimitive.Content>,
|
||||||
React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content>
|
React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content>
|
||||||
>(({ className, align = "center", sideOffset = 4, ...props }, ref) => (
|
>(({ className, align = 'center', sideOffset = 4, collisionPadding = 16, ...props }, ref) => (
|
||||||
<PopoverPrimitive.Portal>
|
<PopoverPrimitive.Portal>
|
||||||
<PopoverPrimitive.Content
|
<PopoverPrimitive.Content
|
||||||
ref={ref}
|
ref={ref}
|
||||||
align={align}
|
align={align}
|
||||||
sideOffset={sideOffset}
|
sideOffset={sideOffset}
|
||||||
|
// collisionPadding keeps the popover from clipping past the viewport
|
||||||
|
// edge on mobile (390px / iPad portrait). w-72 is a desktop default;
|
||||||
|
// on narrow viewports the calc() ceiling kicks in.
|
||||||
|
collisionPadding={collisionPadding}
|
||||||
className={cn(
|
className={cn(
|
||||||
"z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-popover-content-transform-origin]",
|
'z-50 w-[min(calc(100vw-2rem),18rem)] rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-popover-content-transform-origin]',
|
||||||
className
|
className,
|
||||||
)}
|
)}
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
</PopoverPrimitive.Portal>
|
</PopoverPrimitive.Portal>
|
||||||
))
|
));
|
||||||
PopoverContent.displayName = PopoverPrimitive.Content.displayName
|
PopoverContent.displayName = PopoverPrimitive.Content.displayName;
|
||||||
|
|
||||||
export { Popover, PopoverTrigger, PopoverContent, PopoverAnchor }
|
export { Popover, PopoverTrigger, PopoverContent, PopoverAnchor };
|
||||||
|
|||||||
Reference in New Issue
Block a user