mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 12:50:38 +00:00
WIP feature/Currencies
This commit is contained in:
35
client/src/connectors/CurrencyFromDialog.connect.js
Normal file
35
client/src/connectors/CurrencyFromDialog.connect.js
Normal file
@@ -0,0 +1,35 @@
|
||||
import { connect } from 'react-redux';
|
||||
import {
|
||||
fetchCurrencies,
|
||||
submitCurrencies,
|
||||
deleteCurrency,
|
||||
editCurrency,
|
||||
} from 'store/currencies/currencies.actions';
|
||||
import { getDialogPayload } from 'store/dashboard/dashboard.reducer';
|
||||
import { getCurrencyById } from 'store/currencies/currencies.selector';
|
||||
|
||||
export const mapStateToProps = (state, props) => {
|
||||
const dialogPayload = getDialogPayload(state, 'currency-form');
|
||||
|
||||
return {
|
||||
currencies: state.currencies.preferences.currencies,
|
||||
name: 'currency-form',
|
||||
payload: { action: 'new', id: null, ...dialogPayload },
|
||||
editCurrency:
|
||||
dialogPayload && dialogPayload.action === 'edit'
|
||||
? state.currencies.preferences.currencies[dialogPayload.currency_code]
|
||||
: {},
|
||||
getCurrencyId: (id) =>
|
||||
getCurrencyById(state.currencies.preferences.currencies, id),
|
||||
};
|
||||
};
|
||||
|
||||
export const mapDispatchToProps = (dispatch) => ({
|
||||
requestFetchCurrencies: () => dispatch(fetchCurrencies({})),
|
||||
requestSubmitCurrencies: (form) => dispatch(submitCurrencies({ form })),
|
||||
requestEditCurrency: (id, form) => dispatch(editCurrency({ id, form })),
|
||||
requestDeleteCurrency: (currency_code) =>
|
||||
dispatch(deleteCurrency({ currency_code })),
|
||||
});
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps);
|
||||
Reference in New Issue
Block a user