mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2024-12-24 01:48:18 +03:00
18 lines
532 B
TypeScript
18 lines
532 B
TypeScript
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>
|
|
)}
|
|
</>
|
|
);
|