This repository has been archived by the owner on May 11, 2021. It is now read-only.
-
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.
feat(auth): add fancy sign-in/sign-up errors
- Loading branch information
1 parent
7903b0a
commit bedcb9c
Showing
5 changed files
with
31 additions
and
4 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
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,7 @@ | ||
export const tryOr = <T>(calculate: () => T, or: T): T => { | ||
try { | ||
return calculate() | ||
} catch (e) { | ||
return or | ||
} | ||
} |
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,18 @@ | ||
import { Option } from 'tsoption' | ||
import { useEffect } from 'react' | ||
import { notification } from 'antd' | ||
|
||
export const useErrorAlert = ( | ||
error: Option<string>, | ||
customMessage?: string, | ||
) => { | ||
useEffect(() => { | ||
if (error.nonEmpty()) { | ||
const message = !!customMessage ? customMessage : error.get() | ||
|
||
notification.error({ | ||
message, | ||
}) | ||
} | ||
}, [error]) | ||
} |