From ea199dbf8f33e24060a5c7a713f4638efb4bf2dd Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 6 Nov 2022 19:12:41 +0100 Subject: [PATCH] Removed redundant types --- src/short-urls/data/index.ts | 10 +++++----- src/short-urls/helpers/DeleteShortUrlModal.tsx | 6 +++--- src/short-urls/reducers/shortUrlDeletion.ts | 10 +++------- src/short-urls/reducers/shortUrlEdition.ts | 7 ++----- 4 files changed, 13 insertions(+), 20 deletions(-) diff --git a/src/short-urls/data/index.ts b/src/short-urls/data/index.ts index 3c17a812..88f5b22b 100644 --- a/src/short-urls/data/index.ts +++ b/src/short-urls/data/index.ts @@ -21,6 +21,11 @@ export interface ShortUrlData extends EditShortUrlData { findIfExists?: boolean; } +export interface ShortUrlIdentifier { + shortCode: string; + domain?: OptionalString; +} + export interface ShortUrl { shortCode: string; shortUrl: string; @@ -47,11 +52,6 @@ export interface ShortUrlModalProps { toggle: () => void; } -export interface ShortUrlIdentifier { - shortCode: string; - domain: OptionalString; -} - export const SHORT_URLS_ORDERABLE_FIELDS = { dateCreated: 'Created at', shortCode: 'Short URL', diff --git a/src/short-urls/helpers/DeleteShortUrlModal.tsx b/src/short-urls/helpers/DeleteShortUrlModal.tsx index 06caab5e..d240279f 100644 --- a/src/short-urls/helpers/DeleteShortUrlModal.tsx +++ b/src/short-urls/helpers/DeleteShortUrlModal.tsx @@ -1,8 +1,8 @@ import { useEffect, useState } from 'react'; import { Modal, ModalBody, ModalFooter, ModalHeader } from 'reactstrap'; import { pipe } from 'ramda'; -import { DeleteShortUrl, ShortUrlDeletion } from '../reducers/shortUrlDeletion'; -import { ShortUrlModalProps } from '../data'; +import { ShortUrlDeletion } from '../reducers/shortUrlDeletion'; +import { ShortUrlIdentifier, ShortUrlModalProps } from '../data'; import { handleEventPreventingDefault } from '../../utils/utils'; import { Result } from '../../utils/Result'; import { isInvalidDeletionError } from '../../api/utils'; @@ -10,7 +10,7 @@ import { ShlinkApiError } from '../../api/ShlinkApiError'; interface DeleteShortUrlModalConnectProps extends ShortUrlModalProps { shortUrlDeletion: ShortUrlDeletion; - deleteShortUrl: (shortUrl: DeleteShortUrl) => void; + deleteShortUrl: (shortUrl: ShortUrlIdentifier) => void; resetDeleteShortUrl: () => void; } diff --git a/src/short-urls/reducers/shortUrlDeletion.ts b/src/short-urls/reducers/shortUrlDeletion.ts index 87fceed9..9af657b8 100644 --- a/src/short-urls/reducers/shortUrlDeletion.ts +++ b/src/short-urls/reducers/shortUrlDeletion.ts @@ -3,6 +3,7 @@ import { createAsyncThunk } from '../../utils/helpers/redux'; import { ShlinkApiClientBuilder } from '../../api/services/ShlinkApiClientBuilder'; import { parseApiError } from '../../api/utils'; import { ProblemDetailsError } from '../../api/types/errors'; +import { ShortUrlIdentifier } from '../data'; export const SHORT_URL_DELETED = 'shlink/deleteShortUrl/SHORT_URL_DELETED'; @@ -14,12 +15,7 @@ export interface ShortUrlDeletion { errorData?: ProblemDetailsError; } -export interface DeleteShortUrl { - shortCode: string; - domain?: string | null; -} - -export type DeleteShortUrlAction = PayloadAction; +export type DeleteShortUrlAction = PayloadAction; const initialState: ShortUrlDeletion = { shortCode: '', @@ -31,7 +27,7 @@ const initialState: ShortUrlDeletion = { export const shortUrlDeletionReducerCreator = (buildShlinkApiClient: ShlinkApiClientBuilder) => { const deleteShortUrl = createAsyncThunk( SHORT_URL_DELETED, - async ({ shortCode, domain }: DeleteShortUrl, { getState }): Promise => { + async ({ shortCode, domain }: ShortUrlIdentifier, { getState }): Promise => { const { deleteShortUrl: shlinkDeleteShortUrl } = buildShlinkApiClient(getState); await shlinkDeleteShortUrl(shortCode, domain); return { shortCode, domain }; diff --git a/src/short-urls/reducers/shortUrlEdition.ts b/src/short-urls/reducers/shortUrlEdition.ts index 462515ca..267d9b23 100644 --- a/src/short-urls/reducers/shortUrlEdition.ts +++ b/src/short-urls/reducers/shortUrlEdition.ts @@ -1,7 +1,6 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit'; import { createAsyncThunk } from '../../utils/helpers/redux'; -import { OptionalString } from '../../utils/utils'; -import { EditShortUrlData, ShortUrl } from '../data'; +import { EditShortUrlData, ShortUrl, ShortUrlIdentifier } from '../data'; import { ShlinkApiClientBuilder } from '../../api/services/ShlinkApiClientBuilder'; import { parseApiError } from '../../api/utils'; import { ProblemDetailsError } from '../../api/types/errors'; @@ -16,9 +15,7 @@ export interface ShortUrlEdition { errorData?: ProblemDetailsError; } -export interface EditShortUrl { - shortCode: string; - domain?: OptionalString; +export interface EditShortUrl extends ShortUrlIdentifier { data: EditShortUrlData; }