-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add user invitation modal to UserManagementPage
- Loading branch information
1 parent
da373cc
commit 315e3fd
Showing
2 changed files
with
136 additions
and
1 deletion.
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,105 @@ | ||
import React, { useState } from "react"; | ||
import { Modal, Button, Form } from "react-bootstrap"; | ||
|
||
interface FormModalProps { | ||
show: boolean; | ||
onClose: () => void; | ||
handleSendInvite: (formData: { | ||
firstName: string; | ||
lastName: string; | ||
phoneNumber: string; | ||
email: string; | ||
role: string; | ||
}) => void; | ||
} | ||
|
||
const FormModal: React.FC<FormModalProps> = ({ | ||
show, | ||
onClose, | ||
handleSendInvite, | ||
}) => { | ||
const [formData, setFormData] = useState({ | ||
firstName: "", | ||
lastName: "", | ||
phoneNumber: "", | ||
email: "", | ||
role: "", | ||
}); | ||
|
||
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => { | ||
const { name, value } = e.target; | ||
setFormData((prevData) => ({ ...prevData, [name]: value })); | ||
}; | ||
|
||
const handleSubmit = (e: React.FormEvent) => { | ||
e.preventDefault(); | ||
handleSendInvite(formData); | ||
}; | ||
|
||
return ( | ||
<Modal show={show} onHide={onClose}> | ||
<Modal.Header closeButton> | ||
<Modal.Title>Send Invite</Modal.Title> | ||
</Modal.Header> | ||
<Modal.Body> | ||
<Form onSubmit={handleSubmit}> | ||
<Form.Group controlId="formFirstName"> | ||
<Form.Label>First Name</Form.Label> | ||
<Form.Control | ||
type="text" | ||
name="firstName" | ||
value={formData.firstName} | ||
onChange={handleChange} | ||
required | ||
/> | ||
</Form.Group> | ||
<Form.Group controlId="formLastName"> | ||
<Form.Label>Last Name</Form.Label> | ||
<Form.Control | ||
type="text" | ||
name="lastName" | ||
value={formData.lastName} | ||
onChange={handleChange} | ||
required | ||
/> | ||
</Form.Group> | ||
<Form.Group controlId="formPhoneNumber"> | ||
<Form.Label>Phone Number</Form.Label> | ||
<Form.Control | ||
type="text" | ||
name="phoneNumber" | ||
value={formData.phoneNumber} | ||
onChange={handleChange} | ||
required | ||
/> | ||
</Form.Group> | ||
<Form.Group controlId="formEmail"> | ||
<Form.Label>Email</Form.Label> | ||
<Form.Control | ||
type="email" | ||
name="email" | ||
value={formData.email} | ||
onChange={handleChange} | ||
required | ||
/> | ||
</Form.Group> | ||
<Form.Group controlId="formRole"> | ||
<Form.Label>Role</Form.Label> | ||
<Form.Control | ||
type="text" | ||
name="role" | ||
value={formData.role} | ||
onChange={handleChange} | ||
required | ||
/> | ||
</Form.Group> | ||
<Button variant="primary" type="submit"> | ||
Send Invite | ||
</Button> | ||
</Form> | ||
</Modal.Body> | ||
</Modal> | ||
); | ||
}; | ||
|
||
export default FormModal; |
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