-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ✨ add default not found and error pages
- Loading branch information
1 parent
f37c8f9
commit e9154a1
Showing
10 changed files
with
99 additions
and
26 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -26,7 +26,7 @@ | |
"prettier": "@jimmy.codes/prettier-config", | ||
"dependencies": { | ||
"@tanstack/react-query": "5.59.16", | ||
"@tanstack/react-router": "1.76.3", | ||
"@tanstack/react-router": "1.77.8", | ||
"clsx": "2.1.1", | ||
"react": "18.3.1", | ||
"react-dom": "18.3.1", | ||
|
@@ -48,8 +48,8 @@ | |
"@storybook/react-vite": "8.3.6", | ||
"@tailwindcss/typography": "0.5.15", | ||
"@tanstack/react-query-devtools": "5.59.16", | ||
"@tanstack/router-devtools": "1.76.3", | ||
"@tanstack/router-vite-plugin": "1.76.0", | ||
"@tanstack/router-devtools": "1.77.8", | ||
"@tanstack/router-vite-plugin": "1.77.7", | ||
"@testing-library/dom": "10.4.0", | ||
"@testing-library/jest-dom": "6.6.2", | ||
"@testing-library/react": "16.0.1", | ||
|
@@ -59,18 +59,18 @@ | |
"@types/react": "18.3.12", | ||
"@types/react-dom": "18.3.1", | ||
"@vitejs/plugin-react-swc": "3.7.1", | ||
"@vitest/coverage-v8": "2.1.3", | ||
"@vitest/ui": "2.1.3", | ||
"@vitest/coverage-v8": "2.1.4", | ||
"@vitest/ui": "2.1.4", | ||
"autoprefixer": "10.4.20", | ||
"daisyui": "4.12.13", | ||
"daisyui": "4.12.14", | ||
"eslint": "8.57.0", | ||
"eslint-plugin-storybook": "0.10.0--canary.156.408aed4.0", | ||
"gitzy": "5.4.0", | ||
"happy-dom": "15.7.4", | ||
"is-ci": "3.0.1", | ||
"knip": "5.34.0", | ||
"lefthook": "1.8.1", | ||
"msw": "2.5.1", | ||
"knip": "5.34.3", | ||
"lefthook": "1.8.2", | ||
"msw": "2.6.0", | ||
"postcss": "8.4.47", | ||
"prettier": "3.3.3", | ||
"storybook": "8.3.6", | ||
|
@@ -79,7 +79,7 @@ | |
"typescript": "5.4.5", | ||
"vite": "5.4.10", | ||
"vite-tsconfig-paths": "5.0.1", | ||
"vitest": "2.1.3" | ||
"vitest": "2.1.4" | ||
}, | ||
"packageManager": "[email protected]" | ||
} |
This file contains 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 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 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,13 @@ | ||
import { render, screen } from "@/testing/utils"; | ||
|
||
import { Error as ErrorPage } from "./error"; | ||
|
||
describe("<Error />", () => { | ||
it('should render "Something went Wrong!" message', async () => { | ||
await render( | ||
<ErrorPage reset={vi.fn()} error={new Error("Something went Wrong!")} />, | ||
); | ||
|
||
expect(screen.getByText("Something went Wrong!")).toBeInTheDocument(); | ||
}); | ||
}); |
This file contains 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,21 @@ | ||
import { type ErrorComponentProps, Link } from "@tanstack/react-router"; | ||
|
||
export const Error = ({ error }: ErrorComponentProps) => { | ||
return ( | ||
<main className="grid min-h-screen place-content-center"> | ||
<div className="dsy-hero"> | ||
<div className="dsy-hero-content text-center"> | ||
<div className="max-w-md"> | ||
<h1 className="mb-5 text-5xl font-bold opacity-10 lg:text-7xl xl:text-9xl"> | ||
Error | ||
</h1> | ||
<p className="mb-5">{error.message}</p> | ||
<Link className="dsy-btn dsy-btn-outline" to="/"> | ||
Go back | ||
</Link> | ||
</div> | ||
</div> | ||
</div> | ||
</main> | ||
); | ||
}; |
This file contains 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 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,11 @@ | ||
import { render, screen } from "@/testing/utils"; | ||
|
||
import { NotFound } from "./not-found"; | ||
|
||
describe("<NotFound />", () => { | ||
it('should render "Not Found" message', async () => { | ||
await render(<NotFound />); | ||
|
||
expect(screen.getByText("Not Found")).toBeInTheDocument(); | ||
}); | ||
}); |
This file contains 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,21 @@ | ||
import { Link } from "@tanstack/react-router"; | ||
|
||
export const NotFound = () => { | ||
return ( | ||
<main className="grid min-h-screen place-content-center"> | ||
<div className="dsy-hero"> | ||
<div className="dsy-hero-content text-center"> | ||
<div className="max-w-md"> | ||
<h1 className="mb-5 text-5xl font-bold opacity-10 lg:text-7xl xl:text-9xl"> | ||
Error | ||
</h1> | ||
<p className="mb-5">Not Found</p> | ||
<Link className="dsy-btn dsy-btn-outline" to="/"> | ||
Go back | ||
</Link> | ||
</div> | ||
</div> | ||
</div> | ||
</main> | ||
); | ||
}; |
This file contains 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,17 @@ | ||
import { createRouter } from "@tanstack/react-router"; | ||
|
||
import { Error } from "./pages/error"; | ||
import { NotFound } from "./pages/not-found"; | ||
import { routeTree } from "./route-tree.gen"; | ||
|
||
export const router = createRouter({ | ||
routeTree, | ||
defaultNotFoundComponent: NotFound, | ||
defaultErrorComponent: Error, | ||
}); | ||
|
||
declare module "@tanstack/react-router" { | ||
interface Register { | ||
router: typeof router; | ||
} | ||
} |