Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preventing future dates #178

Merged
merged 1 commit into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import { selectOfficers } from "../../../../store/reducers/officer";
import { CreateComplaintHeader } from "./create-complaint-header";
import { Button } from "react-bootstrap";
import { CancelConfirm } from "../../../../types/modal/modal-types";
import { useNavigate } from "react-router-dom";
import {
createAllegationComplaint,
createWildlifeComplaint,
Expand All @@ -45,6 +44,7 @@ import { Complaint } from "../../../../types/complaints/complaint";
import { ToggleError } from "../../../../common/toast";
import { ToastContainer } from "react-toastify";
import "react-toastify/dist/ReactToastify.css";
import { useNavigate } from "react-router-dom";

export const CreateComplaint: FC = () => {
const dispatch = useAppDispatch();
Expand Down Expand Up @@ -852,23 +852,23 @@ export const CreateComplaint: FC = () => {
const [longitude, setLongitude] = useState<string>("");

function handleIncidentDateTimeChange(date: Date) {
setSelectedIncidentDateTime(date);

if (complaintType === COMPLAINT_TYPES.HWCR) {
let hwcrComplaint: HwcrComplaint = cloneDeep(
createComplaint,
) as HwcrComplaint;
hwcrComplaint.complaint_identifier.incident_utc_datetime =
date;
setCreateComplaint(hwcrComplaint);
} else if (complaintType === COMPLAINT_TYPES.ERS) {
let allegationComplaint: AllegationComplaint = cloneDeep(
createComplaint,
) as AllegationComplaint;
allegationComplaint.complaint_identifier.incident_utc_datetime =
date;
setCreateComplaint(allegationComplaint);
}
setSelectedIncidentDateTime(date);
if (complaintType === COMPLAINT_TYPES.HWCR) {
let hwcrComplaint: HwcrComplaint = cloneDeep(
createComplaint,
) as HwcrComplaint;
hwcrComplaint.complaint_identifier.incident_utc_datetime =
date;
setCreateComplaint(hwcrComplaint);
} else if (complaintType === COMPLAINT_TYPES.ERS) {
let allegationComplaint: AllegationComplaint = cloneDeep(
createComplaint,
) as AllegationComplaint;
allegationComplaint.complaint_identifier.incident_utc_datetime =
date;
setCreateComplaint(allegationComplaint);
}
}

const handleCoordinateChange = (input: string, type: Coordinates) => {
Expand Down Expand Up @@ -1021,6 +1021,8 @@ export const CreateComplaint: FC = () => {
}
};

const maxDate = new Date();

return (
<div className="comp-complaint-details">
<ToastContainer />
Expand Down Expand Up @@ -1191,15 +1193,16 @@ export const CreateComplaint: FC = () => {
>
<label>Incident Time</label>
<DatePicker
showTimeInput
id="complaint-incident-time"
showIcon
timeInputLabel="Time:"
onChange={handleIncidentDateTimeChange}
selected={selectedIncidentDateTime}
showTimeInput
dateFormat="yyyy-MM-dd HH:mm"
timeFormat="HH:mm"
wrapperClassName="comp-details-edit-calendar-input"
maxDate={maxDate}
/>
</div>
{complaintType === COMPLAINT_TYPES.HWCR && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -997,6 +997,8 @@ export const ComplaintDetailsEdit: FC = () => {
}
}

const maxDate = new Date();

return (
<div className="comp-complaint-details">
<ToastContainer />
Expand Down Expand Up @@ -1198,6 +1200,7 @@ export const ComplaintDetailsEdit: FC = () => {
dateFormat="yyyy-MM-dd HH:mm"
timeFormat="HH:mm"
wrapperClassName="comp-details-edit-calendar-input"
maxDate={maxDate}
/>
</div>
{complaintType === COMPLAINT_TYPES.HWCR && (
Expand Down
Loading