Cancelled
Push — task/review-page-comment-feed ( 140bdc...cc85f1 )
by Yonathan
09:48
created

resources/assets/js/components/JobBuilder/Review/JobReviewActivityFeed.tsx   A

Complexity

Total Complexity 1
Complexity/F 0

Size

Lines of Code 161
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

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