Removed redundant types

This commit is contained in:
Alejandro Celaya
2022-11-06 19:12:41 +01:00
parent 526d7195bc
commit ea199dbf8f
4 changed files with 13 additions and 20 deletions

View File

@@ -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<DeleteShortUrl>;
export type DeleteShortUrlAction = PayloadAction<ShortUrlIdentifier>;
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<DeleteShortUrl> => {
async ({ shortCode, domain }: ShortUrlIdentifier, { getState }): Promise<ShortUrlIdentifier> => {
const { deleteShortUrl: shlinkDeleteShortUrl } = buildShlinkApiClient(getState);
await shlinkDeleteShortUrl(shortCode, domain);
return { shortCode, domain };

View File

@@ -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;
}