mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-04-20 05:26:20 +00:00
Move more components to shlink-web-component when applicable
This commit is contained in:
18
shlink-web-component/common/ShlinkApiError.tsx
Normal file
18
shlink-web-component/common/ShlinkApiError.tsx
Normal file
@@ -0,0 +1,18 @@
|
||||
import type { ProblemDetailsError } from '../api-contract';
|
||||
import { isInvalidArgumentError } from '../api-contract/utils';
|
||||
|
||||
export interface ShlinkApiErrorProps {
|
||||
errorData?: ProblemDetailsError;
|
||||
fallbackMessage?: string;
|
||||
}
|
||||
|
||||
export const ShlinkApiError = ({ errorData, fallbackMessage }: ShlinkApiErrorProps) => (
|
||||
<>
|
||||
{errorData?.detail ?? fallbackMessage}
|
||||
{isInvalidArgumentError(errorData) && (
|
||||
<p className="mb-0">
|
||||
Invalid elements: [{errorData.invalidElements.join(', ')}]
|
||||
</p>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
Reference in New Issue
Block a user