mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-03-18 05:23:49 +00:00
Changed format on action types and reducer names for those already migrated to RTK
This commit is contained in:
@@ -5,7 +5,8 @@ import { ShlinkApiClientBuilder } from '../../api/services/ShlinkApiClientBuilde
|
||||
import { parseApiError } from '../../api/utils';
|
||||
import { ProblemDetailsError } from '../../api/types/errors';
|
||||
|
||||
export const CREATE_SHORT_URL = 'shlink/createShortUrl/CREATE_SHORT_URL';
|
||||
const REDUCER_PREFIX = 'shlink/shortUrlCreation';
|
||||
export const CREATE_SHORT_URL = `${REDUCER_PREFIX}/createShortUrl`;
|
||||
|
||||
export type ShortUrlCreation = {
|
||||
saving: false;
|
||||
@@ -45,7 +46,7 @@ export const createShortUrl = (buildShlinkApiClient: ShlinkApiClientBuilder) =>
|
||||
|
||||
export const shortUrlCreationReducerCreator = (createShortUrlThunk: ReturnType<typeof createShortUrl>) => {
|
||||
const { reducer, actions } = createSlice({
|
||||
name: 'shortUrlCreationReducer',
|
||||
name: REDUCER_PREFIX,
|
||||
initialState: initialState as ShortUrlCreation, // Without this casting it infers type ShortUrlCreationWaiting
|
||||
reducers: {
|
||||
resetCreateShortUrl: () => initialState,
|
||||
|
||||
@@ -5,7 +5,8 @@ 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';
|
||||
const REDUCER_PREFIX = 'shlink/shortUrlDeletion';
|
||||
export const SHORT_URL_DELETED = `${REDUCER_PREFIX}/deleteShortUrl`;
|
||||
|
||||
export interface ShortUrlDeletion {
|
||||
shortCode: string;
|
||||
@@ -35,7 +36,7 @@ export const shortUrlDeletionReducerCreator = (buildShlinkApiClient: ShlinkApiCl
|
||||
);
|
||||
|
||||
const { actions, reducer } = createSlice({
|
||||
name: 'shortUrlDeletion',
|
||||
name: REDUCER_PREFIX,
|
||||
initialState,
|
||||
reducers: {
|
||||
resetDeleteShortUrl: () => initialState,
|
||||
|
||||
@@ -6,7 +6,7 @@ import { shortUrlMatches } from '../helpers';
|
||||
import { parseApiError } from '../../api/utils';
|
||||
import { ProblemDetailsError } from '../../api/types/errors';
|
||||
|
||||
const GET_SHORT_URL_DETAIL = 'shlink/shortUrlDetail/GET_SHORT_URL_DETAIL';
|
||||
const REDUCER_PREFIX = 'shlink/shortUrlDetail';
|
||||
|
||||
export interface ShortUrlDetail {
|
||||
shortUrl?: ShortUrl;
|
||||
@@ -24,7 +24,7 @@ const initialState: ShortUrlDetail = {
|
||||
|
||||
export const shortUrlDetailReducerCreator = (buildShlinkApiClient: ShlinkApiClientBuilder) => {
|
||||
const getShortUrlDetail = createAsyncThunk(
|
||||
GET_SHORT_URL_DETAIL,
|
||||
`${REDUCER_PREFIX}/getShortUrlDetail`,
|
||||
async ({ shortCode, domain }: ShortUrlIdentifier, { getState }): Promise<ShortUrl> => {
|
||||
const { shortUrlsList } = getState();
|
||||
const alreadyLoaded = shortUrlsList?.shortUrls?.data.find((url) => shortUrlMatches(url, shortCode, domain));
|
||||
@@ -34,7 +34,7 @@ export const shortUrlDetailReducerCreator = (buildShlinkApiClient: ShlinkApiClie
|
||||
);
|
||||
|
||||
const { reducer } = createSlice({
|
||||
name: 'shortUrlDetailReducer',
|
||||
name: REDUCER_PREFIX,
|
||||
initialState,
|
||||
reducers: {},
|
||||
extraReducers: (builder) => {
|
||||
|
||||
@@ -5,7 +5,8 @@ import { ShlinkApiClientBuilder } from '../../api/services/ShlinkApiClientBuilde
|
||||
import { parseApiError } from '../../api/utils';
|
||||
import { ProblemDetailsError } from '../../api/types/errors';
|
||||
|
||||
export const SHORT_URL_EDITED = 'shlink/shortUrlEdition/SHORT_URL_EDITED';
|
||||
const REDUCER_PREFIX = 'shlink/shortUrlEdition';
|
||||
export const SHORT_URL_EDITED = `${REDUCER_PREFIX}/editShortUrl`;
|
||||
|
||||
export interface ShortUrlEdition {
|
||||
shortUrl?: ShortUrl;
|
||||
@@ -37,7 +38,7 @@ export const shortUrlEditionReducerCreator = (buildShlinkApiClient: ShlinkApiCli
|
||||
);
|
||||
|
||||
const { reducer } = createSlice({
|
||||
name: 'shortUrlEditionReducer',
|
||||
name: REDUCER_PREFIX,
|
||||
initialState,
|
||||
reducers: {},
|
||||
extraReducers: (builder) => {
|
||||
|
||||
Reference in New Issue
Block a user