Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | 4550x 4550x 4550x 4550x 10x 4550x 8x 8x 12x | import React, { useState } from "react";
import Modal from "react-bootstrap/Modal";
import Button from "react-bootstrap/Button";
import Form from "react-bootstrap/Form";
import PersonalScheduleSelector from "./PersonalScheduleSelector";
import { Link } from "react-router-dom";
import { schedulesFilter } from "main/utils/PersonalScheduleUtils";
import { yyyyqToQyy } from "main/utils/quarterUtilities.jsx";
export default function AddToScheduleModal({
quarter,
section,
onAdd,
schedules,
testid = "AddToScheduleModal",
}) {
const [showModal, setShowModal] = useState(false);
const [selectedSchedule, setSelectedSchedule] = useState("");
const filteringSchedules = schedulesFilter(schedules, quarter);
const handleModalClose = () => {
setShowModal(false);
};
const handleModalSave = () => {
onAdd(section, selectedSchedule);
handleModalClose();
};
return (
<>
<Button
variant="success"
onClick={() => setShowModal(true)}
data-testid={`${testid}-add-to-schedule-button`}
>
Add
</Button>
<Modal
show={showModal}
onHide={handleModalClose}
data-testid={`${testid}-modal`}
>
<Modal.Header closeButton>
<Modal.Title>Add to Schedule</Modal.Title>
</Modal.Header>
<Modal.Body>
<Form>
{
/* istanbul ignore next */
filteringSchedules.length > 0 ? (
<Form.Group controlId="scheduleSelect">
<Form.Label>Select Schedule</Form.Label>
<PersonalScheduleSelector
schedule={selectedSchedule}
setSchedule={setSelectedSchedule}
controlId="scheduleSelect"
filteringSchedules={filteringSchedules}
/>
</Form.Group>
) : (
<p data-testid={`${testid}-no-schedules`}>
There are no personal schedules for {yyyyqToQyy(quarter)}.
<Link to="/personalschedules/create">
[Create Personal Schedule]
</Link>
</p>
)
}
</Form>
</Modal.Body>
<Modal.Footer>
<Button
variant="secondary"
onClick={handleModalClose}
data-testid={`${testid}-modal-close-button`}
>
Close
</Button>
<Button
variant="primary"
onClick={handleModalSave}
data-testid={`${testid}-modal-save-button`}
>
Save Changes
</Button>
</Modal.Footer>
</Modal>
</>
);
}
|