Skip to content

Commit

Permalink
Added Toast and ContactModal in ContactList
Browse files Browse the repository at this point in the history
  • Loading branch information
nirmal1064 committed Feb 24, 2023
1 parent 8a04b86 commit 718aef7
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion src/pages/ContactList.jsx
@@ -1,8 +1,44 @@
import { useState } from "react";
import { Button } from "react-bootstrap";
import ContactModal from "../components/ContactModal";

const ContactList = () => {
const { msg, setMsg, errorMsg, setErrorMsg } = useContacts();
const [showContactModal, setShowContactModal] = useState(false);
const [type, setType] = useState("");
const [activeContact, setActiveContact] = useState({});

const closeContactModal = () => {
setActiveContact({});
setShowContactModal(false);
setType("");
};

const handleAdd = () => {
setType("Add");
setShowContactModal(true);
};

return (
<div>
<ToastMessage
type="Success"
show={msg ? true : false}
message={msg}
handleClose={() => setMsg("")}
/>
<ToastMessage
type="Error"
show={errorMsg ? true : false}
message={errorMsg}
handleClose={() => setErrorMsg("")}
/>
<ContactModal
show={showContactModal}
handleClose={closeContactModal}
type={type}
contact={activeContact}
/>
<div
style={{
display: "flex",
Expand All @@ -12,7 +48,7 @@ const ContactList = () => {
marginBottom: "10px"
}}>
<h2 className="text-center">Contact List</h2>
<Button>Add Contact</Button>
<Button onClick={handleAdd}>Add Contact</Button>
</div>
</div>
);
Expand Down

0 comments on commit 718aef7

Please sign in to comment.