1
|
|
|
import * as React from "react"; |
2
|
|
|
import { FormattedMessage, useIntl } from "react-intl"; |
3
|
|
|
import { Link } from "../models/app"; |
4
|
|
|
import { readableDateTime } from "../helpers/dates"; |
5
|
|
|
|
6
|
|
|
export interface Activity { |
7
|
|
|
name: string; |
8
|
|
|
userRole: string; |
9
|
|
|
time: Date; |
10
|
|
|
type: string; |
11
|
|
|
comment: string; |
12
|
|
|
location: string; |
13
|
|
|
link: Link; |
14
|
|
|
} |
15
|
|
|
|
16
|
|
|
type ActivityProps = Activity; |
17
|
|
|
|
18
|
|
|
const Activity: React.FunctionComponent<ActivityProps> = ({ |
19
|
|
|
name, |
20
|
|
|
userRole, |
21
|
|
|
time, |
22
|
|
|
type, |
23
|
|
|
comment, |
24
|
|
|
location, |
25
|
|
|
link, |
26
|
|
|
}) => { |
27
|
|
|
const { locale } = useIntl(); |
28
|
|
|
if (locale !== "en" && locale !== "fr") { |
29
|
|
|
throw new Error("Unexpected locale"); |
30
|
|
|
} |
31
|
|
|
return ( |
32
|
|
|
<div> |
33
|
|
|
<a |
34
|
|
|
href={link.url} |
35
|
|
|
title={link.title} |
36
|
|
|
target="_blank" |
37
|
|
|
rel="noopener noreferrer" |
38
|
|
|
className="tc-job-activity-comment" |
39
|
|
|
data-c-card |
40
|
|
|
data-c-background="white(100)" |
41
|
|
|
data-c-radius="rounded" |
42
|
|
|
data-c-padding="all(1)" |
43
|
|
|
data-c-margin="bottom(.5)" |
44
|
|
|
> |
45
|
|
|
<p |
46
|
|
|
data-c-margin="bottom(.5)" |
47
|
|
|
data-c-color="gray" |
48
|
|
|
data-c-font-size="small" |
49
|
|
|
> |
50
|
|
|
<FormattedMessage |
51
|
|
|
id="activity.commentMetadata" |
52
|
|
|
description="Text with additional information on comment." |
53
|
|
|
defaultMessage="{name} ({userRole}) commented at {time}." |
54
|
|
|
values={{ |
55
|
|
|
name, |
56
|
|
|
userRole, |
57
|
|
|
time: readableDateTime(locale, time), |
58
|
|
|
}} |
59
|
|
|
/> |
60
|
|
|
</p> |
61
|
|
|
<p data-c-margin="bottom(.5)" data-c-color="black"> |
62
|
|
|
<span data-c-font-weight="bold">{type}:</span> {comment} |
63
|
|
|
</p> |
64
|
|
|
<div data-c-grid="gutter(all, 1)"> |
65
|
|
|
<div data-c-grid-item="tp(1of2) ds(2of3)"> |
66
|
|
|
<p data-c-font-size="small" data-c-color="black"> |
67
|
|
|
<FormattedMessage |
68
|
|
|
id="activity.commentLocation.label" |
69
|
|
|
defaultMessage="Comment Located" |
70
|
|
|
description="The label used before the comment location." |
71
|
|
|
/> |
72
|
|
|
{": "} {location} |
73
|
|
|
</p> |
74
|
|
|
</div> |
75
|
|
|
<div |
76
|
|
|
data-c-grid-item="tp(1of2) ds(1of3)" |
77
|
|
|
data-c-align="base(center) tp(right)" |
78
|
|
|
> |
79
|
|
|
<p |
80
|
|
|
data-c-font-size="small" |
81
|
|
|
data-c-font-style="underline" |
82
|
|
|
data-c-color="c1" |
83
|
|
|
> |
84
|
|
|
<FormattedMessage |
85
|
|
|
id="activity.viewComment.label" |
86
|
|
|
defaultMessage="View Comment" |
87
|
|
|
description="The text displayed on the activity link to view comment." |
88
|
|
|
/> |
89
|
|
|
</p> |
90
|
|
|
</div> |
91
|
|
|
</div> |
92
|
|
|
</a> |
93
|
|
|
</div> |
94
|
|
|
); |
95
|
|
|
}; |
96
|
|
|
|
97
|
|
|
export default Activity; |
98
|
|
|
|