mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-08-02 09:01:52 +00:00
Simplified ShlinkApiClient and moved runtime creation logic to external service
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { curry } from 'ramda';
|
||||
import PropTypes from 'prop-types';
|
||||
import shlinkApiClient from '../../api/ShlinkApiClient';
|
||||
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,9 +50,12 @@ export default function reducer(state = defaultState, action) {
|
||||
}
|
||||
}
|
||||
|
||||
export const _createShortUrl = (shlinkApiClient, data) => async (dispatch) => {
|
||||
export const _createShortUrl = (buildShlinkApiClient, data) => async (dispatch, getState) => {
|
||||
dispatch({ type: CREATE_SHORT_URL_START });
|
||||
|
||||
const { selectedServer } = getState();
|
||||
const shlinkApiClient = buildShlinkApiClient(selectedServer);
|
||||
|
||||
try {
|
||||
const result = await shlinkApiClient.createShortUrl(data);
|
||||
|
||||
@@ -62,6 +65,6 @@ export const _createShortUrl = (shlinkApiClient, data) => async (dispatch) => {
|
||||
}
|
||||
};
|
||||
|
||||
export const createShortUrl = curry(_createShortUrl)(shlinkApiClient);
|
||||
export const createShortUrl = curry(_createShortUrl)(buildShlinkApiClient);
|
||||
|
||||
export const resetCreateShortUrl = () => ({ type: RESET_CREATE_SHORT_URL });
|
||||
|
||||
Reference in New Issue
Block a user