mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 12:50:38 +00:00
Merge remote-tracking branch 'origin/fix_connectors'
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import {connect} from 'react-redux';
|
||||
import { connect } from 'react-redux';
|
||||
import { compose } from 'utils';
|
||||
import DialogConnect from 'connectors/Dialog.connector';
|
||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||
import DialogReduxConnect from 'components/DialogReduxConnect';
|
||||
import {getDialogPayload} from 'store/dashboard/dashboard.reducer';
|
||||
import { getDialogPayload } from 'store/dashboard/dashboard.reducer';
|
||||
import withAccountsActions from 'containers/Accounts/withAccountsActions';
|
||||
import withAccountDetail from 'containers/Accounts/withAccountDetail';
|
||||
import withAccounts from 'containers/Accounts/withAccounts';
|
||||
@@ -12,12 +12,11 @@ export const mapStateToProps = (state, props) => {
|
||||
|
||||
return {
|
||||
name: 'account-form',
|
||||
payload: {action: 'new', id: null, ...dialogPayload},
|
||||
payload: { action: 'new', id: null, ...dialogPayload },
|
||||
|
||||
accountId: dialogPayload?.id || null,
|
||||
};
|
||||
};
|
||||
|
||||
const AccountFormDialogConnect = connect(mapStateToProps);
|
||||
|
||||
export default compose(
|
||||
@@ -29,5 +28,5 @@ export default compose(
|
||||
accounts,
|
||||
})),
|
||||
DialogReduxConnect,
|
||||
DialogConnect,
|
||||
withDialogActions,
|
||||
);
|
||||
|
||||
@@ -18,7 +18,7 @@ import Dialog from 'components/Dialog';
|
||||
import DialogReduxConnect from 'components/DialogReduxConnect';
|
||||
import ErrorMessage from 'components/ErrorMessage';
|
||||
import classNames from 'classnames';
|
||||
import DialogConnect from 'connectors/Dialog.connector';
|
||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||
import { getDialogPayload } from 'store/dashboard/dashboard.reducer';
|
||||
|
||||
import withCurrency from 'containers/Currencies/withCurrency';
|
||||
@@ -31,7 +31,7 @@ function CurrencyDialog({
|
||||
payload,
|
||||
isOpen,
|
||||
|
||||
// #withDialog
|
||||
// #withDialogActions
|
||||
closeDialog,
|
||||
|
||||
// #withCurrency
|
||||
@@ -44,8 +44,7 @@ function CurrencyDialog({
|
||||
requestEditCurrency,
|
||||
}) {
|
||||
const { formatMessage } = useIntl();
|
||||
|
||||
const fetchCurrencies = useQuery('currencies', () =>
|
||||
const fetchCurrencies = useQuery('currencies', () =>
|
||||
requestFetchCurrencies(),
|
||||
);
|
||||
|
||||
@@ -236,7 +235,7 @@ const withCurrencyFormDialog = connect(mapStateToProps);
|
||||
|
||||
export default compose(
|
||||
withCurrencyFormDialog,
|
||||
DialogConnect,
|
||||
withDialogActions,
|
||||
DialogReduxConnect,
|
||||
withCurrenciesActions,
|
||||
withCurrency,
|
||||
|
||||
@@ -2,7 +2,7 @@ import { connect } from 'react-redux';
|
||||
import { compose } from 'utils';
|
||||
import { getDialogPayload } from 'store/dashboard/dashboard.reducer';
|
||||
|
||||
import DialogConnect from 'connectors/Dialog.connector';
|
||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||
import DialogReduxConnect from 'components/DialogReduxConnect';
|
||||
|
||||
import withExchangeRatesActions from 'containers/ExchangeRates/withExchangeRatesActions';
|
||||
@@ -31,5 +31,5 @@ export default compose(
|
||||
exchangeRatesList,
|
||||
})),
|
||||
DialogReduxConnect,
|
||||
DialogConnect,
|
||||
withDialogActions,
|
||||
);
|
||||
@@ -10,19 +10,20 @@ import {
|
||||
Intent,
|
||||
Classes,
|
||||
} from '@blueprintjs/core';
|
||||
import { objectKeysTransform } from 'utils';
|
||||
import classNames from 'classnames';
|
||||
import { pick, snakeCase } from 'lodash';
|
||||
import { queryCache } from 'react-query';
|
||||
|
||||
import AppToaster from 'components/AppToaster';
|
||||
|
||||
import DialogReduxConnect from 'components/DialogReduxConnect';
|
||||
import UserListDialogConnect from 'connectors/UsersList.connector';
|
||||
|
||||
import UserListDialogConnect from 'containers/Dialogs/UsersListDialog.connector';
|
||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||
import withUsersActions from 'containers/Users/withUsersActions';
|
||||
import ErrorMessage from 'components/ErrorMessage';
|
||||
import useAsync from 'hooks/async';
|
||||
import classNames from 'classnames';
|
||||
|
||||
import { compose } from 'utils';
|
||||
import { compose, objectKeysTransform } from 'utils';
|
||||
|
||||
function InviteUserDialog({
|
||||
name,
|
||||
@@ -210,6 +211,8 @@ function InviteUserDialog({
|
||||
}
|
||||
|
||||
export default compose(
|
||||
withDialogActions,
|
||||
UserListDialogConnect,
|
||||
withUsersActions,
|
||||
DialogReduxConnect,
|
||||
)(InviteUserDialog);
|
||||
|
||||
@@ -23,7 +23,7 @@ import ErrorMessage from 'components/ErrorMessage';
|
||||
import { ListSelect } from 'components';
|
||||
|
||||
import Dialog from 'components/Dialog';
|
||||
import DialogConnect from 'connectors/Dialog.connector';
|
||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||
import DialogReduxConnect from 'components/DialogReduxConnect';
|
||||
|
||||
import { getDialogPayload } from 'store/dashboard/dashboard.reducer';
|
||||
@@ -317,7 +317,7 @@ const withItemCategoryDialog = connect(mapStateToProps);
|
||||
|
||||
export default compose(
|
||||
withItemCategoryDialog,
|
||||
DialogConnect,
|
||||
withDialogActions,
|
||||
DialogReduxConnect,
|
||||
withItemCategoryDetail,
|
||||
withItemCategories(({ categoriesList }) => ({
|
||||
|
||||
@@ -1,138 +1,138 @@
|
||||
import React, { useState } from 'react';
|
||||
import {
|
||||
Button,
|
||||
Classes,
|
||||
FormGroup,
|
||||
InputGroup,
|
||||
Intent,
|
||||
TextArea,
|
||||
} from '@blueprintjs/core';
|
||||
import * as Yup from 'yup';
|
||||
import { FormattedMessage as T, useIntl } from 'react-intl';
|
||||
import { useFormik } from 'formik';
|
||||
import { compose } from 'utils';
|
||||
import Dialog from 'components/Dialog';
|
||||
import useAsync from 'hooks/async';
|
||||
import AppToaster from 'components/AppToaster';
|
||||
import DialogConnect from 'connectors/Dialog.connector';
|
||||
import DialogReduxConnect from 'components/DialogReduxConnect';
|
||||
import ItemFormDialogConnect from 'connectors/ItemFormDialog.connect';
|
||||
// import React, { useState } from 'react';
|
||||
// import {
|
||||
// Button,
|
||||
// Classes,
|
||||
// FormGroup,
|
||||
// InputGroup,
|
||||
// Intent,
|
||||
// TextArea,
|
||||
// } from '@blueprintjs/core';
|
||||
// import * as Yup from 'yup';
|
||||
// import { FormattedMessage as T, useIntl } from 'react-intl';
|
||||
// import { useFormik } from 'formik';
|
||||
// import { compose } from 'utils';
|
||||
// import Dialog from 'components/Dialog';
|
||||
// import useAsync from 'hooks/async';
|
||||
// import AppToaster from 'components/AppToaster';
|
||||
// import withDialog from 'containers/Dialogs/withDialog';
|
||||
// import DialogReduxConnect from 'components/DialogReduxConnect';
|
||||
// // import ItemFormDialogConnect from 'connectors/ItemFormDialog.connect';
|
||||
|
||||
function ItemFromDialog({
|
||||
name,
|
||||
payload,
|
||||
isOpen,
|
||||
submitItemCategory,
|
||||
fetchCategory,
|
||||
openDialog,
|
||||
closeDialog,
|
||||
}) {
|
||||
const [state, setState] = useState({});
|
||||
const { formatMessage } = useIntl();
|
||||
const ValidationSchema = Yup.object().shape({
|
||||
name: Yup.string().required().label(formatMessage({id:'category_name_'})),
|
||||
description: Yup.string().trim(),
|
||||
});
|
||||
// function ItemFromDialog({
|
||||
// name,
|
||||
// payload,
|
||||
// isOpen,
|
||||
// submitItemCategory,
|
||||
// fetchCategory,
|
||||
// openDialog,
|
||||
// closeDialog,
|
||||
// }) {
|
||||
// const [state, setState] = useState({});
|
||||
// const { formatMessage } = useIntl();
|
||||
// const ValidationSchema = Yup.object().shape({
|
||||
// name: Yup.string().required().label(formatMessage({id:'category_name_'})),
|
||||
// description: Yup.string().trim(),
|
||||
// });
|
||||
|
||||
const formik = useFormik({
|
||||
enableReinitialize: true,
|
||||
initialValues: {},
|
||||
validationSchema: ValidationSchema,
|
||||
onSubmit: (values) => {
|
||||
submitItemCategory({ values })
|
||||
.then((response) => {
|
||||
AppToaster.show({
|
||||
message: formatMessage({id:'the_category_has_been_successfully_created'}),
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
alert(error.message);
|
||||
});
|
||||
},
|
||||
});
|
||||
// const formik = useFormik({
|
||||
// enableReinitialize: true,
|
||||
// initialValues: {},
|
||||
// validationSchema: ValidationSchema,
|
||||
// onSubmit: (values) => {
|
||||
// submitItemCategory({ values })
|
||||
// .then((response) => {
|
||||
// AppToaster.show({
|
||||
// message: formatMessage({id:'the_category_has_been_successfully_created'}),
|
||||
// });
|
||||
// })
|
||||
// .catch((error) => {
|
||||
// alert(error.message);
|
||||
// });
|
||||
// },
|
||||
// });
|
||||
|
||||
const fetchHook = useAsync(async () => {
|
||||
await Promise.all([submitItemCategory]);
|
||||
});
|
||||
// const fetchHook = useAsync(async () => {
|
||||
// await Promise.all([submitItemCategory]);
|
||||
// });
|
||||
|
||||
const handleClose = () => {
|
||||
closeDialog(name);
|
||||
};
|
||||
// const handleClose = () => {
|
||||
// closeDialog(name);
|
||||
// };
|
||||
|
||||
const onDialogOpening = () => {
|
||||
fetchHook.execute();
|
||||
openDialog(name);
|
||||
};
|
||||
const onDialogClosed = () => {
|
||||
// formik.resetForm();
|
||||
closeDialog(name);
|
||||
};
|
||||
// const onDialogOpening = () => {
|
||||
// fetchHook.execute();
|
||||
// openDialog(name);
|
||||
// };
|
||||
// const onDialogClosed = () => {
|
||||
// // formik.resetForm();
|
||||
// closeDialog(name);
|
||||
// };
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
name={name}
|
||||
title={
|
||||
payload.action === 'new' ? <T id={'new'} /> : <T id={'new_category'} />
|
||||
}
|
||||
className={{
|
||||
'dialog--loading': state.isLoading,
|
||||
'dialog--item-form': true,
|
||||
}}
|
||||
isOpen={isOpen}
|
||||
onClosed={onDialogClosed}
|
||||
onOpening={onDialogOpening}
|
||||
isLoading={fetchHook.pending}
|
||||
>
|
||||
<form onSubmit={formik.handleSubmit}>
|
||||
<div className={Classes.DIALOG_BODY}>
|
||||
<FormGroup
|
||||
label={<T id={'category_name'} />}
|
||||
className={'form-group--category-name'}
|
||||
intent={formik.errors.name && Intent.DANGER}
|
||||
helperText={formik.errors.name && formik.errors.name}
|
||||
inline={true}
|
||||
>
|
||||
<InputGroup
|
||||
medium={formik.values.toString()}
|
||||
intent={formik.errors.name && Intent.DANGER}
|
||||
{...formik.getFieldProps('name')}
|
||||
/>
|
||||
</FormGroup>
|
||||
<FormGroup
|
||||
label={<T id={'description'} />}
|
||||
className={'form-group--description'}
|
||||
intent={formik.errors.description && Intent.DANGER}
|
||||
helperText={formik.errors.description && formik.errors.credential}
|
||||
inline={true}
|
||||
>
|
||||
<TextArea
|
||||
growVertically={true}
|
||||
large={true}
|
||||
{...formik.getFieldProps('description')}
|
||||
/>
|
||||
</FormGroup>
|
||||
</div>
|
||||
<div className={Classes.DIALOG_FOOTER}>
|
||||
<div className={Classes.DIALOG_FOOTER_ACTIONS}>
|
||||
<Button onClick={handleClose}>
|
||||
<T id={'close'} />
|
||||
</Button>
|
||||
<Button intent={Intent.PRIMARY} type='submit'>
|
||||
{payload.action === 'new' ? (
|
||||
<T id={'new'} />
|
||||
) : (
|
||||
<T id={'submit'} />
|
||||
)}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
// return (
|
||||
// <Dialog
|
||||
// name={name}
|
||||
// title={
|
||||
// payload.action === 'new' ? <T id={'new'} /> : <T id={'new_category'} />
|
||||
// }
|
||||
// className={{
|
||||
// 'dialog--loading': state.isLoading,
|
||||
// 'dialog--item-form': true,
|
||||
// }}
|
||||
// isOpen={isOpen}
|
||||
// onClosed={onDialogClosed}
|
||||
// onOpening={onDialogOpening}
|
||||
// isLoading={fetchHook.pending}
|
||||
// >
|
||||
// <form onSubmit={formik.handleSubmit}>
|
||||
// <div className={Classes.DIALOG_BODY}>
|
||||
// <FormGroup
|
||||
// label={<T id={'category_name'} />}
|
||||
// className={'form-group--category-name'}
|
||||
// intent={formik.errors.name && Intent.DANGER}
|
||||
// helperText={formik.errors.name && formik.errors.name}
|
||||
// inline={true}
|
||||
// >
|
||||
// <InputGroup
|
||||
// medium={formik.values.toString()}
|
||||
// intent={formik.errors.name && Intent.DANGER}
|
||||
// {...formik.getFieldProps('name')}
|
||||
// />
|
||||
// </FormGroup>
|
||||
// <FormGroup
|
||||
// label={<T id={'description'} />}
|
||||
// className={'form-group--description'}
|
||||
// intent={formik.errors.description && Intent.DANGER}
|
||||
// helperText={formik.errors.description && formik.errors.credential}
|
||||
// inline={true}
|
||||
// >
|
||||
// <TextArea
|
||||
// growVertically={true}
|
||||
// large={true}
|
||||
// {...formik.getFieldProps('description')}
|
||||
// />
|
||||
// </FormGroup>
|
||||
// </div>
|
||||
// <div className={Classes.DIALOG_FOOTER}>
|
||||
// <div className={Classes.DIALOG_FOOTER_ACTIONS}>
|
||||
// <Button onClick={handleClose}>
|
||||
// <T id={'close'} />
|
||||
// </Button>
|
||||
// <Button intent={Intent.PRIMARY} type='submit'>
|
||||
// {payload.action === 'new' ? (
|
||||
// <T id={'new'} />
|
||||
// ) : (
|
||||
// <T id={'submit'} />
|
||||
// )}
|
||||
// </Button>
|
||||
// </div>
|
||||
// </div>
|
||||
// </form>
|
||||
// </Dialog>
|
||||
// );
|
||||
// }
|
||||
|
||||
export default compose(
|
||||
ItemFormDialogConnect,
|
||||
DialogConnect,
|
||||
DialogReduxConnect
|
||||
)(ItemFromDialog);
|
||||
// export default compose(
|
||||
// // ItemFormDialogConnect,
|
||||
// withDialog,
|
||||
// DialogReduxConnect
|
||||
// )(ItemFromDialog);
|
||||
|
||||
19
client/src/containers/Dialogs/UserFormDialog.connector.js
Normal file
19
client/src/containers/Dialogs/UserFormDialog.connector.js
Normal file
@@ -0,0 +1,19 @@
|
||||
import { connect } from 'react-redux';
|
||||
import { getUserDetails } from 'store/users/users.reducer';
|
||||
import { getDialogPayload } from 'store/dashboard/dashboard.reducer';
|
||||
import t from 'store/types';
|
||||
|
||||
export const mapStateToProps = (state, props) => {
|
||||
const dialogPayload = getDialogPayload(state, 'user-form');
|
||||
|
||||
return {
|
||||
name: 'user-form',
|
||||
payload: { action: 'new', id: null },
|
||||
userDetails:
|
||||
dialogPayload.action === 'edit'
|
||||
? getUserDetails(state, dialogPayload.user.id)
|
||||
: {},
|
||||
};
|
||||
};
|
||||
|
||||
export default connect(mapStateToProps, null);
|
||||
@@ -18,7 +18,11 @@ import { queryCache, useQuery } from 'react-query';
|
||||
import AppToaster from 'components/AppToaster';
|
||||
import DialogReduxConnect from 'components/DialogReduxConnect';
|
||||
import ErrorMessage from 'components/ErrorMessage';
|
||||
import UserFormDialogConnect from 'connectors/UserFormDialog.connector';
|
||||
|
||||
import UserFormDialogConnect from 'containers/Dialogs/UserFormDialog.connector';
|
||||
import withUsersActions from 'containers/Users/withUsersActions';
|
||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||
|
||||
import { compose } from 'utils';
|
||||
|
||||
function UserFormDialog({
|
||||
@@ -167,5 +171,7 @@ function UserFormDialog({
|
||||
|
||||
export default compose(
|
||||
UserFormDialogConnect,
|
||||
withUsersActions,
|
||||
withDialogActions,
|
||||
DialogReduxConnect,
|
||||
)(UserFormDialog);
|
||||
|
||||
22
client/src/containers/Dialogs/UsersListDialog.connector.js
Normal file
22
client/src/containers/Dialogs/UsersListDialog.connector.js
Normal file
@@ -0,0 +1,22 @@
|
||||
import { connect } from 'react-redux';
|
||||
import { getUserDetails } from 'store/users/users.reducer';
|
||||
import { getDialogPayload } from 'store/dashboard/dashboard.reducer';
|
||||
|
||||
export const mapStateToProps = (state, props) => {
|
||||
const dialogPayload = getDialogPayload(state, 'userList-form');
|
||||
|
||||
return {
|
||||
name: 'userList-form',
|
||||
payload: { action: 'new', id: null },
|
||||
userDetails:
|
||||
dialogPayload.action === 'edit'
|
||||
? getUserDetails(state, dialogPayload.user.id)
|
||||
: {},
|
||||
editUser:
|
||||
dialogPayload && dialogPayload.action === 'edit'
|
||||
? state.users.list.results[dialogPayload.user.id]
|
||||
: {},
|
||||
};
|
||||
};
|
||||
|
||||
export default connect(mapStateToProps, null);
|
||||
Reference in New Issue
Block a user