diff --git a/client/src/containers/Dialogs/CurrencyDialog.js b/client/src/containers/Dialogs/CurrencyDialog.js
index f7959b22b..4aac6789c 100644
--- a/client/src/containers/Dialogs/CurrencyDialog.js
+++ b/client/src/containers/Dialogs/CurrencyDialog.js
@@ -19,7 +19,6 @@ import withDialogRedux from 'components/DialogReduxConnect';
import ErrorMessage from 'components/ErrorMessage';
import classNames from 'classnames';
import withDialogActions from 'containers/Dialog/withDialogActions';
-import { getDialogPayload } from 'store/dashboard/dashboard.reducer';
import withCurrency from 'containers/Currencies/withCurrency';
import withCurrenciesActions from 'containers/Currencies/withCurrenciesActions';
@@ -27,7 +26,7 @@ import withCurrenciesActions from 'containers/Currencies/withCurrenciesActions';
import { compose } from 'utils';
function CurrencyDialog({
- name,
+ dialogName,
payload,
isOpen,
@@ -66,6 +65,7 @@ function CurrencyDialog({
);
const {
+ values,
errors,
touched,
isSubmitting,
@@ -83,7 +83,7 @@ function CurrencyDialog({
if (payload.action === 'edit') {
requestEditCurrency(currency.id, values)
.then((response) => {
- closeDialog(name);
+ closeDialog(dialogName);
AppToaster.show({
message: formatMessage({
id: 'the_currency_has_been_successfully_edited',
@@ -99,7 +99,7 @@ function CurrencyDialog({
} else {
requestSubmitCurrencies(values)
.then((response) => {
- closeDialog(name);
+ closeDialog(dialogName);
AppToaster.show({
message: formatMessage({
id: 'the_currency_has_been_successfully_created',
@@ -117,8 +117,8 @@ function CurrencyDialog({
});
const handleClose = useCallback(() => {
- closeDialog(name);
- }, [name, closeDialog]);
+ closeDialog(dialogName);
+ }, [dialogName, closeDialog]);
const onDialogOpening = useCallback(() => {
fetchCurrencies.refetch();
@@ -126,14 +126,14 @@ function CurrencyDialog({
const onDialogClosed = useCallback(() => {
resetForm();
- closeDialog(name);
- }, [closeDialog, name, resetForm]);
+ closeDialog(dialogName);
+ }, [closeDialog, dialogName, resetForm]);
const requiredSpan = useMemo(() => *, []);
return (
@@ -222,7 +222,7 @@ function CurrencyDialog({
}
const mapStateToProps = (state, props) => ({
- dialogName: 'currency-form',
+ currency: 'currency-form',
});
const withCurrencyFormDialog = connect(mapStateToProps);
diff --git a/client/src/containers/Dialogs/ExchangeRateDialog.container.js b/client/src/containers/Dialogs/ExchangeRateDialog.container.js
index 854f80937..8c9373994 100644
--- a/client/src/containers/Dialogs/ExchangeRateDialog.container.js
+++ b/client/src/containers/Dialogs/ExchangeRateDialog.container.js
@@ -3,27 +3,31 @@ import { compose } from 'utils';
import withDialogActions from 'containers/Dialog/withDialogActions';
import withDialogRedux from 'components/DialogReduxConnect';
-
+import withExchangeRateDetail from 'containers/ExchangeRates/withExchangeRateDetail';
import withExchangeRatesActions from 'containers/ExchangeRates/withExchangeRatesActions';
-import withExchangeRates from 'containers/ExchangeRates/withExchangeRates';
+import withExchangeRates from 'containers/ExchangeRates/withExchangeRates';
import withCurrencies from 'containers/Currencies/withCurrencies';
-
const mapStateToProps = (state, props) => ({
dialogName: 'exchangeRate-form',
+ exchangeRateId:
+ props.payload.action === 'edit' && props.payload.id
+ ? props.payload.id
+ : null,
});
const withExchangeRateDialog = connect(mapStateToProps);
export default compose(
- withExchangeRateDialog,
withDialogRedux(null, 'exchangeRate-form'),
+ withExchangeRateDialog,
withCurrencies(({ currenciesList }) => ({
currenciesList,
})),
+ withExchangeRatesActions,
+ withExchangeRateDetail,
withExchangeRates(({ exchangeRatesList }) => ({
exchangeRatesList,
})),
- withExchangeRatesActions,
withDialogActions,
-);
\ No newline at end of file
+);
diff --git a/client/src/containers/Dialogs/ExchangeRateDialog.js b/client/src/containers/Dialogs/ExchangeRateDialog.js
index af97adbc7..1f1e77f9c 100644
--- a/client/src/containers/Dialogs/ExchangeRateDialog.js
+++ b/client/src/containers/Dialogs/ExchangeRateDialog.js
@@ -15,13 +15,8 @@ import { useFormik } from 'formik';
import { useQuery, queryCache } from 'react-query';
import moment from 'moment';
import { DateInput } from '@blueprintjs/datetime';
-import { momentFormatter } from 'utils';
-import {
- AppToaster,
- Dialog,
- ErrorMessage,
- ListSelect,
-} from 'components';
+import { momentFormatter, tansformDateValue } from 'utils';
+import { AppToaster, Dialog, ErrorMessage, ListSelect } from 'components';
import classNames from 'classnames';
import withExchangeRatesDialog from './ExchangeRateDialog.container';
@@ -39,12 +34,13 @@ function ExchangeRateDialog({
// #withCurrencies
currenciesList,
+ //#WithExchangeRateDetail
+ exchangeRate,
+
// #withExchangeRatesActions
requestSubmitExchangeRate,
requestFetchExchangeRates,
requestEditExchangeRate,
- requestFetchCurrencies,
- editExchangeRate,
}) {
const { formatMessage } = useIntl();
const [selectedItems, setSelectedItems] = useState({});
@@ -90,7 +86,7 @@ function ExchangeRateDialog({
validationSchema,
initialValues: {
...(payload.action === 'edit' &&
- pick(editExchangeRate, Object.keys(initialValues))),
+ pick(exchangeRate, Object.keys(initialValues))),
},
onSubmit: (values, { setSubmitting, setErrors }) => {
if (payload.action === 'edit') {
@@ -154,9 +150,9 @@ function ExchangeRateDialog({
}, [fetchExchangeRatesDialog]);
const handleDateChange = useCallback(
- (date) => {
+ (date_filed) => (date) => {
const formatted = moment(date).format('YYYY-MM-DD');
- setFieldValue('date', formatted);
+ setFieldValue(date_filed, formatted);
},
[setFieldValue],
);
@@ -231,10 +227,10 @@ function ExchangeRateDialog({
>