Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions apps/web/src/app/(admin)/not-found.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ import Link from 'next/link';

export default function AdminNotFound() {
return (
<div className="flex items-center justify-center py-20">
<div className="w-full max-w-md text-center">
<div className="flex items-center justify-center py-16">
<div className="w-full max-w-md rounded-2xl border border-slate-200 bg-white p-10 text-center shadow-xs">
<p className="text-6xl font-bold text-slate-200">404</p>
<h2 className="mt-4 text-lg font-semibold text-slate-900">Page not found</h2>
<p className="mt-2 text-sm text-slate-500">
The page you are looking for does not exist.
The page you are looking for doesn&apos;t exist or may have been moved.
</p>
<Link
href="/dashboard"
className="mt-6 inline-block rounded-md bg-brand-500 px-4 py-2 text-sm font-medium text-white hover:bg-brand-600"
className="mt-6 inline-block rounded-md bg-brand-500 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-brand-600"
>
Go to Dashboard
</Link>
Expand Down
19 changes: 13 additions & 6 deletions apps/web/src/app/(portal)/portal/dashboard/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import Link from 'next/link';
import { api } from '@/lib/api-client';
import { useAuth } from '@/hooks/use-auth';
import {
BarChart,
Bar,
AreaChart,
Area,
XAxis,
YAxis,
CartesianGrid,
Expand Down Expand Up @@ -152,21 +152,28 @@ export default function PortalDashboardPage() {
{earnings.length > 0 ? (
<div className="mt-4 h-56">
<ResponsiveContainer width="100%" height="100%">
<BarChart data={earnings}>
<AreaChart data={earnings}>
<defs>
<linearGradient id="earningsGradient" x1="0" y1="0" x2="0" y2="1">
<stop offset="5%" stopColor="#6366f1" stopOpacity={0.15} />
<stop offset="95%" stopColor="#6366f1" stopOpacity={0} />
</linearGradient>
</defs>
<CartesianGrid strokeDasharray="3 3" stroke="#e2e8f0" />
<XAxis dataKey="label" tick={{ fontSize: 12, fill: '#64748b' }} axisLine={false} tickLine={false} interval="preserveStartEnd" />
<YAxis
tick={{ fontSize: 12, fill: '#64748b' }}
axisLine={false}
tickLine={false}
tickFormatter={(v: number) => v >= 1000 ? `$${(v / 1000).toFixed(0)}k` : `$${v}`}
width={48}
tickFormatter={(v: number) => (v >= 1000 ? `$${(v / 1000).toFixed(0)}k` : `$${v}`)}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The use of toFixed(0) rounds currency values to the nearest thousand, which can be misleading for financial data (e.g., $1,500 would be displayed as $2k). Consider using toFixed(1) and removing the trailing zero to provide better precision while keeping the labels concise.

Suggested change
tickFormatter={(v: number) => (v >= 1000 ? `$${(v / 1000).toFixed(0)}k` : `$${v}`)}
tickFormatter={(v: number) => (v >= 1000 ? `$${(v / 1000).toFixed(1).replace(/\.0$/, '')}k` : `$${v}`)}

/>
<Tooltip
formatter={(value) => [`$${Number(value ?? 0).toLocaleString('en-US', { minimumFractionDigits: 2 })}`, 'Earnings']}
contentStyle={{ borderRadius: '8px', border: '1px solid #e2e8f0', fontSize: '13px' }}
/>
<Bar dataKey="total" fill="#6366f1" radius={[4, 4, 0, 0]} />
</BarChart>
<Area type="monotone" dataKey="total" stroke="#6366f1" strokeWidth={2} fill="url(#earningsGradient)" />
</AreaChart>
</ResponsiveContainer>
</div>
) : (
Expand Down
30 changes: 30 additions & 0 deletions apps/web/src/app/not-found.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { describe, it, expect } from 'vitest';
import { render, screen } from '@testing-library/react';
import NotFound from './not-found';
import AdminNotFound from './(admin)/not-found';

describe('NotFound (root)', () => {
it('shows branded 404 content', () => {
render(<NotFound />);
expect(screen.getByText('404')).toBeInTheDocument();
expect(screen.getByText('Page not found')).toBeInTheDocument();
// Brand mark is present so a logged-out 404 still looks on-brand.
expect(screen.getByText('ContractorOS')).toBeInTheDocument();
});

it('routes the primary action to "/" so it is safe in any auth state', () => {
render(<NotFound />);
const cta = screen.getByRole('link', { name: /back to home/i });
expect(cta).toHaveAttribute('href', '/');
});
});

describe('AdminNotFound', () => {
it('renders inside the admin shell and links back to the dashboard', () => {
render(<AdminNotFound />);
expect(screen.getByText('404')).toBeInTheDocument();
expect(
screen.getByRole('link', { name: /go to dashboard/i }),
).toHaveAttribute('href', '/dashboard');
});
});
35 changes: 23 additions & 12 deletions apps/web/src/app/not-found.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,30 @@ import Link from 'next/link';

export default function NotFound() {
return (
<div className="flex min-h-screen items-center justify-center bg-slate-50 px-4">
<div className="w-full max-w-md text-center">
<p className="text-6xl font-bold text-slate-200">404</p>
<h2 className="mt-4 text-lg font-semibold text-slate-900">Page not found</h2>
<p className="mt-2 text-sm text-slate-500">
The page you are looking for does not exist.
</p>
<Link
href="/dashboard"
className="mt-6 inline-block rounded-md bg-brand-500 px-4 py-2 text-sm font-medium text-white hover:bg-brand-600"
>
Go to Dashboard
<div className="flex min-h-screen items-center justify-center bg-gradient-to-br from-[#eef1ff] via-[#f5f7fc] to-[#f8f9fb] px-4">
<div className="w-full max-w-md">
<Link href="/" className="mb-8 flex flex-col items-center">
<div className="mb-4 flex h-11 w-11 items-center justify-center rounded-xl bg-brand-600">
<span className="text-lg font-bold text-white">C</span>
</div>
<h1 className="text-xl font-bold text-slate-900">ContractorOS</h1>
<p className="mt-1 text-[13px] text-slate-500">
Unified contractor lifecycle platform
</p>
</Link>
<div className="rounded-2xl border border-slate-200 bg-white p-8 text-center shadow-card">
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Inconsistent shadow utility. The rest of the application, including the admin 404 card in apps/web/src/app/(admin)/not-found.tsx, uses shadow-xs. Unless shadow-card is a specific custom utility intended for this branded page, consider using shadow-xs for visual consistency.

Suggested change
<div className="rounded-2xl border border-slate-200 bg-white p-8 text-center shadow-card">
<div className="rounded-2xl border border-slate-200 bg-white p-8 text-center shadow-xs">

<p className="text-6xl font-bold text-slate-200">404</p>
<h2 className="mt-4 text-lg font-semibold text-slate-900">Page not found</h2>
<p className="mt-2 text-sm text-slate-500">
The page you are looking for doesn&apos;t exist or may have been moved.
</p>
<Link
href="/"
className="mt-6 inline-block rounded-md bg-brand-500 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-brand-600"
>
Back to home
</Link>
</div>
</div>
</div>
);
Expand Down
56 changes: 56 additions & 0 deletions apps/web/src/components/layout/header.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { render, screen } from '@testing-library/react';

let mockPathname = '/dashboard';

vi.mock('next/navigation', () => ({
usePathname: () => mockPathname,
useRouter: () => ({ push: vi.fn(), back: vi.fn(), replace: vi.fn() }),
}));

vi.mock('@/hooks/use-auth', () => ({
useAuth: () => ({
user: { firstName: 'Sarah', lastName: 'Chen', email: 'sarah@acme.test' },
isLoading: false,
login: vi.fn(),
logout: vi.fn(),
}),
}));

// The notification dropdown fetches over the network on mount; stub it so the
// Header renders in isolation.
vi.mock('@/components/notifications/notification-dropdown', () => ({
NotificationDropdown: () => null,
}));

import { Header } from './header';

describe('Header', () => {
beforeEach(() => {
mockPathname = '/dashboard';
});

it('renders the search control as an accessible link to the contractor directory on admin routes', () => {
mockPathname = '/dashboard';
render(<Header />);

const search = screen.getByRole('link', { name: /search contractors/i });
expect(search).toHaveAttribute('href', '/contractors');
});

it('scopes the search control to invoices inside the contractor portal', () => {
mockPathname = '/portal/dashboard';
render(<Header />);

const search = screen.getByRole('link', { name: /search invoices/i });
expect(search).toHaveAttribute('href', '/portal/invoices');
});

it('exposes an accessible name on the mobile navigation toggle', () => {
render(<Header onMenuToggle={vi.fn()} />);

expect(
screen.getByRole('button', { name: /open navigation menu/i }),
).toBeInTheDocument();
});
});
15 changes: 13 additions & 2 deletions apps/web/src/components/layout/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,20 @@ interface HeaderProps {

export function Header({ onMenuToggle }: HeaderProps) {
const breadcrumbs = useBreadcrumbs();
const pathname = usePathname();
const isPortal = pathname.startsWith('/portal');
const searchHref = isPortal ? '/portal/invoices' : '/contractors';
const searchLabel = isPortal ? 'Search invoices' : 'Search contractors';

return (
<header className="sticky top-0 z-20 flex h-14 items-center justify-between bg-slate-50 px-4 sm:px-6 lg:px-8">
{/* Left: Hamburger + Breadcrumbs */}
<div className="flex min-w-0 flex-1 items-center gap-2">
{onMenuToggle && (
<button
type="button"
onClick={onMenuToggle}
aria-label="Open navigation menu"
className="shrink-0 rounded-lg p-2 text-slate-500 transition-colors hover:bg-white/60 hover:text-slate-700 lg:hidden"
>
<Menu className="h-5 w-5" />
Expand Down Expand Up @@ -102,9 +108,14 @@ export function Header({ onMenuToggle }: HeaderProps) {

{/* Right: Action icons */}
<div className="flex shrink-0 items-center gap-1">
<button className="rounded-lg p-2 text-slate-400 transition-colors hover:bg-white/60 hover:text-slate-600">
<Link
href={searchHref}
aria-label={searchLabel}
title={searchLabel}
className="rounded-lg p-2 text-slate-400 transition-colors hover:bg-white/60 hover:text-slate-600"
>
<Search className="h-[18px] w-[18px]" />
</button>
</Link>
<NotificationDropdown />
<UserMenu />
</div>
Expand Down
Loading