-
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.
- Loading branch information
1 parent
dcadd43
commit 28d9958
Showing
8 changed files
with
63 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Alert, AlertDescription, AlertIcon, AlertTitle, VStack } from '@chakra-ui/react'; | ||
import { ApiError } from '../types/apiError.ts'; | ||
|
||
export const ErrorDisplay = ({ error }: { error: ApiError }) => { | ||
return ( | ||
<Alert status="error"> | ||
<AlertIcon /> | ||
<VStack alignItems="start" spacing={0}> | ||
<AlertTitle>{error?.title || 'Something went wrong'}</AlertTitle> | ||
{error?.detail ? ( | ||
<AlertDescription>{error.detail}</AlertDescription> | ||
) : !!error?.errors ? ( | ||
Object.keys(error.errors).map((key) => { | ||
const errors = error.errors![key]; | ||
return errors.map((error) => <AlertDescription>{error}</AlertDescription>); | ||
}) | ||
) : null} | ||
</VStack> | ||
</Alert> | ||
); | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export type ApiError = { | ||
status: number; | ||
detail: string | undefined; | ||
title: string; | ||
type: string; | ||
errors: Record<string, string[]> | undefined; | ||
}; |