-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(auth): improve error handling (#386)
- Loading branch information
Showing
17 changed files
with
191 additions
and
37 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
41 changes: 41 additions & 0 deletions
41
packages/app-builder/src/components/Auth/PopupBlockedError.tsx
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,41 @@ | ||
import { getCurrentBrowser } from '@app-builder/utils/browser'; | ||
import { Trans, useTranslation } from 'react-i18next'; | ||
|
||
export function PopupBlockedError() { | ||
const { t } = useTranslation(['common']); | ||
return ( | ||
<div> | ||
<Trans | ||
t={t} | ||
i18nKey="common:errors.popup_blocked_by_client" | ||
components={{ | ||
EnablePopup: <EnablePopup />, | ||
}} | ||
/> | ||
</div> | ||
); | ||
} | ||
|
||
const hrefMap = { | ||
Safari: 'https://support.apple.com/guide/safari/sfri40696/mac', | ||
Firefox: | ||
'https://support.mozilla.org/en-US/kb/pop-blocker-settings-exceptions-troubleshooting', | ||
Chrome: 'https://support.google.com/chrome/answer/95472', | ||
}; | ||
|
||
function EnablePopup({ children }: { children?: React.ReactNode }) { | ||
const browser = getCurrentBrowser(navigator.userAgent); | ||
if (browser in hrefMap) { | ||
return ( | ||
<a | ||
href={hrefMap[browser as keyof typeof hrefMap]} | ||
target="_blank" | ||
rel="noreferrer noopener" | ||
className="text-purple-100 hover:underline" | ||
> | ||
{children} | ||
</a> | ||
); | ||
} | ||
return <span>{children}</span>; | ||
} |
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
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
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.