-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add popup form, code refacto-creating reusable component
- Loading branch information
1 parent
b042b92
commit 5b34891
Showing
4 changed files
with
122 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import React from "react"; | ||
import Button from "react-bootstrap/Button"; | ||
import Modal from "react-bootstrap/Modal"; | ||
import { PropTypes } from "prop-types"; | ||
|
||
const PopupModalForm = ({ | ||
showModal, | ||
onHide, | ||
onSubmit, | ||
errors, | ||
title, | ||
buttonTitle, | ||
children, | ||
}) => { | ||
return ( | ||
<Modal show={showModal} onHide={onHide} centered> | ||
<Modal.Header | ||
style={{ backgroundColor: "#000", color: "#fff", fontSize: "10px" }} | ||
> | ||
<Modal.Title>{title}</Modal.Title> | ||
</Modal.Header> | ||
|
||
<Modal.Body> | ||
<form onSubmit={onSubmit}>{children}</form> | ||
{errors && <div className="form-text text-danger">{errors}</div>} | ||
</Modal.Body> | ||
|
||
<Modal.Footer> | ||
<Button variant="primary" size="sm" onClick={onSubmit}> | ||
{buttonTitle}{" "} | ||
<span | ||
className="spinner-border spinner-border-sm" | ||
role="status" | ||
aria-hidden="true" | ||
></span> | ||
</Button> | ||
</Modal.Footer> | ||
</Modal> | ||
); | ||
}; | ||
|
||
PopupModalForm.propTypes = { | ||
showModal: PropTypes.bool.isRequired, | ||
onHide: PropTypes.func.isRequired, | ||
onSubmit: PropTypes.func.isRequired, | ||
errors: PropTypes.string, | ||
title: PropTypes.string.isRequired, | ||
buttonTitle: PropTypes.string.isRequired, | ||
children: PropTypes.any, | ||
}; | ||
|
||
export default PopupModalForm; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import React from "react"; | ||
import { PropTypes } from "prop-types"; | ||
|
||
const TextInput = ({ name, value, onChange, type, placeholder }) => { | ||
return ( | ||
<div className="field"> | ||
<input | ||
className="form-control mb-4" | ||
name={name} | ||
type={type} | ||
value={value} | ||
onChange={onChange} | ||
placeholder={placeholder} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
TextInput.propTypes = { | ||
name: PropTypes.string.isRequired, | ||
type: PropTypes.string, | ||
value: PropTypes.string.isRequired, | ||
onChange: PropTypes.func.isRequired, | ||
placeholder: PropTypes.string, | ||
}; | ||
|
||
TextInput.defaultProps = { | ||
type: "text", | ||
}; | ||
|
||
export default TextInput; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters