envoc-form 2.0.1-6 → 3.0.0-2
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/README.md +7 -7
- package/dist/css/envoc-form-styles.css +43 -5
- package/dist/css/envoc-form-styles.css.map +1 -1
- package/es/AddressInput/AddressInput.js +7 -6
- package/es/ConfirmBaseForm/ConfirmBaseForm.js +3 -2
- package/es/ConfirmDeleteForm/ConfirmDeleteForm.js +6 -5
- package/es/DatePickerInput/DatePickerInput.js +8 -3
- package/es/FileInput/DefaultFileList.js +36 -0
- package/es/FileInput/DropzoneFileInput.js +58 -0
- package/es/FileInput/FileInput.js +31 -9
- package/es/FileInput/index.js +2 -1
- package/es/Form/Form.js +11 -33
- package/es/Form/FormBasedPreventNavigation.js +4 -7
- package/es/FormGroupWrapper.js +2 -1
- package/es/FormInput/FormInput.js +19 -7
- package/es/FormInputArray/FormInputArray.js +39 -24
- package/es/IconInput.js +2 -1
- package/es/ReactSelectField/ReactSelectField.js +6 -3
- package/es/SubmitFormButton.js +2 -1
- package/es/__Tests__/FormTestBase.js +5 -2
- package/es/normalizers.js +10 -5
- package/es/useStandardFormInput.js +4 -2
- package/es/utils/index.js +3 -0
- package/es/utils/objectContainsNonSerializableProperty.js +16 -0
- package/es/utils/objectToFormData.js +65 -0
- package/es/utils/typeChecks.js +25 -0
- package/lib/AddressInput/AddressInput.js +14 -8
- package/lib/ConfirmBaseForm/ConfirmBaseForm.js +4 -2
- package/lib/ConfirmDeleteForm/ConfirmDeleteForm.js +6 -4
- package/lib/DatePickerInput/DatePickerInput.js +9 -3
- package/lib/FileInput/DefaultFileList.js +47 -0
- package/lib/FileInput/DropzoneFileInput.js +75 -0
- package/lib/FileInput/FileInput.js +39 -10
- package/lib/FileInput/index.js +13 -3
- package/lib/Form/Form.js +19 -39
- package/lib/Form/FormBasedPreventNavigation.js +4 -10
- package/lib/FormGroupWrapper.js +3 -1
- package/lib/FormInput/FormInput.js +21 -8
- package/lib/FormInputArray/FormInputArray.js +47 -26
- package/lib/FormSection.js +5 -1
- package/lib/IconInput.js +3 -1
- package/lib/ReactSelectField/ReactSelectField.js +13 -5
- package/lib/ReactSelectField/index.js +6 -2
- package/lib/SubmitFormButton.js +3 -1
- package/lib/__Tests__/FormTestBase.js +6 -2
- package/lib/index.js +7 -3
- package/lib/normalizers.js +10 -5
- package/lib/useStandardFormInput.js +5 -2
- package/lib/utils/index.js +23 -0
- package/lib/utils/objectContainsNonSerializableProperty.js +24 -0
- package/lib/utils/objectToFormData.js +73 -0
- package/lib/utils/typeChecks.js +58 -0
- package/lib/validators/index.js +5 -1
- package/package.json +99 -92
- package/src/AddressInput/AddesssInput.test.js +23 -23
- package/src/AddressInput/AddressInput.js +73 -73
- package/src/AddressInput/UsStates.js +53 -53
- package/src/AddressInput/__snapshots__/AddesssInput.test.js.snap +207 -207
- package/src/AddressInput/index.js +2 -2
- package/src/BoolInput/BoolInput.js +7 -7
- package/src/BoolInput/BoolInput.test.js +23 -23
- package/src/BoolInput/InlineBoolInput.js +7 -7
- package/src/BoolInput/__snapshots__/BoolInput.test.js.snap +89 -89
- package/src/BoolInput/boolOptions.js +6 -6
- package/src/BoolInput/index.js +4 -4
- package/src/ConfirmBaseForm/ConfirmBaseForm.js +37 -37
- package/src/ConfirmBaseForm/ConfirmBaseForm.test.js +14 -14
- package/src/ConfirmBaseForm/__snapshots__/ConfirmBaseForm.test.js.snap +23 -23
- package/src/ConfirmBaseForm/index.js +1 -1
- package/src/ConfirmDeleteForm/ConfirmDeleteForm.js +39 -39
- package/src/ConfirmDeleteForm/ConfirmDeleteForm.test.js +24 -24
- package/src/ConfirmDeleteForm/__snapshots__/ConfirmDeleteForm.test.js.snap +25 -25
- package/src/ConfirmDeleteForm/index.js +1 -1
- package/src/DatePickerInput/DatePickerInput.js +49 -46
- package/src/DatePickerInput/DatePickerInput.test.js +74 -74
- package/src/DatePickerInput/__snapshots__/DatePickerInput.test.js.snap +134 -134
- package/src/DatePickerInput/date-picker-input.scss +42 -42
- package/src/DatePickerInput/index.js +3 -3
- package/src/ErrorScrollTarget.js +6 -6
- package/src/FileInput/DefaultFileList.js +39 -0
- package/src/FileInput/DropzoneFileInput.js +56 -0
- package/src/FileInput/DropzoneFileInput.test.js +24 -0
- package/src/FileInput/FileInput.js +77 -49
- package/src/FileInput/FileInput.test.js +24 -15
- package/src/FileInput/__snapshots__/DropzoneFileInput.test.js.snap +57 -0
- package/src/FileInput/__snapshots__/FileInput.test.js.snap +58 -22
- package/src/FileInput/file-input.scss +58 -17
- package/src/FileInput/index.js +4 -3
- package/src/Form/FocusError.js +48 -48
- package/src/Form/Form.js +139 -161
- package/src/Form/Form.test.js +23 -23
- package/src/Form/FormBasedPreventNavigation.js +25 -25
- package/src/Form/ServerErrorContext.js +7 -7
- package/src/Form/__snapshots__/Form.test.js.snap +9 -9
- package/src/Form/index.js +3 -3
- package/src/FormGroup.js +30 -30
- package/src/FormGroupWrapper.js +28 -28
- package/src/FormInput/FormInput.js +144 -141
- package/src/FormInput/FormInput.test.js +66 -66
- package/src/FormInput/__snapshots__/FormInput.test.js.snap +323 -316
- package/src/FormInput/form-input.scss +9 -9
- package/src/FormInput/index.js +2 -2
- package/src/FormInputArray/FormInputArray.js +224 -210
- package/src/FormInputArray/FormInputArray.test.js +108 -59
- package/src/FormInputArray/__snapshots__/FormInputArray.test.js.snap +52 -40
- package/src/FormInputArray/form-input-array.scss +13 -8
- package/src/FormInputArray/index.js +2 -2
- package/src/FormSection.js +13 -13
- package/src/IconInput.js +31 -31
- package/src/InlineFormInput/InlineFormInput.js +6 -6
- package/src/InlineFormInput/InlineFormInput.test.js +23 -23
- package/src/InlineFormInput/__snapshots__/InlineFormInput.test.js.snap +26 -26
- package/src/InlineFormInput/index.js +3 -3
- package/src/InlineFormInput/inline-form-input.scss +3 -3
- package/src/MoneyInput/InlineMoneyInput.js +7 -7
- package/src/MoneyInput/MoneyInput.js +7 -7
- package/src/MoneyInput/MoneyInputs.test.js +43 -43
- package/src/MoneyInput/__snapshots__/MoneyInputs.test.js.snap +81 -81
- package/src/MoneyInput/index.js +4 -4
- package/src/MoneyInput/money-input.scss +3 -3
- package/src/MoneyInput/moneyInputProps.js +12 -12
- package/src/NestedFormFieldContext.js +6 -6
- package/src/ReactSelectField/ReactSelectField.js +122 -120
- package/src/ReactSelectField/index.js +6 -6
- package/src/ReactSelectField/react-select-field.scss +5 -5
- package/src/StandardFormActions.js +27 -27
- package/src/SubmitFormButton.js +28 -28
- package/src/__Tests__/FormTestBase.js +14 -11
- package/src/__Tests__/IconInput.test.js +23 -23
- package/src/__Tests__/StandardFormActions.test.js +23 -23
- package/src/__Tests__/SubmitFormButton.test.js +23 -23
- package/src/__Tests__/__snapshots__/IconInput.test.js.snap +38 -38
- package/src/__Tests__/__snapshots__/StandardFormActions.test.js.snap +25 -25
- package/src/__Tests__/__snapshots__/SubmitFormButton.test.js.snap +18 -18
- package/src/__Tests__/index.js +2 -2
- package/src/_variables.scss +11 -11
- package/src/index.js +33 -33
- package/src/normalizers.js +42 -32
- package/src/selectors.js +3 -3
- package/src/styles.scss +7 -7
- package/src/useStandardFormInput.js +118 -118
- package/src/utils/index.js +3 -0
- package/src/utils/objectContainsNonSerializableProperty.js +15 -0
- package/src/utils/objectContainsNonSerializableProperty.test.js +49 -0
- package/src/utils/objectToFormData.js +89 -0
- package/src/utils/objectToFormData.test.js +76 -0
- package/src/utils/typeChecks.js +18 -0
- package/src/validators/index.js +2 -2
- package/src/validators/validators.js +93 -93
- package/src/validators/validators.test.js +79 -79
- package/CHANGELOG.json +0 -95
- package/CHANGELOG.md +0 -58
@@ -1,2 +1,2 @@
|
|
1
|
-
import AddressInput from './AddressInput';
|
2
|
-
export default AddressInput;
|
1
|
+
import AddressInput from './AddressInput';
|
2
|
+
export default AddressInput;
|
@@ -1,7 +1,7 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import boolOptions from './boolOptions';
|
3
|
-
import FormInput from '../FormInput';
|
4
|
-
|
5
|
-
export default function BoolInput(props) {
|
6
|
-
return <FormInput options={boolOptions} type="select" {...props} />;
|
7
|
-
}
|
1
|
+
import React from 'react';
|
2
|
+
import boolOptions from './boolOptions';
|
3
|
+
import FormInput from '../FormInput';
|
4
|
+
|
5
|
+
export default function BoolInput(props) {
|
6
|
+
return <FormInput options={boolOptions} type="select" {...props} />;
|
7
|
+
}
|
@@ -1,23 +1,23 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import { render } from '@testing-library/react';
|
3
|
-
import { FormTestBase } from '../__Tests__';
|
4
|
-
import BoolInput from './BoolInput';
|
5
|
-
|
6
|
-
describe('BoolInput', () => {
|
7
|
-
it('renders without crashing', () => {
|
8
|
-
render(
|
9
|
-
<FormTestBase>
|
10
|
-
<BoolInput name="yesNo" />
|
11
|
-
</FormTestBase>
|
12
|
-
);
|
13
|
-
});
|
14
|
-
|
15
|
-
it('has matching snapshot', () => {
|
16
|
-
const renderResult = render(
|
17
|
-
<FormTestBase>
|
18
|
-
<BoolInput name="yesNo" />
|
19
|
-
</FormTestBase>
|
20
|
-
);
|
21
|
-
expect(renderResult.asFragment()).toMatchSnapshot();
|
22
|
-
});
|
23
|
-
});
|
1
|
+
import React from 'react';
|
2
|
+
import { render } from '@testing-library/react';
|
3
|
+
import { FormTestBase } from '../__Tests__';
|
4
|
+
import BoolInput from './BoolInput';
|
5
|
+
|
6
|
+
describe('BoolInput', () => {
|
7
|
+
it('renders without crashing', () => {
|
8
|
+
render(
|
9
|
+
<FormTestBase>
|
10
|
+
<BoolInput name="yesNo" />
|
11
|
+
</FormTestBase>
|
12
|
+
);
|
13
|
+
});
|
14
|
+
|
15
|
+
it('has matching snapshot', () => {
|
16
|
+
const renderResult = render(
|
17
|
+
<FormTestBase>
|
18
|
+
<BoolInput name="yesNo" />
|
19
|
+
</FormTestBase>
|
20
|
+
);
|
21
|
+
expect(renderResult.asFragment()).toMatchSnapshot();
|
22
|
+
});
|
23
|
+
});
|
@@ -1,7 +1,7 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import boolOptions from './boolOptions';
|
3
|
-
import InlineFormInput from '../InlineFormInput';
|
4
|
-
|
5
|
-
export default function InlineBoolInput(props) {
|
6
|
-
return <InlineFormInput options={boolOptions} type="select" {...props} />;
|
7
|
-
}
|
1
|
+
import React from 'react';
|
2
|
+
import boolOptions from './boolOptions';
|
3
|
+
import InlineFormInput from '../InlineFormInput';
|
4
|
+
|
5
|
+
export default function InlineBoolInput(props) {
|
6
|
+
return <InlineFormInput options={boolOptions} type="select" {...props} />;
|
7
|
+
}
|
@@ -1,89 +1,89 @@
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
-
|
3
|
-
exports[`BoolInput has matching snapshot 1`] = `
|
4
|
-
<DocumentFragment>
|
5
|
-
<form
|
6
|
-
action="#"
|
7
|
-
>
|
8
|
-
<div
|
9
|
-
class="form-group"
|
10
|
-
>
|
11
|
-
<div
|
12
|
-
id="yesno-error-scroll-target"
|
13
|
-
style="display: none;"
|
14
|
-
/>
|
15
|
-
<div
|
16
|
-
class="react-select-input css-2b097c-container"
|
17
|
-
id="yesNo"
|
18
|
-
>
|
19
|
-
<div
|
20
|
-
class=" css-150ye8w-control"
|
21
|
-
>
|
22
|
-
<div
|
23
|
-
class=" css-lbak6p-Component"
|
24
|
-
>
|
25
|
-
<div
|
26
|
-
class=" css-1osw1h9-placeholder"
|
27
|
-
>
|
28
|
-
Select...
|
29
|
-
</div>
|
30
|
-
<div
|
31
|
-
class="css-lp83hw-Component"
|
32
|
-
>
|
33
|
-
<div
|
34
|
-
class=""
|
35
|
-
style="display: inline-block;"
|
36
|
-
>
|
37
|
-
<input
|
38
|
-
aria-autocomplete="list"
|
39
|
-
autocapitalize="none"
|
40
|
-
autocomplete="off"
|
41
|
-
autocorrect="off"
|
42
|
-
id="react-select-3-input"
|
43
|
-
spellcheck="false"
|
44
|
-
style="box-sizing: content-box; width: 2px; border: 0px; opacity: 1; outline: 0; padding: 0px;"
|
45
|
-
tabindex="0"
|
46
|
-
type="text"
|
47
|
-
value=""
|
48
|
-
/>
|
49
|
-
<div
|
50
|
-
style="position: absolute; top: 0px; left: 0px; visibility: hidden; height: 0px; overflow: scroll; white-space: pre; font-family: -webkit-small-control; letter-spacing: normal; text-transform: none;"
|
51
|
-
/>
|
52
|
-
</div>
|
53
|
-
</div>
|
54
|
-
</div>
|
55
|
-
<div
|
56
|
-
class=" css-ny0e4k-Component"
|
57
|
-
>
|
58
|
-
<span
|
59
|
-
class=" css-1sl80az-indicatorSeparator"
|
60
|
-
/>
|
61
|
-
<div
|
62
|
-
aria-hidden="true"
|
63
|
-
class=" css-augegj-indicatorContainer"
|
64
|
-
>
|
65
|
-
<svg
|
66
|
-
aria-hidden="true"
|
67
|
-
class="css-7ezgaa-Component"
|
68
|
-
focusable="false"
|
69
|
-
height="20"
|
70
|
-
viewBox="0 0 20 20"
|
71
|
-
width="20"
|
72
|
-
>
|
73
|
-
<path
|
74
|
-
d="M4.516 7.548c0.436-0.446 1.043-0.481 1.576 0l3.908 3.747 3.908-3.747c0.533-0.481 1.141-0.446 1.574 0 0.436 0.445 0.408 1.197 0 1.615-0.406 0.418-4.695 4.502-4.695 4.502-0.217 0.223-0.502 0.335-0.787 0.335s-0.57-0.112-0.789-0.335c0 0-4.287-4.084-4.695-4.502s-0.436-1.17 0-1.615z"
|
75
|
-
/>
|
76
|
-
</svg>
|
77
|
-
</div>
|
78
|
-
</div>
|
79
|
-
</div>
|
80
|
-
<input
|
81
|
-
name="yesNo"
|
82
|
-
type="hidden"
|
83
|
-
value=""
|
84
|
-
/>
|
85
|
-
</div>
|
86
|
-
</div>
|
87
|
-
</form>
|
88
|
-
</DocumentFragment>
|
89
|
-
`;
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
+
|
3
|
+
exports[`BoolInput has matching snapshot 1`] = `
|
4
|
+
<DocumentFragment>
|
5
|
+
<form
|
6
|
+
action="#"
|
7
|
+
>
|
8
|
+
<div
|
9
|
+
class="form-group"
|
10
|
+
>
|
11
|
+
<div
|
12
|
+
id="yesno-error-scroll-target"
|
13
|
+
style="display: none;"
|
14
|
+
/>
|
15
|
+
<div
|
16
|
+
class="react-select-input css-2b097c-container"
|
17
|
+
id="yesNo"
|
18
|
+
>
|
19
|
+
<div
|
20
|
+
class=" css-150ye8w-control"
|
21
|
+
>
|
22
|
+
<div
|
23
|
+
class=" css-lbak6p-Component"
|
24
|
+
>
|
25
|
+
<div
|
26
|
+
class=" css-1osw1h9-placeholder"
|
27
|
+
>
|
28
|
+
Select...
|
29
|
+
</div>
|
30
|
+
<div
|
31
|
+
class="css-lp83hw-Component"
|
32
|
+
>
|
33
|
+
<div
|
34
|
+
class=""
|
35
|
+
style="display: inline-block;"
|
36
|
+
>
|
37
|
+
<input
|
38
|
+
aria-autocomplete="list"
|
39
|
+
autocapitalize="none"
|
40
|
+
autocomplete="off"
|
41
|
+
autocorrect="off"
|
42
|
+
id="react-select-3-input"
|
43
|
+
spellcheck="false"
|
44
|
+
style="box-sizing: content-box; width: 2px; border: 0px; opacity: 1; outline: 0; padding: 0px;"
|
45
|
+
tabindex="0"
|
46
|
+
type="text"
|
47
|
+
value=""
|
48
|
+
/>
|
49
|
+
<div
|
50
|
+
style="position: absolute; top: 0px; left: 0px; visibility: hidden; height: 0px; overflow: scroll; white-space: pre; font-family: -webkit-small-control; letter-spacing: normal; text-transform: none;"
|
51
|
+
/>
|
52
|
+
</div>
|
53
|
+
</div>
|
54
|
+
</div>
|
55
|
+
<div
|
56
|
+
class=" css-ny0e4k-Component"
|
57
|
+
>
|
58
|
+
<span
|
59
|
+
class=" css-1sl80az-indicatorSeparator"
|
60
|
+
/>
|
61
|
+
<div
|
62
|
+
aria-hidden="true"
|
63
|
+
class=" css-augegj-indicatorContainer"
|
64
|
+
>
|
65
|
+
<svg
|
66
|
+
aria-hidden="true"
|
67
|
+
class="css-7ezgaa-Component"
|
68
|
+
focusable="false"
|
69
|
+
height="20"
|
70
|
+
viewBox="0 0 20 20"
|
71
|
+
width="20"
|
72
|
+
>
|
73
|
+
<path
|
74
|
+
d="M4.516 7.548c0.436-0.446 1.043-0.481 1.576 0l3.908 3.747 3.908-3.747c0.533-0.481 1.141-0.446 1.574 0 0.436 0.445 0.408 1.197 0 1.615-0.406 0.418-4.695 4.502-4.695 4.502-0.217 0.223-0.502 0.335-0.787 0.335s-0.57-0.112-0.789-0.335c0 0-4.287-4.084-4.695-4.502s-0.436-1.17 0-1.615z"
|
75
|
+
/>
|
76
|
+
</svg>
|
77
|
+
</div>
|
78
|
+
</div>
|
79
|
+
</div>
|
80
|
+
<input
|
81
|
+
name="yesNo"
|
82
|
+
type="hidden"
|
83
|
+
value=""
|
84
|
+
/>
|
85
|
+
</div>
|
86
|
+
</div>
|
87
|
+
</form>
|
88
|
+
</DocumentFragment>
|
89
|
+
`;
|
@@ -1,6 +1,6 @@
|
|
1
|
-
const boolOptions = [
|
2
|
-
{ label: 'Yes', value: true },
|
3
|
-
{ label: 'No', value: false },
|
4
|
-
];
|
5
|
-
|
6
|
-
export default boolOptions;
|
1
|
+
const boolOptions = [
|
2
|
+
{ label: 'Yes', value: true },
|
3
|
+
{ label: 'No', value: false },
|
4
|
+
];
|
5
|
+
|
6
|
+
export default boolOptions;
|
package/src/BoolInput/index.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import BoolInput from './BoolInput';
|
2
|
-
import InlineBoolInput from './InlineBoolInput';
|
3
|
-
|
4
|
-
export { BoolInput, InlineBoolInput };
|
1
|
+
import BoolInput from './BoolInput';
|
2
|
+
import InlineBoolInput from './InlineBoolInput';
|
3
|
+
|
4
|
+
export { BoolInput, InlineBoolInput };
|
@@ -1,37 +1,37 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import { Button } from 'reactstrap';
|
3
|
-
import { useAxiosRequest } from 'envoc-request';
|
4
|
-
|
5
|
-
export default function ConfirmBaseForm({
|
6
|
-
handleCancel,
|
7
|
-
request,
|
8
|
-
yesColor = 'danger',
|
9
|
-
style,
|
10
|
-
title,
|
11
|
-
...props
|
12
|
-
}) {
|
13
|
-
const webRequest = useAxiosRequest(
|
14
|
-
Object.assign({}, request, { autoExecute: false })
|
15
|
-
);
|
16
|
-
return (
|
17
|
-
<div style={{ textAlign: 'center', ...style }} {...props}>
|
18
|
-
<h3>{title}</h3>
|
19
|
-
<Button
|
20
|
-
color={yesColor}
|
21
|
-
onClick={webRequest.submitRequest}
|
22
|
-
disabled={webRequest.loading}>
|
23
|
-
Yes
|
24
|
-
</Button>
|
25
|
-
<Button
|
26
|
-
type="button"
|
27
|
-
color="link"
|
28
|
-
disabled={webRequest.loading}
|
29
|
-
onClick={handleCancel || goBack}>
|
30
|
-
Cancel
|
31
|
-
</Button>
|
32
|
-
</div>
|
33
|
-
);
|
34
|
-
function goBack() {
|
35
|
-
window.history.back();
|
36
|
-
}
|
37
|
-
}
|
1
|
+
import React from 'react';
|
2
|
+
import { Button } from 'reactstrap';
|
3
|
+
import { useAxiosRequest } from 'envoc-request';
|
4
|
+
|
5
|
+
export default function ConfirmBaseForm({
|
6
|
+
handleCancel,
|
7
|
+
request,
|
8
|
+
yesColor = 'danger',
|
9
|
+
style,
|
10
|
+
title,
|
11
|
+
...props
|
12
|
+
}) {
|
13
|
+
const webRequest = useAxiosRequest(
|
14
|
+
Object.assign({}, request, { autoExecute: false })
|
15
|
+
);
|
16
|
+
return (
|
17
|
+
<div style={{ textAlign: 'center', ...style }} {...props}>
|
18
|
+
<h3>{title}</h3>
|
19
|
+
<Button
|
20
|
+
color={yesColor}
|
21
|
+
onClick={webRequest.submitRequest}
|
22
|
+
disabled={webRequest.loading}>
|
23
|
+
Yes
|
24
|
+
</Button>
|
25
|
+
<Button
|
26
|
+
type="button"
|
27
|
+
color="link"
|
28
|
+
disabled={webRequest.loading}
|
29
|
+
onClick={handleCancel || goBack}>
|
30
|
+
Cancel
|
31
|
+
</Button>
|
32
|
+
</div>
|
33
|
+
);
|
34
|
+
function goBack() {
|
35
|
+
window.history.back();
|
36
|
+
}
|
37
|
+
}
|
@@ -1,14 +1,14 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import { render, screen } from '@testing-library/react';
|
3
|
-
import ConfirmBaseForm from './ConfirmBaseForm';
|
4
|
-
|
5
|
-
describe('ConfirmBaseForm', () => {
|
6
|
-
it('Renders without error', () => {
|
7
|
-
render(<ConfirmBaseForm />);
|
8
|
-
});
|
9
|
-
|
10
|
-
it('has matching snapshot', () => {
|
11
|
-
const renderResult = render(<ConfirmBaseForm />);
|
12
|
-
expect(renderResult.asFragment()).toMatchSnapshot();
|
13
|
-
});
|
14
|
-
});
|
1
|
+
import React from 'react';
|
2
|
+
import { render, screen } from '@testing-library/react';
|
3
|
+
import ConfirmBaseForm from './ConfirmBaseForm';
|
4
|
+
|
5
|
+
describe('ConfirmBaseForm', () => {
|
6
|
+
it('Renders without error', () => {
|
7
|
+
render(<ConfirmBaseForm />);
|
8
|
+
});
|
9
|
+
|
10
|
+
it('has matching snapshot', () => {
|
11
|
+
const renderResult = render(<ConfirmBaseForm />);
|
12
|
+
expect(renderResult.asFragment()).toMatchSnapshot();
|
13
|
+
});
|
14
|
+
});
|
@@ -1,23 +1,23 @@
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
-
|
3
|
-
exports[`ConfirmBaseForm has matching snapshot 1`] = `
|
4
|
-
<DocumentFragment>
|
5
|
-
<div
|
6
|
-
style="text-align: center;"
|
7
|
-
>
|
8
|
-
<h3 />
|
9
|
-
<button
|
10
|
-
class="btn btn-danger"
|
11
|
-
type="button"
|
12
|
-
>
|
13
|
-
Yes
|
14
|
-
</button>
|
15
|
-
<button
|
16
|
-
class="btn btn-link"
|
17
|
-
type="button"
|
18
|
-
>
|
19
|
-
Cancel
|
20
|
-
</button>
|
21
|
-
</div>
|
22
|
-
</DocumentFragment>
|
23
|
-
`;
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
+
|
3
|
+
exports[`ConfirmBaseForm has matching snapshot 1`] = `
|
4
|
+
<DocumentFragment>
|
5
|
+
<div
|
6
|
+
style="text-align: center;"
|
7
|
+
>
|
8
|
+
<h3 />
|
9
|
+
<button
|
10
|
+
class="btn btn-danger"
|
11
|
+
type="button"
|
12
|
+
>
|
13
|
+
Yes
|
14
|
+
</button>
|
15
|
+
<button
|
16
|
+
class="btn btn-link"
|
17
|
+
type="button"
|
18
|
+
>
|
19
|
+
Cancel
|
20
|
+
</button>
|
21
|
+
</div>
|
22
|
+
</DocumentFragment>
|
23
|
+
`;
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import ConfirmBaseForm from './ConfirmBaseForm';
|
1
|
+
import ConfirmBaseForm from './ConfirmBaseForm';
|
2
2
|
export default ConfirmBaseForm;
|
@@ -1,39 +1,39 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import {
|
3
|
-
import ConfirmBaseForm from '../ConfirmBaseForm';
|
4
|
-
import { toast } from 'react-toastify';
|
5
|
-
|
6
|
-
export default function ConfirmDeleteForm({
|
7
|
-
successUrl,
|
8
|
-
form,
|
9
|
-
children,
|
10
|
-
...props
|
11
|
-
}) {
|
12
|
-
const
|
13
|
-
const { entityId } = useParams();
|
14
|
-
const request = {
|
15
|
-
method: 'delete',
|
16
|
-
url: `/api/${form}/${entityId}`,
|
17
|
-
onComplete: () => {
|
18
|
-
toast.success('Deleted!');
|
19
|
-
goBack();
|
20
|
-
},
|
21
|
-
};
|
22
|
-
return (
|
23
|
-
<ConfirmBaseForm
|
24
|
-
request={request}
|
25
|
-
handleCancel={goBack}
|
26
|
-
title="Are you sure you want to delete this?"
|
27
|
-
{...props}>
|
28
|
-
{children}
|
29
|
-
</ConfirmBaseForm>
|
30
|
-
);
|
31
|
-
|
32
|
-
function goBack() {
|
33
|
-
if (successUrl) {
|
34
|
-
|
35
|
-
} else {
|
36
|
-
|
37
|
-
}
|
38
|
-
}
|
39
|
-
}
|
1
|
+
import React from 'react';
|
2
|
+
import { useNavigate, useParams } from 'react-router-dom';
|
3
|
+
import ConfirmBaseForm from '../ConfirmBaseForm';
|
4
|
+
import { toast } from 'react-toastify';
|
5
|
+
|
6
|
+
export default function ConfirmDeleteForm({
|
7
|
+
successUrl,
|
8
|
+
form,
|
9
|
+
children,
|
10
|
+
...props
|
11
|
+
}) {
|
12
|
+
const navigate = useNavigate();
|
13
|
+
const { entityId } = useParams();
|
14
|
+
const request = {
|
15
|
+
method: 'delete',
|
16
|
+
url: `/api/${form}/${entityId}`,
|
17
|
+
onComplete: () => {
|
18
|
+
toast.success('Deleted!');
|
19
|
+
goBack();
|
20
|
+
},
|
21
|
+
};
|
22
|
+
return (
|
23
|
+
<ConfirmBaseForm
|
24
|
+
request={request}
|
25
|
+
handleCancel={goBack}
|
26
|
+
title="Are you sure you want to delete this?"
|
27
|
+
{...props}>
|
28
|
+
{children}
|
29
|
+
</ConfirmBaseForm>
|
30
|
+
);
|
31
|
+
|
32
|
+
function goBack() {
|
33
|
+
if (successUrl) {
|
34
|
+
navigate(successUrl);
|
35
|
+
} else {
|
36
|
+
navigate(-1);
|
37
|
+
}
|
38
|
+
}
|
39
|
+
}
|
@@ -1,24 +1,24 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import { HashRouter } from 'react-router-dom';
|
3
|
-
import { render, screen } from '@testing-library/react';
|
4
|
-
|
5
|
-
import ConfirmDeleteForm from './ConfirmDeleteForm';
|
6
|
-
|
7
|
-
describe('ConfirmDeleteForm', () => {
|
8
|
-
it('Renders without error', () => {
|
9
|
-
render(
|
10
|
-
<HashRouter>
|
11
|
-
<ConfirmDeleteForm />
|
12
|
-
</HashRouter>
|
13
|
-
);
|
14
|
-
});
|
15
|
-
|
16
|
-
it('has matching snapshot', () => {
|
17
|
-
const renderResult = render(
|
18
|
-
<HashRouter>
|
19
|
-
<ConfirmDeleteForm />
|
20
|
-
</HashRouter>
|
21
|
-
);
|
22
|
-
expect(renderResult.asFragment()).toMatchSnapshot();
|
23
|
-
});
|
24
|
-
});
|
1
|
+
import React from 'react';
|
2
|
+
import { HashRouter } from 'react-router-dom';
|
3
|
+
import { render, screen } from '@testing-library/react';
|
4
|
+
|
5
|
+
import ConfirmDeleteForm from './ConfirmDeleteForm';
|
6
|
+
|
7
|
+
describe('ConfirmDeleteForm', () => {
|
8
|
+
it('Renders without error', () => {
|
9
|
+
render(
|
10
|
+
<HashRouter>
|
11
|
+
<ConfirmDeleteForm />
|
12
|
+
</HashRouter>
|
13
|
+
);
|
14
|
+
});
|
15
|
+
|
16
|
+
it('has matching snapshot', () => {
|
17
|
+
const renderResult = render(
|
18
|
+
<HashRouter>
|
19
|
+
<ConfirmDeleteForm />
|
20
|
+
</HashRouter>
|
21
|
+
);
|
22
|
+
expect(renderResult.asFragment()).toMatchSnapshot();
|
23
|
+
});
|
24
|
+
});
|
@@ -1,25 +1,25 @@
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
-
|
3
|
-
exports[`ConfirmDeleteForm has matching snapshot 1`] = `
|
4
|
-
<DocumentFragment>
|
5
|
-
<div
|
6
|
-
style="text-align: center;"
|
7
|
-
>
|
8
|
-
<h3>
|
9
|
-
Are you sure you want to delete this?
|
10
|
-
</h3>
|
11
|
-
<button
|
12
|
-
class="btn btn-danger"
|
13
|
-
type="button"
|
14
|
-
>
|
15
|
-
Yes
|
16
|
-
</button>
|
17
|
-
<button
|
18
|
-
class="btn btn-link"
|
19
|
-
type="button"
|
20
|
-
>
|
21
|
-
Cancel
|
22
|
-
</button>
|
23
|
-
</div>
|
24
|
-
</DocumentFragment>
|
25
|
-
`;
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
+
|
3
|
+
exports[`ConfirmDeleteForm has matching snapshot 1`] = `
|
4
|
+
<DocumentFragment>
|
5
|
+
<div
|
6
|
+
style="text-align: center;"
|
7
|
+
>
|
8
|
+
<h3>
|
9
|
+
Are you sure you want to delete this?
|
10
|
+
</h3>
|
11
|
+
<button
|
12
|
+
class="btn btn-danger"
|
13
|
+
type="button"
|
14
|
+
>
|
15
|
+
Yes
|
16
|
+
</button>
|
17
|
+
<button
|
18
|
+
class="btn btn-link"
|
19
|
+
type="button"
|
20
|
+
>
|
21
|
+
Cancel
|
22
|
+
</button>
|
23
|
+
</div>
|
24
|
+
</DocumentFragment>
|
25
|
+
`;
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import ConfirmDeleteForm from './ConfirmDeleteForm'
|
1
|
+
import ConfirmDeleteForm from './ConfirmDeleteForm'
|
2
2
|
export default ConfirmDeleteForm;
|