mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-04-20 13:36:20 +00:00
Migrated tagVisits reducer to RTK
This commit is contained in:
@@ -1,22 +1,6 @@
|
||||
import { createAsyncThunk as baseCreateAsyncThunk, AsyncThunkPayloadCreator } from '@reduxjs/toolkit';
|
||||
import { Action } from 'redux';
|
||||
import { ShlinkState } from '../../container/types';
|
||||
|
||||
type ActionHandler<State, AT> = (currentState: State, action: AT) => State;
|
||||
type ActionHandlerMap<State, AT> = Record<string, ActionHandler<State, AT>>;
|
||||
|
||||
/** @deprecated */
|
||||
export const buildReducer = <State, AT extends Action>(map: ActionHandlerMap<State, AT>, initialState: State) => (
|
||||
state: State | undefined,
|
||||
action: AT,
|
||||
): State => {
|
||||
const { type } = action;
|
||||
const actionHandler = map[type];
|
||||
const currentState = state ?? initialState;
|
||||
|
||||
return actionHandler ? actionHandler(currentState, action) : currentState;
|
||||
};
|
||||
|
||||
export const createAsyncThunk = <Returned, ThunkArg>(
|
||||
typePrefix: string,
|
||||
payloadCreator: AsyncThunkPayloadCreator<Returned, ThunkArg, { state: ShlinkState }>,
|
||||
|
||||
@@ -21,10 +21,6 @@ type Optional<T> = T | null | undefined;
|
||||
|
||||
export type OptionalString = Optional<string>;
|
||||
|
||||
export type RecursivePartial<T> = {
|
||||
[P in keyof T]?: RecursivePartial<T[P]>;
|
||||
};
|
||||
|
||||
export const nonEmptyValueOrNull = <T>(value: T): T | null => (isEmpty(value) ? null : value);
|
||||
|
||||
export const capitalize = <T extends string>(value: T): string => `${value.charAt(0).toUpperCase()}${value.slice(1)}`;
|
||||
|
||||
Reference in New Issue
Block a user