-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1661 from ten-protocol/jennifer/scan-updates
Jennifer/scan updates
- Loading branch information
Showing
27 changed files
with
839 additions
and
60 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,38 @@ | ||
import { ErrorType } from "@/src/types/interfaces"; | ||
import Error from "./_error"; | ||
|
||
export function Custom404Error({ | ||
customPageTitle, | ||
showRedirectText, | ||
redirectText, | ||
isFullWidth, | ||
message, | ||
showMessage = true, | ||
redirectLink, | ||
children, | ||
}: ErrorType) { | ||
return ( | ||
<Error | ||
heading={` ${customPageTitle || "Oops! Page"} Not Found`} | ||
statusText={`We can't seem to find the ${ | ||
customPageTitle || "page" | ||
} you're looking for.`} | ||
statusCode={404} | ||
showRedirectText={showRedirectText} | ||
redirectText={redirectText || "Home Page"} | ||
message={ | ||
message || | ||
`The ${ | ||
customPageTitle || "page" | ||
} you are looking for might have been removed, had its name changed, or is temporarily unavailable.` | ||
} | ||
isFullWidth={isFullWidth} | ||
showMessage={showMessage} | ||
redirectLink={redirectLink} | ||
> | ||
{children} | ||
</Error> | ||
); | ||
} | ||
|
||
export default Custom404Error; |
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,32 @@ | ||
import { ErrorType } from "@/src/types/interfaces"; | ||
import Error from "./_error"; | ||
|
||
function Custom500Error({ | ||
customPageTitle, | ||
message, | ||
showRedirectText, | ||
redirectText, | ||
err, | ||
redirectLink, | ||
children, | ||
}: ErrorType) { | ||
return ( | ||
<Error | ||
heading={"Oops! Something went wrong."} | ||
message={ | ||
message || | ||
"We're experiencing technical difficulties. Please try again later." | ||
} | ||
statusText={customPageTitle || `An Error occured`} | ||
statusCode={500} | ||
showRedirectText={showRedirectText || true} | ||
redirectText={redirectText || "Home Page"} | ||
err={err} | ||
redirectLink={redirectLink} | ||
> | ||
{children} | ||
</Error> | ||
); | ||
} | ||
|
||
export default Custom500Error; |
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,91 @@ | ||
import React from "react"; | ||
import NextErrorComponent from "next/error"; | ||
import Link from "next/link"; | ||
import Image from "next/image"; | ||
import { ErrorType } from "@/src/types/interfaces"; | ||
|
||
function ErrorMessage({ | ||
statusText, | ||
message, | ||
showMessage, | ||
showStatusText, | ||
}: any) { | ||
return ( | ||
<div className="error-message"> | ||
{showStatusText && <h3>{statusText}</h3>} | ||
{message && showMessage && ( | ||
<p className="text-muted-foreground">{message}</p> | ||
)} | ||
</div> | ||
); | ||
} | ||
|
||
export function CustomError({ | ||
showRedirectText = true, | ||
heading = "Oops! Something went wrong.", | ||
statusText = "500", | ||
message = "We're experiencing technical difficulties. Please try again later.", | ||
redirectText = "Home Page", | ||
isFullWidth, | ||
err, | ||
showMessage = true, | ||
showStatusText, | ||
statusCode, | ||
isModal, | ||
redirectLink = "/", | ||
children, | ||
...props | ||
}: ErrorType) { | ||
return ( | ||
<section | ||
className="h-full flex flex-col justify-center items-center" | ||
{...props} | ||
> | ||
<main className={isFullWidth ? "max-w-full" : ""}> | ||
<div className="text-center"> | ||
<h1 className="text-4xl font-extrabold mb-6">{heading}</h1> | ||
<div className={isFullWidth ? "w-full" : ""}> | ||
<ErrorMessage | ||
showStatusText={showStatusText} | ||
showMessage={showMessage} | ||
message={message} | ||
statusText={statusText} | ||
/> | ||
</div> | ||
{showRedirectText && ( | ||
<div> | ||
Go to{" "} | ||
<Link | ||
href={redirectLink} | ||
passHref | ||
className="text-primary pointer underline" | ||
> | ||
{redirectText} | ||
</Link>{" "} | ||
{/* <div> | ||
Looks like you're on the wrong side of town, buddy. | ||
Let's get you back on the <Link href="/">right side</Link>. | ||
</div> */} | ||
</div> | ||
)} | ||
{children} | ||
</div> | ||
</main> | ||
</section> | ||
); | ||
} | ||
|
||
CustomError.getInitialProps = async ({ res, err }: any) => { | ||
const statusCode = res ? res.statusCode : err?.statusCode || 404; | ||
const errorInitialProps = await NextErrorComponent.getInitialProps({ | ||
res, | ||
err, | ||
} as any); | ||
errorInitialProps.statusCode = statusCode; | ||
|
||
return statusCode < 500 | ||
? errorInitialProps | ||
: { ...errorInitialProps, statusCode }; | ||
}; | ||
|
||
export default CustomError; |
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
Oops, something went wrong.