mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-08-02 09:01:52 +00:00
Created component holding the logic to render Shlink API errors
This commit is contained in:
@@ -6,6 +6,7 @@ import { ShortUrlModalProps } from '../data';
|
||||
import { handleEventPreventingDefault, OptionalString } from '../../utils/utils';
|
||||
import { Result } from '../../utils/Result';
|
||||
import { isInvalidDeletionError } from '../../utils/services/types';
|
||||
import { ShlinkApiError } from '../../api/ShlinkApiError';
|
||||
|
||||
interface DeleteShortUrlModalConnectProps extends ShortUrlModalProps {
|
||||
shortUrlDeletion: ShortUrlDeletion;
|
||||
@@ -49,15 +50,9 @@ const DeleteShortUrlModal = (
|
||||
onChange={(e) => setInputValue(e.target.value)}
|
||||
/>
|
||||
|
||||
{error && isInvalidDeletionError(errorData) && (
|
||||
<Result type="warning" small className="mt-2">
|
||||
{errorData.threshold && `This short URL has received more than ${errorData.threshold} visits, and therefore, it cannot be deleted.`}
|
||||
{!errorData.threshold && 'This short URL has received too many visits, and therefore, it cannot be deleted.'}
|
||||
</Result>
|
||||
)}
|
||||
{error && !isInvalidDeletionError(errorData) && (
|
||||
<Result type="error" small className="mt-2">
|
||||
{errorData?.detail ?? 'Something went wrong while deleting the URL :('}
|
||||
{error && (
|
||||
<Result type={isInvalidDeletionError(errorData) ? 'warning' : 'error'} small className="mt-2">
|
||||
<ShlinkApiError errorData={errorData} fallbackMessage="Something went wrong while deleting the URL :(" />
|
||||
</Result>
|
||||
)}
|
||||
</ModalBody>
|
||||
|
||||
Reference in New Issue
Block a user