@bigbinary/neeto-molecules 1.1.4 → 1.1.5
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 +1 -0
- package/dist/ConfirmationModal.cjs.js +87 -0
- package/dist/ConfirmationModal.cjs.js.map +1 -0
- package/dist/ConfirmationModal.js +62 -0
- package/dist/ConfirmationModal.js.map +1 -0
- package/package.json +1 -1
- package/src/translations/en.json +3 -0
- package/types/ConfirmationModal.d.ts +63 -0
package/README.md
CHANGED
|
@@ -55,6 +55,7 @@ https://neeto-molecules.neeto.com/
|
|
|
55
55
|
- [Breadcrumbs](./docs/components.md#Breadcrumbs)
|
|
56
56
|
- [Security](./docs/components.md#Security)
|
|
57
57
|
- [SendToFields](./docs/components.md#SendToFieldsComponent)
|
|
58
|
+
- [ConfirmationModal](./docs/components.md#ConfirmationModal)
|
|
58
59
|
|
|
59
60
|
## Installation Instructions
|
|
60
61
|
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var neetoui = require('@bigbinary/neetoui');
|
|
5
|
+
var formik = require('@bigbinary/neetoui/formik');
|
|
6
|
+
var ramda = require('ramda');
|
|
7
|
+
var i18next = require('i18next');
|
|
8
|
+
var yup = require('yup');
|
|
9
|
+
|
|
10
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
11
|
+
|
|
12
|
+
function _interopNamespace(e) {
|
|
13
|
+
if (e && e.__esModule) return e;
|
|
14
|
+
var n = Object.create(null);
|
|
15
|
+
if (e) {
|
|
16
|
+
Object.keys(e).forEach(function (k) {
|
|
17
|
+
if (k !== 'default') {
|
|
18
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
19
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () { return e[k]; }
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
n["default"] = e;
|
|
27
|
+
return Object.freeze(n);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
31
|
+
var yup__namespace = /*#__PURE__*/_interopNamespace(yup);
|
|
32
|
+
|
|
33
|
+
var INITIAL_VALUES = {
|
|
34
|
+
confirmationText: ""
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
var deletionValidationSchema = function deletionValidationSchema(confirmationText) {
|
|
38
|
+
var errorMessage = i18next.t("neetoMolecules.confirmationModal.required", {
|
|
39
|
+
confirmationText: confirmationText
|
|
40
|
+
});
|
|
41
|
+
return yup__namespace.object({
|
|
42
|
+
confirmationText: yup__namespace.string().required(errorMessage).oneOf([confirmationText], errorMessage)
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
var ConfirmationModal = function ConfirmationModal(_ref) {
|
|
47
|
+
var buttonLabel = _ref.buttonLabel,
|
|
48
|
+
confirmationText = _ref.confirmationText,
|
|
49
|
+
_ref$description = _ref.description,
|
|
50
|
+
description = _ref$description === void 0 ? "" : _ref$description,
|
|
51
|
+
_ref$isOpen = _ref.isOpen,
|
|
52
|
+
isOpen = _ref$isOpen === void 0 ? true : _ref$isOpen,
|
|
53
|
+
_ref$isSubmitting = _ref.isSubmitting,
|
|
54
|
+
isSubmitting = _ref$isSubmitting === void 0 ? false : _ref$isSubmitting,
|
|
55
|
+
_ref$title = _ref.title,
|
|
56
|
+
title = _ref$title === void 0 ? "" : _ref$title,
|
|
57
|
+
onClose = _ref.onClose,
|
|
58
|
+
onSubmit = _ref.onSubmit;
|
|
59
|
+
var formikProps = {
|
|
60
|
+
initialValues: INITIAL_VALUES,
|
|
61
|
+
validationSchema: deletionValidationSchema(confirmationText),
|
|
62
|
+
onSubmit: onSubmit
|
|
63
|
+
};
|
|
64
|
+
return /*#__PURE__*/React__default["default"].createElement(neetoui.Modal, {
|
|
65
|
+
isOpen: isOpen,
|
|
66
|
+
onClose: onClose,
|
|
67
|
+
"data-testid": "confirmation-modal"
|
|
68
|
+
}, /*#__PURE__*/React__default["default"].createElement(neetoui.Modal.Header, null, /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
|
|
69
|
+
style: "h2"
|
|
70
|
+
}, title)), /*#__PURE__*/React__default["default"].createElement(neetoui.Modal.Body, {
|
|
71
|
+
className: "space-y-4"
|
|
72
|
+
}, ramda.type(description) === "String" ? /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, null, description) : description, /*#__PURE__*/React__default["default"].createElement(formik.Form, {
|
|
73
|
+
className: "flex items-start space-x-1",
|
|
74
|
+
formikProps: formikProps
|
|
75
|
+
}, /*#__PURE__*/React__default["default"].createElement(formik.Input, {
|
|
76
|
+
className: "flex-auto",
|
|
77
|
+
"data-testid": "confirmation-modal-input",
|
|
78
|
+
name: "confirmationText"
|
|
79
|
+
}), /*#__PURE__*/React__default["default"].createElement(formik.Button, {
|
|
80
|
+
label: buttonLabel,
|
|
81
|
+
loading: isSubmitting,
|
|
82
|
+
style: "danger"
|
|
83
|
+
}))));
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
module.exports = ConfirmationModal;
|
|
87
|
+
//# sourceMappingURL=ConfirmationModal.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConfirmationModal.cjs.js","sources":["../src/components/ConfirmationModal/constants.js","../src/components/ConfirmationModal/utils.js","../src/components/ConfirmationModal/index.jsx"],"sourcesContent":["export const INITIAL_VALUES = { confirmationText: \"\" };\n","import { t } from \"i18next\";\nimport * as yup from \"yup\";\n\nexport const deletionValidationSchema = confirmationText => {\n const errorMessage = t(\"neetoMolecules.confirmationModal.required\", {\n confirmationText,\n });\n\n return yup.object({\n confirmationText: yup\n .string()\n .required(errorMessage)\n .oneOf([confirmationText], errorMessage),\n });\n};\n","import React from \"react\";\n\nimport { Modal, Typography } from \"neetoui\";\nimport { Button, Form, Input } from \"neetoui/formik\";\nimport PropTypes from \"prop-types\";\nimport { type } from \"ramda\";\n\nimport { INITIAL_VALUES } from \"./constants\";\nimport { deletionValidationSchema } from \"./utils\";\n\nconst ConfirmationModal = ({\n buttonLabel,\n confirmationText,\n description = \"\",\n isOpen = true,\n isSubmitting = false,\n title = \"\",\n onClose,\n onSubmit,\n}) => {\n const formikProps = {\n initialValues: INITIAL_VALUES,\n validationSchema: deletionValidationSchema(confirmationText),\n onSubmit,\n };\n\n return (\n <Modal {...{ isOpen, onClose }} data-testid=\"confirmation-modal\">\n <Modal.Header>\n <Typography style=\"h2\">{title}</Typography>\n </Modal.Header>\n <Modal.Body className=\"space-y-4\">\n {type(description) === \"String\" ? (\n <Typography>{description}</Typography>\n ) : (\n description\n )}\n <Form className=\"flex items-start space-x-1\" {...{ formikProps }}>\n <Input\n className=\"flex-auto\"\n data-testid=\"confirmation-modal-input\"\n name=\"confirmationText\"\n />\n <Button label={buttonLabel} loading={isSubmitting} style=\"danger\" />\n </Form>\n </Modal.Body>\n </Modal>\n );\n};\n\nConfirmationModal.propTypes = {\n /**\n * Label of the action button in the Modal\n */\n buttonLabel: PropTypes.string,\n /**\n * Text that is expected to be entered by the user\n */\n confirmationText: PropTypes.string,\n /**\n * Modal description\n */\n description: PropTypes.oneOfType([\n PropTypes.arrayOf(PropTypes.node),\n PropTypes.node,\n PropTypes.string,\n ]),\n /**\n * To be passed to loading prop of the action button\n */\n isSubmitting: PropTypes.bool,\n /**\n * To specify whether the modal should be opened or closed.\n */\n isOpen: PropTypes.bool,\n /**\n * Title of the modal\n */\n title: PropTypes.string,\n /**\n * Handler function that is invoked when the close button is clicked\n */\n onClose: PropTypes.func,\n /**\n * Handler function that is invoked when the action button is clicked\n */\n onSubmit: PropTypes.func,\n};\n\nexport default ConfirmationModal;\n"],"names":["INITIAL_VALUES","confirmationText","deletionValidationSchema","errorMessage","t","yup","object","string","required","oneOf","ConfirmationModal","_ref","buttonLabel","_ref$description","description","_ref$isOpen","isOpen","_ref$isSubmitting","isSubmitting","_ref$title","title","onClose","onSubmit","formikProps","initialValues","validationSchema","React","createElement","Modal","Header","Typography","style","Body","className","type","Form","Input","name","Button","label","loading"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAO,IAAMA,cAAc,GAAG;AAAEC,EAAAA,gBAAgB,EAAE,EAAA;AAAG,CAAC;;ACG/C,IAAMC,wBAAwB,GAAG,SAA3BA,wBAAwBA,CAAGD,gBAAgB,EAAI;AAC1D,EAAA,IAAME,YAAY,GAAGC,SAAC,CAAC,2CAA2C,EAAE;AAClEH,IAAAA,gBAAgB,EAAhBA,gBAAAA;AACF,GAAC,CAAC,CAAA;EAEF,OAAOI,cAAG,CAACC,MAAM,CAAC;AAChBL,IAAAA,gBAAgB,EAAEI,cAAG,CAClBE,MAAM,EAAE,CACRC,QAAQ,CAACL,YAAY,CAAC,CACtBM,KAAK,CAAC,CAACR,gBAAgB,CAAC,EAAEE,YAAY,CAAA;AAC3C,GAAC,CAAC,CAAA;AACJ,CAAC;;ACJD,IAAMO,iBAAiB,GAAG,SAApBA,iBAAiBA,CAAAC,IAAA,EASjB;AAAA,EAAA,IARJC,WAAW,GAAAD,IAAA,CAAXC,WAAW;IACXX,gBAAgB,GAAAU,IAAA,CAAhBV,gBAAgB;IAAAY,gBAAA,GAAAF,IAAA,CAChBG,WAAW;AAAXA,IAAAA,WAAW,GAAAD,gBAAA,KAAG,KAAA,CAAA,GAAA,EAAE,GAAAA,gBAAA;IAAAE,WAAA,GAAAJ,IAAA,CAChBK,MAAM;AAANA,IAAAA,MAAM,GAAAD,WAAA,KAAG,KAAA,CAAA,GAAA,IAAI,GAAAA,WAAA;IAAAE,iBAAA,GAAAN,IAAA,CACbO,YAAY;AAAZA,IAAAA,YAAY,GAAAD,iBAAA,KAAG,KAAA,CAAA,GAAA,KAAK,GAAAA,iBAAA;IAAAE,UAAA,GAAAR,IAAA,CACpBS,KAAK;AA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AAA;AAACC,IAAAA,KAAK,EAAE3B,WAAY;AAAC4B,IAAAA,OAAO,EAAEtB,YAAa;AAACa,IAAAA,KAAK,EAAC,QAAA;GAAW,CAAA,CAC/D,CACI,CACP,CAAA;AAEZ;;;;"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Modal, Typography } from '@bigbinary/neetoui';
|
|
3
|
+
import { Form, Input, Button } from '@bigbinary/neetoui/formik';
|
|
4
|
+
import { type } from 'ramda';
|
|
5
|
+
import { t } from 'i18next';
|
|
6
|
+
import * as yup from 'yup';
|
|
7
|
+
|
|
8
|
+
var INITIAL_VALUES = {
|
|
9
|
+
confirmationText: ""
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
var deletionValidationSchema = function deletionValidationSchema(confirmationText) {
|
|
13
|
+
var errorMessage = t("neetoMolecules.confirmationModal.required", {
|
|
14
|
+
confirmationText: confirmationText
|
|
15
|
+
});
|
|
16
|
+
return yup.object({
|
|
17
|
+
confirmationText: yup.string().required(errorMessage).oneOf([confirmationText], errorMessage)
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
var ConfirmationModal = function ConfirmationModal(_ref) {
|
|
22
|
+
var buttonLabel = _ref.buttonLabel,
|
|
23
|
+
confirmationText = _ref.confirmationText,
|
|
24
|
+
_ref$description = _ref.description,
|
|
25
|
+
description = _ref$description === void 0 ? "" : _ref$description,
|
|
26
|
+
_ref$isOpen = _ref.isOpen,
|
|
27
|
+
isOpen = _ref$isOpen === void 0 ? true : _ref$isOpen,
|
|
28
|
+
_ref$isSubmitting = _ref.isSubmitting,
|
|
29
|
+
isSubmitting = _ref$isSubmitting === void 0 ? false : _ref$isSubmitting,
|
|
30
|
+
_ref$title = _ref.title,
|
|
31
|
+
title = _ref$title === void 0 ? "" : _ref$title,
|
|
32
|
+
onClose = _ref.onClose,
|
|
33
|
+
onSubmit = _ref.onSubmit;
|
|
34
|
+
var formikProps = {
|
|
35
|
+
initialValues: INITIAL_VALUES,
|
|
36
|
+
validationSchema: deletionValidationSchema(confirmationText),
|
|
37
|
+
onSubmit: onSubmit
|
|
38
|
+
};
|
|
39
|
+
return /*#__PURE__*/React.createElement(Modal, {
|
|
40
|
+
isOpen: isOpen,
|
|
41
|
+
onClose: onClose,
|
|
42
|
+
"data-testid": "confirmation-modal"
|
|
43
|
+
}, /*#__PURE__*/React.createElement(Modal.Header, null, /*#__PURE__*/React.createElement(Typography, {
|
|
44
|
+
style: "h2"
|
|
45
|
+
}, title)), /*#__PURE__*/React.createElement(Modal.Body, {
|
|
46
|
+
className: "space-y-4"
|
|
47
|
+
}, type(description) === "String" ? /*#__PURE__*/React.createElement(Typography, null, description) : description, /*#__PURE__*/React.createElement(Form, {
|
|
48
|
+
className: "flex items-start space-x-1",
|
|
49
|
+
formikProps: formikProps
|
|
50
|
+
}, /*#__PURE__*/React.createElement(Input, {
|
|
51
|
+
className: "flex-auto",
|
|
52
|
+
"data-testid": "confirmation-modal-input",
|
|
53
|
+
name: "confirmationText"
|
|
54
|
+
}), /*#__PURE__*/React.createElement(Button, {
|
|
55
|
+
label: buttonLabel,
|
|
56
|
+
loading: isSubmitting,
|
|
57
|
+
style: "danger"
|
|
58
|
+
}))));
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export { ConfirmationModal as default };
|
|
62
|
+
//# sourceMappingURL=ConfirmationModal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConfirmationModal.js","sources":["../src/components/ConfirmationModal/constants.js","../src/components/ConfirmationModal/utils.js","../src/components/ConfirmationModal/index.jsx"],"sourcesContent":["export const INITIAL_VALUES = { confirmationText: \"\" };\n","import { t } from \"i18next\";\nimport * as yup from \"yup\";\n\nexport const deletionValidationSchema = confirmationText => {\n const errorMessage = t(\"neetoMolecules.confirmationModal.required\", {\n confirmationText,\n });\n\n return yup.object({\n confirmationText: yup\n .string()\n .required(errorMessage)\n .oneOf([confirmationText], errorMessage),\n });\n};\n","import React from \"react\";\n\nimport { Modal, Typography } from \"neetoui\";\nimport { Button, Form, Input } from \"neetoui/formik\";\nimport PropTypes from \"prop-types\";\nimport { type } from \"ramda\";\n\nimport { INITIAL_VALUES } from \"./constants\";\nimport { deletionValidationSchema } from \"./utils\";\n\nconst ConfirmationModal = ({\n buttonLabel,\n confirmationText,\n description = \"\",\n isOpen = true,\n isSubmitting = false,\n title = \"\",\n onClose,\n onSubmit,\n}) => {\n const formikProps = {\n initialValues: INITIAL_VALUES,\n validationSchema: deletionValidationSchema(confirmationText),\n onSubmit,\n };\n\n return (\n <Modal {...{ isOpen, onClose }} data-testid=\"confirmation-modal\">\n <Modal.Header>\n <Typography style=\"h2\">{title}</Typography>\n </Modal.Header>\n <Modal.Body className=\"space-y-4\">\n {type(description) === \"String\" ? (\n <Typography>{description}</Typography>\n ) : (\n description\n )}\n <Form className=\"flex items-start space-x-1\" {...{ formikProps }}>\n <Input\n className=\"flex-auto\"\n data-testid=\"confirmation-modal-input\"\n name=\"confirmationText\"\n />\n <Button label={buttonLabel} loading={isSubmitting} style=\"danger\" />\n </Form>\n </Modal.Body>\n </Modal>\n );\n};\n\nConfirmationModal.propTypes = {\n /**\n * Label of the action button in the Modal\n */\n buttonLabel: PropTypes.string,\n /**\n * Text that is expected to be entered by the user\n */\n confirmationText: PropTypes.string,\n /**\n * Modal description\n */\n description: PropTypes.oneOfType([\n PropTypes.arrayOf(PropTypes.node),\n PropTypes.node,\n PropTypes.string,\n ]),\n /**\n * To be passed to loading prop of the action button\n */\n isSubmitting: PropTypes.bool,\n /**\n * To specify whether the modal should be opened or closed.\n */\n isOpen: PropTypes.bool,\n /**\n * Title of the modal\n */\n title: PropTypes.string,\n /**\n * Handler function that is invoked when the close button is clicked\n */\n onClose: PropTypes.func,\n /**\n * Handler function that is invoked when the action button is clicked\n */\n onSubmit: PropTypes.func,\n};\n\nexport default ConfirmationModal;\n"],"names":["INITIAL_VALUES","confirmationText","deletionValidationSchema","errorMessage","t","yup","object","string","required","oneOf","ConfirmationModal","_ref","buttonLabel","_ref$description","description","_ref$isOpen","isOpen","_ref$isSubmitting","isSubmitting","_ref$title","title","onClose","onSubmit","formikProps","initialValues","validationSchema","React","createElement","Modal","Header","Typography","style","Body","className","type","Form","Input","name","Button","label","loading"],"mappings":";;;;;;;AAAO,IAAMA,cAAc,GAAG;AAAEC,EAAAA,gBAAgB,EAAE,EAAA;AAAG,CAAC;;ACG/C,IAAMC,wBAAwB,GAAG,SAA3BA,wBAAwBA,CAAGD,gBAAgB,EAAI;AAC1D,EAAA,IAAME,YAAY,GAAGC,CAAC,CAAC,2CAA2C,EAAE;AAClEH,IAAAA,gBAAgB,EAAhBA,gBAAAA;AACF,GAAC,CAAC,CAAA;EAEF,OAAOI,GAAG,CAACC,MAAM,CAAC;AAChBL,IAAAA,gBAAgB,EAAEI,GAAG,CAClBE,MAAM,EAAE,CACRC,QAAQ,CAACL,YAAY,CAAC,CACtBM,KAAK,CAAC,CAACR,gBAAgB,CAAC,EAAEE,YAAY,CAAA;AAC3C,GAAC,CAAC,CAAA;AACJ,CAAC;;ACJD,IAAMO,iBAAiB,GAAG,SAApBA,iBAAiBA,CAAAC,IAAA,EASjB;AAAA,EAAA,IARJC,WAAW,GAAAD,IAAA,CAAXC,WAAW;IACXX,gBAAgB,GAAAU,IAAA,CAAhBV,gBAAgB;IAAAY,gBAAA,GAAAF,IAAA,CAChBG,WAAW;AAAXA,IAAAA,WAAW,GAAAD,gBAAA,KAAG,KAAA,CAAA,GAAA,EAAE,GAAAA,gBAAA;IAAAE,WAAA,GAAAJ,IAAA,CAChBK,MAAM;AAANA,IAAAA,MAAM,GAAAD,WAAA,KAAG,KAAA,CAAA,GAAA,IAAI,GAAAA,WAAA;IAAAE,iBAAA,GAAAN,IAAA,CACbO,YAAY;AAAZA,IAAAA,YAAY,GAAAD,iBAAA,KAAG,KAAA,CAAA,GAAA,KAAK,GAAAA,iBAAA;IAAAE,UAAA,GAAAR,IAAA,CAC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EAAA;AAACC,IAAAA,KAAK,EAAE3B,WAAY;AAAC4B,IAAAA,OAAO,EAAEtB,YAAa;AAACa,IAAAA,KAAK,EAAC,QAAA;GAAW,CAAA,CAC/D,CACI,CACP,CAAA;AAEZ;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bigbinary/neeto-molecules",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5",
|
|
4
4
|
"description": "A package of reusable molecular components for neeto products.",
|
|
5
5
|
"repository": "git@github.com:bigbinary/neeto-molecules.git",
|
|
6
6
|
"author": "Amaljith K <amaljith.k@bigbinary.com>",
|
package/src/translations/en.json
CHANGED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* When users have to delete an entity that is integral to the app, it is
|
|
5
|
+
*
|
|
6
|
+
* considered a best practice to add an extra step to confirm if they want to
|
|
7
|
+
*
|
|
8
|
+
* delete the entity. This modal contains an input field where you can ask the user
|
|
9
|
+
*
|
|
10
|
+
* to enter something in order to confirm if they want to delete that component. It
|
|
11
|
+
*
|
|
12
|
+
* can also be used to stress on the fact that the deletion is irreversible. This
|
|
13
|
+
*
|
|
14
|
+
* modal can be used for any other operations apart from deletion. You can see a
|
|
15
|
+
*
|
|
16
|
+
* similar modal being used by GitHub when you delete a repository. GitHub asks you
|
|
17
|
+
*
|
|
18
|
+
* to confirm the deletion by prompting you to enter the name of the repository in
|
|
19
|
+
*
|
|
20
|
+
* an input field.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
*
|
|
24
|
+
* import React from "react";
|
|
25
|
+
* import ConfirmationModal from "@bigbinary/neeto-molecules/ConfirmationModal";
|
|
26
|
+
*
|
|
27
|
+
* import { deleteProject } from "apis/projectApi.js";
|
|
28
|
+
*
|
|
29
|
+
* const SendToFieldsComponent = ({ project }) => {
|
|
30
|
+
* const [isDeleting, setIsDeleting] = useState(false);
|
|
31
|
+
* const [showModal, setShowModal] = useState(false);
|
|
32
|
+
*
|
|
33
|
+
* return (
|
|
34
|
+
* <ConfirmationModal
|
|
35
|
+
* buttonLabel="Delete Project"
|
|
36
|
+
* confirmationText={project.name}
|
|
37
|
+
* description="Once the project is deleted it cannot be restored. If you want to proceed, enter the name of the project below"
|
|
38
|
+
* isOpen={showModal}
|
|
39
|
+
* isSubmitting={isDeleting}
|
|
40
|
+
* title="Confirm project deletion"
|
|
41
|
+
* onClose={() => setShowModal(false)}
|
|
42
|
+
* onSubmit={async () => {
|
|
43
|
+
* setIsDeleting(true);
|
|
44
|
+
* await deleteProject(project.name);
|
|
45
|
+
* setShowModal(false);
|
|
46
|
+
* setIsDeleting(false);
|
|
47
|
+
* }}
|
|
48
|
+
* />
|
|
49
|
+
* );
|
|
50
|
+
* };
|
|
51
|
+
* @endexample
|
|
52
|
+
*/
|
|
53
|
+
const ConfirmationModal: React.FC<{
|
|
54
|
+
buttonLabel: string;
|
|
55
|
+
confirmationText: string;
|
|
56
|
+
description?: React.ReactNode | React.ReactNode[] | string;
|
|
57
|
+
isOpen?: boolean;
|
|
58
|
+
isSubmitting?: boolean;
|
|
59
|
+
title?: string;
|
|
60
|
+
onClose: Function;
|
|
61
|
+
onSubmit: Function;
|
|
62
|
+
}>;
|
|
63
|
+
export default ConfirmationModal;
|