Skip to content

Commit

Permalink
Merge pull request #473 from NBISweden/dev/hour-feedback
Browse files Browse the repository at this point in the history
Visual feedback on number of hours logged
  • Loading branch information
konere10 authored May 20, 2022
2 parents e6d3580 + 37f5dd4 commit b313e68
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 7 deletions.
4 changes: 4 additions & 0 deletions frontend/src/icons/exclamation-triangle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions frontend/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -621,3 +621,17 @@ Other button classes are defined further down together with other classes for th
display: flex;
justify-content: center;
}

.feedback-check {
position: absolute;
top: 0;
right: 0;
width: 1.5rem;
}

.feedback-warning {
position: absolute;
top: 3px;
right: 3px;
width: 0.7rem;
}
42 changes: 35 additions & 7 deletions frontend/src/pages/Report.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {
getISOWeek,
getISOWeekYear,
setISOWeek,
isPast,
addDays,
} from "date-fns";
import { Row } from "../components/Row";
import { HeaderRow } from "../components/HeaderRow";
Expand All @@ -29,6 +31,8 @@ import { AuthContext } from "../components/AuthProvider";
import { useParams } from "react-router-dom";
import ClimbingBoxLoader from "react-spinners/ClimbingBoxLoader";
import LoadingOverlay from "react-loading-overlay-ts";
import warning from "../icons/exclamation-triangle.svg";
import check from "../icons/check.svg";

const beforeUnloadHandler = (event) => {
event.preventDefault();
Expand Down Expand Up @@ -673,13 +677,37 @@ export const Report = () => {
);
})}
<div className="col-1 cell-container">
<input
aria-label="total of hours spent during the week"
type="text"
className="cell not-outline"
value={getTotalHoursWeek()}
readOnly
/>
<div className="comment-container">
<input
aria-label="total of hours spent during the week"
type="text"
className="cell not-outline"
value={getTotalHoursWeek()}
readOnly
/>
{/* Only show warnings for weeks that have passed.
It must be at least Saturday. */}
{isPast(addDays(currentWeekArray[4], 1)) && (
<img
src={getTotalHoursWeek() === 40 ? check : warning}
alt={
getTotalHoursWeek() === 40
? "check: 40 hours logged this week"
: "warning: less or more than 40 hours logged this week"
}
className={
getTotalHoursWeek() === 40
? "feedback-check"
: "feedback-warning"
}
title={
getTotalHoursWeek() === 40
? "40 hours logged"
: "less or more than 40 hours logged"
}
/>
)}
</div>
</div>
</div>
</section>
Expand Down

0 comments on commit b313e68

Please sign in to comment.