mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 14:50:32 +00:00
WIP
This commit is contained in:
26
client/src/store/currencies/currencies.actions.js
Normal file
26
client/src/store/currencies/currencies.actions.js
Normal file
@@ -0,0 +1,26 @@
|
||||
import ApiService from "services/ApiService";
|
||||
import t from 'store/types';
|
||||
|
||||
export const fetchCurrencies = () => {
|
||||
return (dispatch) => new Promise((resolve, reject) => {
|
||||
ApiService.get(`currencies/registered`).then((response) => {
|
||||
dispatch({
|
||||
type: t.CURRENCIES_REGISTERED_SET,
|
||||
currencies: response.data.currencies,
|
||||
});
|
||||
resolve(response);
|
||||
}).catch(error => { reject(error); });
|
||||
});
|
||||
};
|
||||
|
||||
export const fetchAllCurrencies = () => {
|
||||
return (dispatch) => new Promise((resolve, reject) => {
|
||||
ApiService.get(`currencies/all`).then((response) => {
|
||||
dispatch({
|
||||
type: t.CURRENCIES_ALL_SET,
|
||||
currencies: response.data.currencies,
|
||||
});
|
||||
resolve(response);
|
||||
}).catch(error => { reject(error); });
|
||||
});
|
||||
};
|
||||
18
client/src/store/currencies/currencies.reducer.js
Normal file
18
client/src/store/currencies/currencies.reducer.js
Normal file
@@ -0,0 +1,18 @@
|
||||
import {createReducer} from '@reduxjs/toolkit'
|
||||
import t from 'store/types';
|
||||
|
||||
const initialState = {
|
||||
all: [],
|
||||
registered: [],
|
||||
};
|
||||
|
||||
export default createReducer(initialState, {
|
||||
[t.CURRENCIES_REGISTERED_SET]: (state, action) => {
|
||||
state.registered = action.currencies;
|
||||
},
|
||||
|
||||
[t.CURRENCIES_ALL_SET]: (state, action) => {
|
||||
state.all = action.currencies;
|
||||
},
|
||||
});
|
||||
|
||||
5
client/src/store/currencies/currencies.types.js
Normal file
5
client/src/store/currencies/currencies.types.js
Normal file
@@ -0,0 +1,5 @@
|
||||
|
||||
export default {
|
||||
CURRENCIES_REGISTERED_SET: 'CURRENCIES_REGISTERED_SET',
|
||||
CURRENCIES_ALL_SET: 'CURRENCIES_ALL_SET',
|
||||
};
|
||||
Reference in New Issue
Block a user