mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-07-22 11:41:52 +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 }>,
|
||||
|
||||
Reference in New Issue
Block a user