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

tweak: End of Service link functionality #574

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
8 changes: 8 additions & 0 deletions assets/css/info-popover.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@import "./variables.scss";

.popover {
--bs-popover-bg: #{$dark-bg};
--bs-popover-body-color: #{$text-primary};
--bs-popover-border-color: #{$border-primary};
margin-bottom: 13px;
}
1 change: 1 addition & 0 deletions assets/css/pa-messages.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@
@include flat-button;
--bs-btn-color: #{$text-link-primary};
padding-left: 0;
padding-right: 8px;
}

.audioReviewedText {
Expand Down
27 changes: 27 additions & 0 deletions assets/js/components/Dashboard/InfoPopover.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from "react";
import { OverlayTrigger, Popover } from "react-bootstrap";
import { InfoCircleFill } from "react-bootstrap-icons";
import { type Placement } from "react-bootstrap/esm/types";
import * as infoPopoverStyles from "Styles/info-popover.module.scss";

interface Props {
popoverText: string;
placement: Placement;
}

const InfoPopover = ({ popoverText, placement }: Props) => {
return (
<OverlayTrigger
placement={placement}
overlay={
<Popover id="info-popover" className={infoPopoverStyles.popover} body>
{popoverText}
</Popover>
}
>
<InfoCircleFill fill="#8ECDFF" />
</OverlayTrigger>
);
};

export default InfoPopover;
70 changes: 46 additions & 24 deletions assets/js/components/Dashboard/PaMessageForm/MainForm.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
/* eslint-disable jsx-a11y/media-has-caption */
import React, { Dispatch, FormEvent, SetStateAction, useState } from "react";
import { Button, Card, Col, Container, Form, Row } from "react-bootstrap";
import DaysPicker from "Components/DaysPicker";
import PriorityPicker from "Components/PriorityPicker";
import IntervalPicker from "Components/IntervalPicker";
import MessageTextBox from "Components/MessageTextBox";
import { useNavigate } from "react-router-dom";
import moment, { type Moment } from "moment";
import {
Expand All @@ -15,6 +11,11 @@ import {
VolumeUpFill,
} from "react-bootstrap-icons";
import cx from "classnames";
import DaysPicker from "Components/DaysPicker";
import PriorityPicker from "Components/PriorityPicker";
import IntervalPicker from "Components/IntervalPicker";
import MessageTextBox from "Components/MessageTextBox";
import InfoPopover from "Components/InfoPopover";
import { ActivePeriod, Alert as AlertModel } from "Models/alert";
import { getAlertEarliestStartLatestEnd } from "../../../util";
import { AudioPreview, Page } from "./types";
Expand Down Expand Up @@ -167,7 +168,7 @@ const MainForm = ({
>
Start
</Form.Label>
<div className="d-flex gap-3">
<div className="d-flex gap-3 align-items-center">
<div className={paMessageStyles.startEndItem}>
<Form.Control
className={cx(paMessageStyles.inputField, "picker")}
Expand Down Expand Up @@ -208,15 +209,23 @@ const MainForm = ({
)
}
/>
<Button
className={paMessageStyles.serviceTimeButton}
variant="link"
onClick={() =>
setStartDateTime(moment(startDateTime).hour(3).minute(0))
}
>
Start of service day
</Button>
<div>
<Button
className={paMessageStyles.serviceTimeButton}
variant="link"
onClick={() =>
setStartDateTime(
moment(startDateTime).hour(3).minute(0),
)
}
>
Start of service day
</Button>
<InfoPopover
placement="top"
popoverText="A service day starts at 3:00 AM, and ends at 3:00 AM the following day"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move this duplicated string into a constant?

/>
</div>
</div>
</Form.Group>
</Row>
Expand Down Expand Up @@ -244,7 +253,7 @@ const MainForm = ({
/>
)}
{!endWithEffectPeriod && endDateTime !== null && (
<div className="d-flex gap-3">
<div className="d-flex gap-3 align-items-center">
<div className={paMessageStyles.startEndItem}>
<Form.Control
className={cx(paMessageStyles.inputField, "picker")}
Expand Down Expand Up @@ -285,15 +294,28 @@ const MainForm = ({
)
}
/>
<Button
className={paMessageStyles.serviceTimeButton}
variant="link"
onClick={() =>
setEndDateTime(moment(endDateTime).hour(3).minute(0))
}
>
End of service day
</Button>
<div>
<Button
className={paMessageStyles.serviceTimeButton}
variant="link"
onClick={() => {
const newMoment = moment(endDateTime)
.hour(3)
.minute(0);
if (endDateTime.hour() >= 3) {
newMoment.day(endDateTime.day() + 1);
}

setEndDateTime(newMoment);
}}
>
End of service day
</Button>
<InfoPopover
placement="top"
popoverText="A service day starts at 3:00 AM, and ends at 3:00 AM the following day"
/>
</div>
</div>
)}
</Form.Group>
Expand Down
Loading