Skip to content

Commit cca6a2e

Browse files
committed
Merge pull request #625 in DAT/ipr-client from release/v5.0.2 to master
* commit 'ac2368e18e4e62d9851c45b03c62e2e400075b9c': 5.0.2 Fix last ?. format in signature card Fix signature typing Use ts .? operator Match dates to old signature format Fix signatures using wrong date, render missing on sign
2 parents 863ba33 + ac2368e commit cca6a2e

File tree

7 files changed

+48
-36
lines changed

7 files changed

+48
-36
lines changed

app/components/SignatureCard/index.tsx

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useContext } from 'react';
1+
import React, { useContext, useState, useEffect } from 'react';
22
import {
33
Paper,
44
Typography,
@@ -9,27 +9,39 @@ import GestureIcon from '@material-ui/icons/Gesture';
99
import RemoveCircleIcon from '@material-ui/icons/RemoveCircle';
1010

1111
import EditContext from '../EditContext';
12+
import { formatDate } from '../../utils/date';
1213

1314
import './index.scss';
1415

1516
const NON_BREAKING_SPACE = '\u00A0';
1617

1718
type Props = {
1819
title: string,
19-
signature: any | object,
20-
onClick: Function,
20+
signatures: null | Record<string, unknown | Record<string, unknown>>,
21+
onClick: (arg0: boolean, arg1: string) => void,
2122
role: 'author' | 'reviewer',
2223
isPrint: boolean,
2324
};
2425

2526
const SignatureCard: React.FC<Props> = ({
2627
title,
27-
signature,
28+
signatures,
2829
onClick,
2930
role,
3031
isPrint,
3132
}) => {
3233
const { canEdit } = useContext(EditContext);
34+
const [userSignature, setUserSignature] = useState<Record<string, unknown>>({});
35+
36+
useEffect(() => {
37+
if (signatures && role) {
38+
if (role === 'author') {
39+
setUserSignature(signatures.authorSignature);
40+
} else {
41+
setUserSignature(signatures.reviewerSignature);
42+
}
43+
}
44+
}, [signatures, role]);
3345

3446
const handleSign = () => {
3547
onClick(true, role);
@@ -46,11 +58,11 @@ const SignatureCard: React.FC<Props> = ({
4658
<Typography variant="body2" display="inline">
4759
{`${title}: `}
4860
</Typography>
49-
{signature && signature.ident ? (
61+
{userSignature?.ident ? (
5062
<Typography variant="body2" display="inline">
51-
{signature.firstName}
63+
{userSignature.firstName}
5264
{' '}
53-
{signature.lastName}
65+
{userSignature.lastName}
5466
</Typography>
5567
) : (
5668
<Typography variant="body2" display="inline">
@@ -60,14 +72,12 @@ const SignatureCard: React.FC<Props> = ({
6072
</div>
6173
<div className="signatures-print__value">
6274
<Typography variant="body2" display="inline">
63-
{`Date: `}
75+
{'Date: '}
6476
</Typography>
65-
{signature && signature.ident ? (
66-
<Typography variant="body2" display="inline">
67-
{signature.updatedAt
68-
? signature.updatedAt
69-
: signature.createdAt}
70-
</Typography>
77+
{signatures?.ident ? (
78+
<Typography variant="body2" display="inline">
79+
{role === 'author' ? formatDate(signatures.authorSignedAt, true) : formatDate(signatures.reviewerSignedAt, true)}
80+
</Typography>
7181
) : (
7282
<Typography display="inline">
7383
{NON_BREAKING_SPACE}
@@ -84,14 +94,14 @@ const SignatureCard: React.FC<Props> = ({
8494
<Typography variant="body2">
8595
{title}
8696
</Typography>
87-
{signature && signature.ident && (
97+
{userSignature?.ident && (
8898
<Typography>
89-
{signature.firstName}
99+
{userSignature.firstName}
90100
{' '}
91-
{signature.lastName}
101+
{userSignature.lastName}
92102
</Typography>
93103
)}
94-
{(!signature || !signature.ident) && canEdit && (
104+
{!userSignature?.ident && canEdit && (
95105
<>
96106
<Button
97107
onClick={handleSign}
@@ -109,19 +119,17 @@ const SignatureCard: React.FC<Props> = ({
109119
<Typography variant="body2">
110120
Date
111121
</Typography>
112-
{signature && signature.ident ? (
113-
<Typography>
114-
{signature.updatedAt
115-
? signature.updatedAt
116-
: signature.createdAt}
117-
</Typography>
122+
{signatures?.ident ? (
123+
<Typography>
124+
{role === 'author' ? formatDate(signatures.authorSignedAt, true) : formatDate(signatures.reviewerSignedAt, true)}
125+
</Typography>
118126
) : (
119127
<Typography>
120128
{NON_BREAKING_SPACE}
121129
</Typography>
122130
)}
123131
</div>
124-
{signature && signature.ident && canEdit && (
132+
{userSignature?.ident && canEdit && (
125133
<div className="signatures__button">
126134
<IconButton
127135
size="small"

app/utils/date.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,19 @@ const getDate = (time = true) => {
1313
return formattedDate.replace(', ', '__').replace(/:/g, '-');
1414
};
1515

16-
const formatDate = (date) => {
16+
const formatDate = (date, long = false) => {
1717
const convertedDate = new Date(date);
1818
const formattedDate = new Intl.DateTimeFormat('en-ca', {
19+
weekday: long ? 'long' : undefined,
20+
month: long ? 'long' : '2-digit',
21+
day: 'numeric',
1922
year: 'numeric',
20-
month: '2-digit',
21-
day: '2-digit',
23+
hour: long ? '2-digit' : undefined,
24+
minute: long ? '2-digit' : undefined,
25+
hour12: false,
2226
}).format(convertedDate);
2327

24-
return formattedDate.replace(', ', '-');
28+
return formattedDate;
2529
};
2630

2731
export {

app/views/ReportView/components/AnalystComments/analyst-comments.pug

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ section.analyst
1818
div(flex=25, layout="column")
1919
h5 Author
2020
div(flex, layout="row")
21-
span(ng-if="$ctrl.canEdit", ng-show="!$ctrl.signatures.authorSignature || !$ctrl.signatures", layout="row", layout-align="start center", ng-click="$ctrl.sign('author')").clickable
21+
span(ng-if="$ctrl.canEdit", ng-show="!$ctrl.signatures.authorSignature.ident || !$ctrl.signatures", layout="row", layout-align="start center", ng-click="$ctrl.sign('author')").clickable
2222
md-icon(style="margin-right: 5px;") gesture
2323
span Sign
2424
span(ng-show="$ctrl.signatures.authorSignature.ident") {{$ctrl.signatures.authorSignature.firstName}} {{$ctrl.signatures.authorSignature.lastName}}
@@ -37,7 +37,7 @@ section.analyst
3737
div(flex=25, layout="column")
3838
h5 Reviewer
3939
div(flex, layout="row")
40-
span(ng-if="$ctrl.canEdit", ng-show="!$ctrl.signatures.reviewerSignature || !$ctrl.signatures", layout="row", layout-align="start center", ng-click="$ctrl.sign('reviewer')").clickable
40+
span(ng-if="$ctrl.canEdit", ng-show="!$ctrl.signatures.reviewerSignature.ident || !$ctrl.signatures", layout="row", layout-align="start center", ng-click="$ctrl.sign('reviewer')").clickable
4141
md-icon(style="margin-right: 5px;") gesture
4242
span Sign
4343
span(ng-show="$ctrl.signatures.reviewerSignature.ident") {{$ctrl.signatures.reviewerSignature.firstName}} {{$ctrl.signatures.reviewerSignature.lastName}}

app/views/ReportView/components/ProbeSummary/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,14 +264,14 @@ const ProbeSummary: React.FC<Props> = ({
264264
<div className={`${isPrint ? 'probe-summary__signatures' : ''}`}>
265265
<SignatureCard
266266
title={`${isPrint ? 'Manual Review' : 'Ready'}`}
267-
signature={signatures ? signatures.authorSignature : null}
267+
signatures={signatures}
268268
onClick={handleSign}
269269
role="author"
270270
isPrint={isPrint}
271271
/>
272272
<SignatureCard
273273
title="Reviewer"
274-
signature={signatures ? signatures.reviewerSignature : null}
274+
signatures={signatures}
275275
onClick={handleSign}
276276
role="reviewer"
277277
isPrint={isPrint}

app/views/ReportView/components/Settings/report-settings.pug

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ section.meta
3636
div(layout="column", ng-if="!$ctrl.report.users.includes($ctrl.user)")
3737
md-subheader.md-no-sticky Analysis Status
3838
div(ng-if="$ctrl.report.analysisStartedAt").analysis__start
39-
span Analysis started: {{$ctrl.formatDate($ctrl.report.analysisStartedAt)}}
39+
span Analysis started: {{$ctrl.formatDate($ctrl.report.analysisStartedAt, true)}}
4040
md-tooltip(ng-if="!$ctrl.report.analysisStartedAt && !$ctrl.canStartAnalysis", md-direction="bottom") Only assigned users can start the analysis
4141
md-button(ng-click="$ctrl.startAnalysis()", ng-if="!$ctrl.report.analysisStartedAt", ng-disabled="!$ctrl.canStartAnalysis").md-accent Start Analysis
4242
md-subheader(ng-if="$ctrl.showBindings").md-no-sticky User Associations

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"private": true,
33
"name": "ipr-client",
4-
"version": "5.0.1",
4+
"version": "5.0.2",
55
"keywords": [],
66
"license": "GPL-3.0",
77
"sideEffects": false,

0 commit comments

Comments
 (0)