-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
158 additions
and
8 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,62 @@ | ||
import { FallbackProps } from "react-error-boundary"; | ||
import { Trans, useTranslation } from "react-i18next"; | ||
import { TwitterFeed } from "./TwitterFeed"; | ||
import { useRouteError } from "react-router-dom"; | ||
import { Button } from "@/shadcn/ui/button"; | ||
import { useAuth } from "@/hooks/useAuth"; | ||
|
||
export function ErrorFallback(props?: FallbackProps | {}) { | ||
const routeError = useRouteError() as Error | null; | ||
const { t } = useTranslation(); | ||
const { logout } = useAuth(); | ||
|
||
// @ts-ignore | ||
const error = routeError ?? (props?.error as Error | null); | ||
|
||
return ( | ||
<div className=" w-full h-full p-8 overflow-y-auto"> | ||
<div className="mx-auto w-full h-full max-w-screen-lg flex flex-col items-center gap-4"> | ||
<h2 className="font-bold text-3xl">{t("Gomenasorry!")}</h2> | ||
<p> | ||
<Trans> | ||
There was an error retrieving content, please check{" "} | ||
<a className="underline text-blue-500" href="https://x.com/holodex"> | ||
</a>{" "} | ||
or report an error through the{" "} | ||
<a | ||
className="underline text-blue-500" | ||
href="https://discord.gg/jctkgHBt4b" | ||
> | ||
Discord | ||
</a> | ||
. | ||
</Trans> | ||
</p> | ||
<div className="flex gap-4"> | ||
<Button size="lg" onClick={() => window.location.reload()}> | ||
{t("Reload")} | ||
</Button> | ||
<Button | ||
size="lg" | ||
variant="secondary" | ||
onClick={() => { | ||
logout(); | ||
window.localStorage.clear(); | ||
window.location.assign("/"); | ||
}} | ||
> | ||
{t("Logout / Clear cache")} | ||
</Button> | ||
</div> | ||
<code className="max-w-full px-2 py-0 shrink-0 bg-black/10 rounded-md text-sm whitespace-pre overflow-x-auto"> | ||
{error?.message} | ||
</code> | ||
<code className="max-w-full shrink-0 p-2 bg-black/10 rounded-md text-xs whitespace-pre overflow-x-auto"> | ||
{error?.stack} | ||
</code> | ||
<TwitterFeed className="flex justify-center w-[min(800px, calc(100vw - 40px))] h-[400px]" /> | ||
</div> | ||
</div> | ||
); | ||
} |
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,27 @@ | ||
import { DetailedHTMLProps, HTMLAttributes, useEffect, useRef } from "react"; | ||
import { useScript } from "usehooks-ts"; | ||
|
||
declare global { | ||
// eslint-disable-next-line | ||
var twttr: any; | ||
} | ||
|
||
const html = `<a class="twitter-timeline" data-dnt="true" data-height="400" data-width="${Math.min( | ||
window.innerWidth - 40, | ||
800, | ||
)}" href="https://twitter.com/holodex?ref_src=twsrc%5Etfw">Tweets by Holodex</a>`; | ||
|
||
export function TwitterFeed( | ||
props: DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, | ||
) { | ||
const ref = useRef<HTMLDivElement>(null); | ||
const status = useScript("https://platform.twitter.com/widgets.js"); | ||
|
||
useEffect(() => { | ||
if (status === "ready") window.twttr?.widgets.load(); | ||
}, [status]); | ||
|
||
return ( | ||
<div {...props} ref={ref} dangerouslySetInnerHTML={{ __html: html }} /> | ||
); | ||
} |
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