-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ui): handle request error in admin panel (#3589)
* fix(ui): handle rate limit error * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
- Loading branch information
Showing
4 changed files
with
77 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
'use client' | ||
|
||
import { ReactNode } from 'react' | ||
|
||
import { cn } from '@/lib/utils' | ||
import { Button } from '@/components/ui/button' | ||
|
||
export function ErrorView({ | ||
title, | ||
description, | ||
className, | ||
children, | ||
statusText, | ||
hideChildren | ||
}: { | ||
title?: string | ||
description?: string | ||
className?: string | ||
hideChildren?: boolean | ||
children?: ReactNode | ||
statusText?: string | ||
}) { | ||
let defaultTitle = 'Something went wrong' | ||
let defaultDescription = 'Oops! Please try again later.' | ||
let displayTitle = '' | ||
let displayDescription = description || defaultDescription | ||
|
||
switch (statusText) { | ||
case 'Too Many Requests': | ||
displayTitle = 'Too Many Requests' | ||
break | ||
case 'Bad Request': | ||
displayTitle = 'Bad Request' | ||
break | ||
default: | ||
displayTitle = title || defaultTitle | ||
} | ||
|
||
return ( | ||
<div className={cn('mx-auto mt-8 max-w-md text-center', className)}> | ||
<h1 className="text-2xl font-bold tracking-tight text-foreground sm:text-3xl"> | ||
{displayTitle} | ||
</h1> | ||
{!!displayDescription && ( | ||
<p className="mt-4 text-muted-foreground">{displayDescription}</p> | ||
)} | ||
{!hideChildren && ( | ||
<div> | ||
{children ? ( | ||
children | ||
) : ( | ||
<Button | ||
className={cn('mt-6')} | ||
onClick={e => window.location.reload()} | ||
> | ||
Refresh | ||
</Button> | ||
)} | ||
</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
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