-
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.
Fixed spelling issues, button oveflow, link text beeing too long, and…
… added error handling for auth error
- Loading branch information
Showing
8 changed files
with
95 additions
and
18 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,61 @@ | ||
import React, { useEffect } from 'react'; | ||
|
||
import { useRouter } from 'next/router'; | ||
import styled from 'styled-components'; | ||
|
||
interface Props { | ||
error: string | string[] | undefined; | ||
} | ||
|
||
// Thanks to https://simplernerd.com/next-auth-custom-error-page/ | ||
// For the below error messages for next-auth I have modified the OAuthAccountNotLinked message | ||
type ErrorTypes = { | ||
[key: string]: string; | ||
}; | ||
|
||
const possibleErrors: ErrorTypes = { | ||
Signin: 'Try signing with a different account.', | ||
OAuthSignin: 'Try signing with a different account.', | ||
OAuthCallback: 'Try signing with a different account.', | ||
OAuthCreateAccount: 'Try signing with a different account.', | ||
EmailCreateAccount: 'Try signing with a different account.', | ||
Callback: 'Try signing with a different account.', | ||
OAuthAccountNotLinked: | ||
'Looks like we have seen you before! Sign in using the same method you used this email to sign in with before. You are likely trying to sign using a email that already has a magic link sent to it :)', | ||
EmailSignin: 'Check your email address.', | ||
CredentialsSignin: | ||
'Sign in failed. Check the details you provided are correct.', | ||
default: 'Unable to sign in.', | ||
}; | ||
|
||
export const ErrorMessage: React.FC<Props> = ({ error }) => { | ||
const router = useRouter(); | ||
|
||
useEffect(() => { | ||
return () => { | ||
router.push( | ||
{ | ||
pathname: '/', | ||
query: null, | ||
}, | ||
undefined, | ||
{ shallow: true } | ||
); | ||
}; | ||
}, [router]); | ||
|
||
const errorMessage = | ||
error && (possibleErrors[error as string] ?? possibleErrors.default); | ||
|
||
return <Wrapper>{errorMessage}</Wrapper>; | ||
}; | ||
|
||
const Wrapper = styled.div` | ||
width: 100%; | ||
padding: 6px; | ||
color: ${(p) => p.theme.COLORS.white}; | ||
background-color: ${(p) => p.theme.COLORS.warning}; | ||
border-radius: 3px; | ||
margin: 16px 0px; | ||
font-size: ${14 / 16}rem; | ||
`; |
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 |
---|---|---|
@@ -1,15 +1,6 @@ | ||
module.exports = { | ||
reactStrictMode: true, | ||
images: { | ||
domains: ["avatars.githubusercontent.com"], | ||
domains: ['avatars.githubusercontent.com'], | ||
}, | ||
// async redirects() { | ||
// return [ | ||
// { | ||
// source: "/redirect", | ||
// destination: "/redirect/asd", | ||
// permanent: true, | ||
// }, | ||
// ]; | ||
// }, | ||
}; |
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
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,3 @@ | ||
export const cropLongText = (text: string, maxLength: number): string => { | ||
return text.length > maxLength ? text.substring(0, maxLength) + '...' : text; | ||
} |
97b5fea
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.
Successfully deployed to the following URLs: