1
|
|
|
import * as React from "react"; |
2
|
|
|
import { connect } from "react-redux"; |
3
|
|
|
import { defineMessages, useIntl, FormattedMessage } from "react-intl"; |
4
|
|
|
import CommentForm from "../../CommentForm"; |
5
|
|
|
import ActivityFeed from "../../ActivityFeed"; |
6
|
|
|
import { LocationId } from "../../../models/lookupConstants"; |
7
|
|
|
import { RootState } from "../../../store/store"; |
8
|
|
|
import { getComments } from "../../../store/Job/jobSelector"; |
9
|
|
|
import Icon from "../../Icon"; |
10
|
|
|
import { hasKey } from "../../../helpers/queries"; |
11
|
|
|
|
12
|
|
|
export const reviewLocations = defineMessages({ |
13
|
|
|
[LocationId.generic]: { |
14
|
|
|
id: "reviewLocations.jpb.generic", |
15
|
|
|
defaultMessage: "Generic", |
16
|
|
|
description: "Location where the activity is located.", |
17
|
|
|
}, |
18
|
|
|
[LocationId.heading]: { |
19
|
|
|
id: "reviewLocations.jpb.heading", |
20
|
|
|
defaultMessage: "Job Page Heading", |
21
|
|
|
description: "Location where the activity is located.", |
22
|
|
|
}, |
23
|
|
|
[LocationId.basicInfo]: { |
24
|
|
|
id: "reviewLocations.jpb.basicInfo", |
25
|
|
|
defaultMessage: "Basic Information", |
26
|
|
|
description: "Location where the activity is located.", |
27
|
|
|
}, |
28
|
|
|
[LocationId.impact]: { |
29
|
|
|
id: "reviewLocations.jpb.impact", |
30
|
|
|
defaultMessage: "Impact", |
31
|
|
|
description: "Location where the activity is located.", |
32
|
|
|
}, |
33
|
|
|
[LocationId.tasks]: { |
34
|
|
|
id: "reviewLocations.jpb.tasks", |
35
|
|
|
defaultMessage: "Tasks", |
36
|
|
|
description: "Location where the activity is located.", |
37
|
|
|
}, |
38
|
|
|
[LocationId.skills]: { |
39
|
|
|
id: "reviewLocations.jpb.skills", |
40
|
|
|
defaultMessage: "Criteria", |
41
|
|
|
description: "Location where the activity is located.", |
42
|
|
|
}, |
43
|
|
|
[LocationId.langRequirements]: { |
44
|
|
|
id: "reviewLocations.jpb.langRequirements", |
45
|
|
|
defaultMessage: "Language Requirements", |
46
|
|
|
description: "Location where the activity is located.", |
47
|
|
|
}, |
48
|
|
|
[LocationId.environment]: { |
49
|
|
|
id: "reviewLocations.jpb.environment", |
50
|
|
|
defaultMessage: "Work Environment", |
51
|
|
|
description: "Location where the activity is located.", |
52
|
|
|
}, |
53
|
|
|
}); |
54
|
|
|
|
55
|
|
|
interface JobReviewActivityFeedProps { |
56
|
|
|
jobId: number; |
57
|
|
|
isHrAdvisor: boolean; |
58
|
|
|
totalActivities: number; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
const JobReviewActivityFeed: React.FunctionComponent<JobReviewActivityFeedProps> = ({ |
62
|
|
|
jobId, |
63
|
|
|
isHrAdvisor, |
64
|
|
|
totalActivities, |
65
|
|
|
}) => { |
66
|
|
|
const intl = useIntl(); |
67
|
|
|
const locationOptions = Object.values(LocationId) |
68
|
|
|
.filter(location => hasKey(reviewLocations, location)) |
69
|
|
|
.map(location => ({ |
70
|
|
|
value: location, |
71
|
|
|
label: intl.formatMessage(reviewLocations[location]), |
72
|
|
|
})); |
73
|
|
|
|
74
|
|
|
return ( |
75
|
|
|
<section data-c-padding="top(double)"> |
76
|
|
|
<div data-c-accordion-group> |
77
|
|
|
<div data-c-accordion="" className=""> |
78
|
|
|
<button |
79
|
|
|
aria-expanded="false" |
80
|
|
|
data-c-accordion-trigger |
81
|
|
|
tabIndex={0} |
82
|
|
|
type="button" |
83
|
|
|
data-c-background="c1(100)" |
84
|
|
|
data-c-padding="all(1)" |
85
|
|
|
> |
86
|
|
|
<div> |
87
|
|
|
<h3 data-c-font-size="h3" data-c-color="white"> |
88
|
|
|
<FormattedMessage |
89
|
|
|
id="activityfeed.review.header" |
90
|
|
|
defaultMessage="Review Your Job Poster {totalActivities}" |
91
|
|
|
description="The activity feed header." |
92
|
|
|
values={{ |
93
|
|
|
totalActivities: |
94
|
|
|
totalActivities === 0 ? ( |
95
|
|
|
<Icon |
96
|
|
|
icon="fa fa-spinner fa-spin" |
97
|
|
|
accessibleText="Number of activities is loading..." |
98
|
|
|
sematicIcon |
99
|
|
|
/> |
100
|
|
|
) : ( |
101
|
|
|
`(${totalActivities})` |
102
|
|
|
), |
103
|
|
|
}} |
104
|
|
|
/> |
105
|
|
|
</h3> |
106
|
|
|
</div> |
107
|
|
|
<span data-c-visibility="invisible"> |
108
|
|
|
<FormattedMessage |
109
|
|
|
id="activityfeed.review.accordionAccessibleLabel" |
110
|
|
|
defaultMessage="Click to view..." |
111
|
|
|
description="The accessibility text displayed on the activity feed accordion button." |
112
|
|
|
/> |
113
|
|
|
</span> |
114
|
|
|
<p |
115
|
|
|
data-c-accordion-add="" |
116
|
|
|
data-c-font-style="underline" |
117
|
|
|
data-c-color="white" |
118
|
|
|
> |
119
|
|
|
<i className="fas fa-caret-up" /> |
120
|
|
|
</p> |
121
|
|
|
<p |
122
|
|
|
data-c-accordion-remove="" |
123
|
|
|
data-c-font-style="underline" |
124
|
|
|
data-c-color="white" |
125
|
|
|
> |
126
|
|
|
<i className="fas fa-caret-down" /> |
127
|
|
|
</p> |
128
|
|
|
</button> |
129
|
|
|
<div |
130
|
|
|
aria-hidden="false" |
131
|
|
|
data-c-accordion-content |
132
|
|
|
data-c-background="grey(20)" |
133
|
|
|
data-c-padding="all(1)" |
134
|
|
|
> |
135
|
|
|
<CommentForm |
136
|
|
|
jobId={jobId} |
137
|
|
|
isHrAdviser={isHrAdvisor} |
138
|
|
|
location={LocationId.generic} |
139
|
|
|
locationOptions={...locationOptions} |
140
|
|
|
/> |
141
|
|
|
<hr data-c-hr="thin(black)" data-c-margin="top(1)" /> |
142
|
|
|
<ActivityFeed jobId={jobId} isHrAdvisor={isHrAdvisor} /> |
143
|
|
|
</div> |
144
|
|
|
</div> |
145
|
|
|
</div> |
146
|
|
|
</section> |
147
|
|
|
); |
148
|
|
|
}; |
149
|
|
|
|
150
|
|
|
const mapStateToProps = ( |
151
|
|
|
state: RootState, |
152
|
|
|
): { |
153
|
|
|
totalActivities: number; |
154
|
|
|
} => ({ |
155
|
|
|
totalActivities: getComments(state).length, |
156
|
|
|
}); |
157
|
|
|
|
158
|
|
|
export default connect(mapStateToProps, () => ({}))(JobReviewActivityFeed); |
159
|
|
|
|