-
Notifications
You must be signed in to change notification settings - Fork 0
fix(web): repair portal earnings chart, dead header search, bare 404 #32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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'); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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"> | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Inconsistent shadow utility. The rest of the application, including the admin 404 card in
Suggested change
|
||||||
| <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'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> | ||||||
| ); | ||||||
|
|
||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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(); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 usingtoFixed(1)and removing the trailing zero to provide better precision while keeping the labels concise.