mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2024-12-23 01:20:24 +03:00
Updated reducers to follow Redux Reducer Bundles proposal
This commit is contained in:
parent
ac62410926
commit
a4f9a2b8b3
5 changed files with 14 additions and 17 deletions
|
@ -1,9 +0,0 @@
|
||||||
|
|
||||||
// Servers
|
|
||||||
export const LOAD_SERVER = 'shlink/LOAD_SERVER';
|
|
||||||
export const FETCH_SERVERS = 'shlink/FETCH_SERVERS';
|
|
||||||
export const CREATE_SERVER = 'shlink/CREATE_SERVER';
|
|
||||||
|
|
||||||
// Short URLs
|
|
||||||
export const LIST_SHORT_URLS = 'shlink/LIST_SHORT_URLS';
|
|
||||||
export const UPDATE_SHORT_URLS_LIST = 'shlink/UPDATE_SHORT_URLS_LIST';
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { LIST_SHORT_URLS } from '../../reducers/types';
|
import { LIST_SHORT_URLS } from '../../short-urls/reducers/shortUrlsList';
|
||||||
|
|
||||||
export default function selectedServerReducer(state = null, action) {
|
export default function reducer(state = null, action) {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case LIST_SHORT_URLS:
|
case LIST_SHORT_URLS:
|
||||||
return action.selectedServer;
|
return action.selectedServer;
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
import ServersService from '../services';
|
import ServersService from '../services';
|
||||||
import { FETCH_SERVERS, CREATE_SERVER } from '../../reducers/types';
|
|
||||||
|
|
||||||
export default function serversReducer(state = {}, action) {
|
const FETCH_SERVERS = 'shlink/servers/FETCH_SERVERS';
|
||||||
|
const CREATE_SERVER = 'shlink/servers/CREATE_SERVER';
|
||||||
|
|
||||||
|
export default function reducer(state = {}, action) {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case FETCH_SERVERS:
|
case FETCH_SERVERS:
|
||||||
return action.servers;
|
return action.servers;
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
import { LIST_SHORT_URLS, UPDATE_SHORT_URLS_LIST } from '../../reducers/types';
|
|
||||||
import ServersService from '../../servers/services';
|
import ServersService from '../../servers/services';
|
||||||
import ShlinkApiClient from '../../api/ShlinkApiClient';
|
import ShlinkApiClient from '../../api/ShlinkApiClient';
|
||||||
|
|
||||||
export default function shortUrlsListReducer(state = [], action) {
|
export const LIST_SHORT_URLS = 'shlink/shortUrlsList/LIST_SHORT_URLS';
|
||||||
|
export const UPDATE_SHORT_URLS_LIST = 'shlink/shortUrlsList/UPDATE_SHORT_URLS_LIST';
|
||||||
|
|
||||||
|
export default function reducer(state = [], action) {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case LIST_SHORT_URLS:
|
case LIST_SHORT_URLS:
|
||||||
case UPDATE_SHORT_URLS_LIST:
|
case UPDATE_SHORT_URLS_LIST:
|
||||||
|
@ -24,6 +26,8 @@ export const listShortUrls = (serverId, params = {}) => {
|
||||||
|
|
||||||
export const updateShortUrlsList = (params = {}) => {
|
export const updateShortUrlsList = (params = {}) => {
|
||||||
return async dispatch => {
|
return async dispatch => {
|
||||||
|
|
||||||
|
|
||||||
const shortUrls = await ShlinkApiClient.listShortUrls(params);
|
const shortUrls = await ShlinkApiClient.listShortUrls(params);
|
||||||
dispatch({ type: UPDATE_SHORT_URLS_LIST, shortUrls, params });
|
dispatch({ type: UPDATE_SHORT_URLS_LIST, shortUrls, params });
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { UPDATE_SHORT_URLS_LIST } from '../../reducers/types';
|
import { UPDATE_SHORT_URLS_LIST } from './shortUrlsList';
|
||||||
|
|
||||||
export default function shortUrlsListReducer(state = { page: 1 }, action) {
|
export default function reducer(state = { page: 1 }, action) {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case UPDATE_SHORT_URLS_LIST:
|
case UPDATE_SHORT_URLS_LIST:
|
||||||
return { ...state, ...action.params };
|
return { ...state, ...action.params };
|
||||||
|
|
Loading…
Reference in a new issue