forked from JumboCode/TheLegacyProject
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add error handling UI * Update redirect message * Update boundary
- Loading branch information
1 parent
06e5c8a
commit 31eba0b
Showing
9 changed files
with
141 additions
and
13 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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
"use client"; | ||
|
||
import { ErrorNavigation } from "@components/navigation"; | ||
|
||
const Error = () => { | ||
return ( | ||
<ErrorNavigation | ||
message="Oops, an error has occurred." | ||
redirectTo="/private/admin/home/chapters" | ||
redirectMessage="View all chapters" | ||
/> | ||
); | ||
}; | ||
|
||
export default Error; |
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,15 @@ | ||
"use client"; | ||
|
||
import { ErrorNavigation } from "@components/navigation"; | ||
|
||
const Error = () => { | ||
return ( | ||
<ErrorNavigation | ||
message="Oops, an error has occurred." | ||
redirectTo="/private/chapter-leader/seniors" | ||
redirectMessage="View all seniors" | ||
/> | ||
); | ||
}; | ||
|
||
export default Error; |
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,15 @@ | ||
"use client"; | ||
|
||
import { ErrorNavigation } from "@components/navigation"; | ||
|
||
const Error = () => { | ||
return ( | ||
<ErrorNavigation | ||
message="Oops, an error has occurred." | ||
redirectTo="/private/chapter-leader/users" | ||
redirectMessage="View all users" | ||
/> | ||
); | ||
}; | ||
|
||
export default Error; |
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,14 @@ | ||
"use client"; | ||
|
||
import { ErrorNavigation } from "@components/navigation"; | ||
|
||
const Error = () => { | ||
return ( | ||
<ErrorNavigation | ||
message="Oops, an error has occurred." | ||
redirectMessage="Back to home" | ||
/> | ||
); | ||
}; | ||
|
||
export default Error; |
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,15 @@ | ||
"use client"; | ||
|
||
import { ErrorNavigation } from "@components/navigation"; | ||
|
||
const Error = () => { | ||
return ( | ||
<ErrorNavigation | ||
message="Oops, an error has occurred." | ||
redirectTo="/private/user/seniors" | ||
redirectMessage="View all seniors" | ||
/> | ||
); | ||
}; | ||
|
||
export default Error; |
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,42 @@ | ||
"use client"; | ||
|
||
import { Popup } from "@components/container"; | ||
import { UserContext } from "@context/UserProvider"; | ||
import { formatUserHomeRoute } from "@utils"; | ||
import { useRouter } from "next/navigation"; | ||
import React from "react"; | ||
|
||
interface ErrorNavigationProps { | ||
message?: string; | ||
redirectTo?: string; | ||
redirectMessage?: string; | ||
} | ||
|
||
const ErrorNavigation = ({ | ||
message, | ||
redirectTo, | ||
redirectMessage, | ||
}: ErrorNavigationProps) => { | ||
const router = useRouter(); | ||
const userContext = React.useContext(UserContext); | ||
|
||
return ( | ||
<Popup> | ||
<div className="text-wrap flex h-full w-full flex-col items-center justify-center gap-y-6"> | ||
<h1 className="text-lg text-white sm:text-xl"> | ||
{message ?? "Oops, an error has occurred."} | ||
</h1> | ||
<button | ||
className="mx-1 w-fit rounded bg-white p-3 text-lg text-dark-teal drop-shadow-md" | ||
onClick={() => | ||
router.replace(redirectTo ?? formatUserHomeRoute(userContext.user)) | ||
} | ||
> | ||
{redirectMessage ?? "Redirect"} | ||
</button> | ||
</div> | ||
</Popup> | ||
); | ||
}; | ||
|
||
export default ErrorNavigation; |
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
export { default as RootNavigation } from "./RootNavigation"; | ||
export { default as ErrorNavigation } from "./ErrorNavigation"; |