More components migrated to TS

This commit is contained in:
Alejandro Celaya
2020-08-26 20:03:23 +02:00
parent 1b03d04318
commit b19bbee7fc
11 changed files with 98 additions and 88 deletions

View File

@@ -3,6 +3,7 @@ import { Action, Dispatch } from 'redux';
import { buildReducer } from '../../utils/helpers/redux';
import { ShlinkApiClientBuilder } from '../../utils/services/types';
import { GetState } from '../../container/types';
import { OptionalString } from '../../utils/utils';
/* eslint-disable padding-line-between-statements */
export const EDIT_SHORT_URL_START = 'shlink/shortUrlEdition/EDIT_SHORT_URL_START';
@@ -28,7 +29,7 @@ export interface ShortUrlEdition {
export interface ShortUrlEditedAction extends Action<string> {
shortCode: string;
longUrl: string;
domain: string | undefined | null;
domain: OptionalString;
}
const initialState: ShortUrlEdition = {
@@ -46,7 +47,7 @@ export default buildReducer<ShortUrlEdition, ShortUrlEditedAction>({
export const editShortUrl = (buildShlinkApiClient: ShlinkApiClientBuilder) => (
shortCode: string,
domain: string | undefined | null,
domain: OptionalString,
longUrl: string,
) => async (dispatch: Dispatch, getState: GetState) => {
dispatch({ type: EDIT_SHORT_URL_START });

View File

@@ -4,6 +4,7 @@ import { ShortUrlMeta } from '../data';
import { ShlinkApiClientBuilder } from '../../utils/services/types';
import { GetState } from '../../container/types';
import { buildActionCreator, buildReducer } from '../../utils/helpers/redux';
import { OptionalString } from '../../utils/utils';
/* eslint-disable padding-line-between-statements */
export const EDIT_SHORT_URL_META_START = 'shlink/shortUrlMeta/EDIT_SHORT_URL_META_START';
@@ -19,14 +20,6 @@ export const shortUrlMetaType = PropTypes.shape({
maxVisits: PropTypes.number,
});
/** @deprecated Use ShortUrlMetaEdition interface instead */
export const shortUrlEditMetaType = PropTypes.shape({
shortCode: PropTypes.string,
meta: shortUrlMetaType.isRequired,
saving: PropTypes.bool.isRequired,
error: PropTypes.bool.isRequired,
});
export interface ShortUrlMetaEdition {
shortCode: string | null;
meta: ShortUrlMeta;
@@ -56,7 +49,7 @@ export default buildReducer<ShortUrlMetaEdition, ShortUrlMetaEditedAction>({
export const editShortUrlMeta = (buildShlinkApiClient: ShlinkApiClientBuilder) => (
shortCode: string,
domain: string | null | undefined,
domain: OptionalString,
meta: ShortUrlMeta,
) => async (dispatch: Dispatch, getState: GetState) => {
dispatch({ type: EDIT_SHORT_URL_META_START });

View File

@@ -3,6 +3,7 @@ import { Action, Dispatch } from 'redux';
import { buildActionCreator, buildReducer } from '../../utils/helpers/redux';
import { ShlinkApiClientBuilder } from '../../utils/services/types';
import { GetState } from '../../container/types';
import { OptionalString } from '../../utils/utils';
/* eslint-disable padding-line-between-statements */
export const EDIT_SHORT_URL_TAGS_START = 'shlink/shortUrlTags/EDIT_SHORT_URL_TAGS_START';
@@ -29,7 +30,7 @@ export interface ShortUrlTags {
export interface EditShortUrlTagsAction extends Action<string> {
shortCode: string;
tags: string[];
domain: string | null | undefined;
domain: OptionalString;
}
const initialState: ShortUrlTags = {
@@ -48,7 +49,7 @@ export default buildReducer<ShortUrlTags, EditShortUrlTagsAction>({
export const editShortUrlTags = (buildShlinkApiClient: ShlinkApiClientBuilder) => (
shortCode: string,
domain: string | null | undefined,
domain: OptionalString,
tags: string[],
) => async (dispatch: Dispatch, getState: GetState) => {
dispatch({ type: EDIT_SHORT_URL_TAGS_START });