Extracted short-url related services to its own service provider

This commit is contained in:
Alejandro Celaya
2018-12-18 19:59:50 +01:00
parent cf1239cf6e
commit 4b1f5e9f4c
16 changed files with 94 additions and 121 deletions

View File

@@ -1,6 +1,4 @@
import { curry } from 'ramda';
import PropTypes from 'prop-types';
import { buildShlinkApiClientWithAxios as buildShlinkApiClient } from '../../api/ShlinkApiClientBuilder';
/* eslint-disable padding-line-between-statements, newline-after-var */
export const CREATE_SHORT_URL_START = 'shlink/createShortUrl/CREATE_SHORT_URL_START';
@@ -50,7 +48,7 @@ export default function reducer(state = defaultState, action) {
}
}
export const _createShortUrl = (buildShlinkApiClient, data) => async (dispatch, getState) => {
export const createShortUrl = (buildShlinkApiClient) => (data) => async (dispatch, getState) => {
dispatch({ type: CREATE_SHORT_URL_START });
const { selectedServer } = getState();
@@ -65,6 +63,4 @@ export const _createShortUrl = (buildShlinkApiClient, data) => async (dispatch,
}
};
export const createShortUrl = curry(_createShortUrl)(buildShlinkApiClient);
export const resetCreateShortUrl = () => ({ type: RESET_CREATE_SHORT_URL });

View File

@@ -1,6 +1,4 @@
import { curry } from 'ramda';
import PropTypes from 'prop-types';
import { buildShlinkApiClientWithAxios as buildShlinkApiClient } from '../../api/ShlinkApiClientBuilder';
/* eslint-disable padding-line-between-statements, newline-after-var */
const DELETE_SHORT_URL_START = 'shlink/deleteShortUrl/DELETE_SHORT_URL_START';
@@ -56,7 +54,7 @@ export default function reducer(state = defaultState, action) {
}
}
export const _deleteShortUrl = (buildShlinkApiClient, shortCode) => async (dispatch, getState) => {
export const deleteShortUrl = (buildShlinkApiClient) => (shortCode) => async (dispatch, getState) => {
dispatch({ type: DELETE_SHORT_URL_START });
const { selectedServer } = getState();
@@ -72,8 +70,6 @@ export const _deleteShortUrl = (buildShlinkApiClient, shortCode) => async (dispa
}
};
export const deleteShortUrl = curry(_deleteShortUrl)(buildShlinkApiClient);
export const resetDeleteShortUrl = () => ({ type: RESET_DELETE_SHORT_URL });
export const shortUrlDeleted = (shortCode) => ({ type: SHORT_URL_DELETED, shortCode });