shlink-web-client/src/api/ShlinkApiError.tsx

17 lines
486 B
TypeScript
Raw Normal View History

import { ProblemDetailsError } from './types';
import { isInvalidArgumentError } from './utils';
2020-12-22 12:05:32 +03:00
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>
}
</>
);