mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-07-19 18:21:54 +00:00
Created component holding the logic to render Shlink API errors
This commit is contained in:
15
src/api/ShlinkApiError.tsx
Normal file
15
src/api/ShlinkApiError.tsx
Normal file
@@ -0,0 +1,15 @@
|
||||
import { isInvalidArgumentError, ProblemDetailsError } from '../utils/services/types';
|
||||
|
||||
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