MCPcopy Create free account
hub / github.com/Bitbox-Connect/Bitbox / TestModal

Function TestModal

client/src/component/Others/TestModal.jsx:6–63  ·  view source on GitHub ↗
(props)

Source from the content-addressed store, hash-verified

4import '../css/ProjectCard.css';
5
6const TestModal = (props) => {
7 const { project, updateProject, showAlert } = props;
8 const context = useContext(projectContext);
9 const { deleteProject } = context;
10
11 const generateImageUrl = (projectId) => {
12 return `https://source.unsplash.com/910x900/?coding/?computer/&${projectId}`;
13 };
14
15 const [showModal, setShowModal] = useState(false);
16
17 const handleModalOpen = () => {
18 setShowModal(true);
19 };
20
21 const handleModalClose = () => {
22 setShowModal(false);
23 };
24
25 return (
26 <div className='col-md-3'>
27 <div className="pro-card my-1">
28 <img src={generateImageUrl(project._id)} style={{ height: "25vh" }} className="card-img-top" alt="..." />
29 <div className="card-body">
30 <h5 className="card-title">Project Title : {project.title}</h5>
31 <p className="card-text mg">Project Link : {project.link}</p>
32 <a href={project.link} target="_blank" className="card-link">Github Link</a>
33 <a href={project.link} target="_blank" className="card-link p-5">Youtube Link</a>
34 <button className="btn btn-primary" onClick={handleModalOpen}>Details</button>
35 <div>
36 <i className="fa-solid fa-trash mx-1 mt-3" onClick={() => { setShowModal(true); deleteProject(project._id); showAlert("Deleted Successfully", "success") }}></i>
37 <i className="fa-solid fa-pen-to-square mx-4 mt-2" onClick={() => updateProject(project)}></i>
38 </div>
39 </div>
40 </div>
41
42 {/* Modal */}
43 {showModal &&
44 <div className="modal fade show" style={{ display: "block" }} tabIndex="-1" role="dialog">
45 <div className="modal-dialog modal-dialog-centered" role="document">
46 <div className="modal-content">
47 <div className="modal-header">
48 <h1 className="modal-title fs-5">Project Details</h1>
49 <button type="button" className="btn-close" onClick={handleModalClose} aria-label="Close"></button>
50 </div>
51 <div className="modal-body">
52 Show a second modal and hide this one with the button below.
53 </div>
54 <div className="modal-footer">
55 <button className="btn btn-primary" onClick={handleModalClose}>Close</button>
56 </div>
57 </div>
58 </div>
59 </div>
60 }
61 </div>
62 );
63};

Callers

nothing calls this directly

Calls 4

deleteProjectFunction · 0.85
showAlertFunction · 0.85
updateProjectFunction · 0.85
generateImageUrlFunction · 0.70

Tested by

no test coverage detected