tycho-components 0.0.8 → 0.0.9-SNAPSHOT
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Participants/ParticipantCreate/ParticipantCreate.js +3 -4
- package/dist/Participants/ParticipantRemove/ParticipantRemove.js +2 -1
- package/dist/configs/MessageUtils.d.ts +1 -0
- package/dist/configs/MessageUtils.js +4 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
|
@@ -7,8 +7,7 @@ import { TextField } from 'tycho-storybook';
|
|
|
7
7
|
import * as yup from 'yup';
|
|
8
8
|
import AppModal from '../../AppModal';
|
|
9
9
|
import CommonContext from '../../configs/CommonContext';
|
|
10
|
-
import { dispatchError } from '../../configs/MessageUtils';
|
|
11
|
-
import { toastLoading } from '../../configs/store/actions';
|
|
10
|
+
import { dispatchError, dispatchLoading } from '../../configs/MessageUtils';
|
|
12
11
|
import ParticipantService from '../types/ParticipantService';
|
|
13
12
|
import './style.scss';
|
|
14
13
|
export default function ParticipantCreate({ document, onClose, onCreate, }) {
|
|
@@ -21,7 +20,7 @@ export default function ParticipantCreate({ document, onClose, onCreate, }) {
|
|
|
21
20
|
const handleAdd = () => {
|
|
22
21
|
if (state.toastLoading)
|
|
23
22
|
return;
|
|
24
|
-
|
|
23
|
+
dispatchLoading(true, dispatch);
|
|
25
24
|
ParticipantService.add(document, createdForm.getValues())
|
|
26
25
|
.then((r) => {
|
|
27
26
|
onCreate(r.data);
|
|
@@ -30,7 +29,7 @@ export default function ParticipantCreate({ document, onClose, onCreate, }) {
|
|
|
30
29
|
dispatchError({ err, dispatch, t, key: 'participants' });
|
|
31
30
|
})
|
|
32
31
|
.finally(() => {
|
|
33
|
-
|
|
32
|
+
dispatchLoading(false, dispatch);
|
|
34
33
|
});
|
|
35
34
|
};
|
|
36
35
|
return (_jsx(AppModal, { title: t('modal.add.title'), className: "modal-participant", close: onClose, confirm: handleAdd, disableConfirm: !createdForm.formState.isValid, children: _jsxs("div", { className: "participant-container", children: [_jsx(TextField, { label: t('modal.input.code'), attr: "code",
|
|
@@ -3,6 +3,7 @@ import { useContext } from 'react';
|
|
|
3
3
|
import { useTranslation } from 'react-i18next';
|
|
4
4
|
import AppModalRemove from '../../AppModal/AppModalRemove';
|
|
5
5
|
import CommonContext from '../../configs/CommonContext';
|
|
6
|
+
import { dispatchLoading } from '../../configs/MessageUtils';
|
|
6
7
|
import { toastLoading } from '../../configs/store/actions';
|
|
7
8
|
import ParticipantService from '../types/ParticipantService';
|
|
8
9
|
import './style.scss';
|
|
@@ -12,7 +13,7 @@ export default function ParticipantRemove({ participant, participants, document,
|
|
|
12
13
|
const handleRemove = () => {
|
|
13
14
|
if (state.toastLoading || !participant)
|
|
14
15
|
return;
|
|
15
|
-
|
|
16
|
+
dispatchLoading(true, dispatch);
|
|
16
17
|
ParticipantService.remove(document, participant.code)
|
|
17
18
|
.then(() => {
|
|
18
19
|
const list = participants?.filter((p) => p.code !== participant.code) || [];
|
|
@@ -12,6 +12,7 @@ type ErrorDispatcher = {
|
|
|
12
12
|
t: TFunction;
|
|
13
13
|
key?: string;
|
|
14
14
|
};
|
|
15
|
+
export declare const dispatchLoading: (val: boolean, dispatch: React.Dispatch<StoreAction>) => void;
|
|
15
16
|
export declare const dispatchError: ({ err, dispatch, t, key }: ErrorDispatcher) => void;
|
|
16
17
|
export declare const dispatchMessage: ({ key, ns, dispatch, t, }: MessageDispatcher) => void;
|
|
17
18
|
declare const MessageUtils: {
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import { message } from '../configs/store/actions';
|
|
1
|
+
import { message, toastLoading } from '../configs/store/actions';
|
|
2
|
+
export const dispatchLoading = (val, dispatch) => {
|
|
3
|
+
dispatch(toastLoading(val));
|
|
4
|
+
};
|
|
2
5
|
// TODO: improve
|
|
3
6
|
export const dispatchError = ({ err, dispatch, t, key }) => {
|
|
4
7
|
if (!err.response) {
|
package/dist/index.d.ts
CHANGED
|
@@ -7,3 +7,4 @@ export { default as AppModalConfirm } from './AppModal/AppModalConfirm';
|
|
|
7
7
|
export { default as AppModalRemove } from './AppModal/AppModalRemove';
|
|
8
8
|
export { commonResources } from './configs/Localization';
|
|
9
9
|
export { CommonProvider } from './configs/CommonContext';
|
|
10
|
+
export { default as MessageUtils } from './configs/MessageUtils';
|
package/dist/index.js
CHANGED
|
@@ -7,3 +7,4 @@ export { default as AppModalConfirm } from './AppModal/AppModalConfirm';
|
|
|
7
7
|
export { default as AppModalRemove } from './AppModal/AppModalRemove';
|
|
8
8
|
export { commonResources } from './configs/Localization';
|
|
9
9
|
export { CommonProvider } from './configs/CommonContext';
|
|
10
|
+
export { default as MessageUtils } from './configs/MessageUtils';
|