Skip to content

Commit

Permalink
Add warning when manual entry dates are changed
Browse files Browse the repository at this point in the history
  • Loading branch information
Keskimaki committed Sep 7, 2023
1 parent 302ec02 commit ecfbac5
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions client/components/NewReportPage/NewReportTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export default withRouter(({ rows, batchId, history }) => {
const graders = useSelector((state) => state.graders.data)
const [sent, setSent] = useState(false)
const onlyMissingEnrollments = rows.every(({ entry }) => entry.type === 'ENTRY' && entry.missingEnrolment)
const dateHasChanged = rows.some(({ entry, attainmentDate }) => !moment(attainmentDate).isSame(moment(entry.completionDate), 'day'))

useEffect(() => {
if (sent && !pending && !(error || {}).genericError) {
Expand Down Expand Up @@ -148,6 +149,15 @@ export default withRouter(({ rows, batchId, history }) => {
</Message>
) : null

const ChangedDateInfo = () =>
dateHasChanged ? (
<Message style={styles.missingEnrolmentInfo} warning>
One or more completion date has been changed to match the study right in the enrollment.
<br />
The changed dates are marked with a pencil icon. Please check the new dates before approving.
</Message>
) : null

const CompletionDate = ({ attainmentDate, completionDate }) =>
completionDate ? (
<div style={styles.completionDate}>
Expand Down Expand Up @@ -179,6 +189,7 @@ export default withRouter(({ rows, batchId, history }) => {
after student enrolls to the course.{' '}
</p>
<MissingEnrollmentsInfo />
<ChangedDateInfo />
</Segment>
{sent && error ? (
<Segment basic>
Expand Down

0 comments on commit ecfbac5

Please sign in to comment.