Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 5b3081e

Browse files
committedFeb 17, 2021
fix: make improvements
1 parent 04060d5 commit 5b3081e

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed
 

‎src/routes/MyTeamsDetails/components/TeamPositions/index.jsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import SkillsList, { skillShape } from "components/SkillsList";
1010
import Button from "components/Button";
1111
import { POSITION_STATUS, POSITION_STATUS_TO_TEXT, RATE_TYPE } from "constants";
1212
import "./styles.module.scss";
13-
import { formatDateRange } from "utils/format";
13+
import { formatDateRange, formatOpenPositions } from "utils/format";
1414
import { Link } from "@reach/router";
1515

16-
const TeamPositions = ({ teamId, positions, getOpenPositionsLabel }) => {
16+
const TeamPositions = ({ teamId, positions, resources }) => {
1717
return (
1818
<div styleName="team-positions">
1919
<div styleName="team-position-header">
@@ -41,7 +41,7 @@ const TeamPositions = ({ teamId, positions, getOpenPositionsLabel }) => {
4141
<strong>{position.title}</strong>
4242
</Link>
4343
<SkillsList skills={position.skills} limit={5} />
44-
<div>{getOpenPositionsLabel(position)}</div>
44+
<div>{formatOpenPositions(position, resources)}</div>
4545
</div>
4646
<div styleName="table-group-first-inner">
4747
<div styleName="table-cell cell-date">
@@ -79,7 +79,6 @@ const TeamPositions = ({ teamId, positions, getOpenPositionsLabel }) => {
7979

8080
TeamPositions.propTypes = {
8181
teamId: PT.string,
82-
getOpenPositionsLabel: PT.func,
8382
positions: PT.arrayOf(
8483
PT.shape({
8584
title: PT.string,
@@ -91,6 +90,16 @@ TeamPositions.propTypes = {
9190
status: PT.oneOf(Object.values(POSITION_STATUS)),
9291
})
9392
),
93+
resources: PT.arrayOf(
94+
PT.shape({
95+
id: PT.string,
96+
handle: PT.string,
97+
firstName: PT.string,
98+
lastName: PT.string,
99+
skills: PT.arrayOf(skillShape),
100+
skillsMatched: PT.number,
101+
})
102+
),
94103
};
95104

96105
export default TeamPositions;

‎src/routes/MyTeamsDetails/index.jsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import PageHeader from "components/PageHeader";
1111
import { useData } from "hooks/useData";
1212
import { getTeamById } from "services/teams";
1313
import LoadingIndicator from "components/LoadingIndicator";
14-
import { formatOpenPositions } from "utils/format";
1514
import TeamSummary from "./components/TeamSummary";
1615
import TeamMembers from "./components/TeamMembers";
1716
import TeamPositions from "./components/TeamPositions";
@@ -20,10 +19,6 @@ import withAuthentication from "../../hoc/withAuthentication";
2019
const MyTeamsDetails = ({ teamId }) => {
2120
const [team, loadingError] = useData(getTeamById, teamId);
2221

23-
const getOpenPositionsLabel = (job) => {
24-
return formatOpenPositions(job, team.resources);
25-
};
26-
2722
return (
2823
<Page title="Team Details">
2924
{!team ? (
@@ -36,7 +31,7 @@ const MyTeamsDetails = ({ teamId }) => {
3631
<TeamPositions
3732
positions={team.jobs || []}
3833
teamId={teamId}
39-
getOpenPositionsLabel={getOpenPositionsLabel}
34+
resources={team.resources}
4035
/>
4136
</>
4237
)}

‎src/utils/format.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -210,17 +210,13 @@ export const formatPageTitle = (pageTitle) => {
210210
* @returns {string} open positions string
211211
*/
212212
export const formatOpenPositions = (job, resources) => {
213-
const jobs = _.filter(resources, (r) => {
214-
return r.jobId === job.id;
215-
});
216-
if (jobs.length === 0) {
217-
if (job.numPositions <= 1) {
218-
return `${job.numPositions} open position`;
219-
}
220-
return `${job.numPositions} open positions`;
221-
} else if (job.numPositions === 1) {
222-
return `${jobs.length} / ${job.numPositions} open position`;
213+
const jobResources = _.filter(resources, { jobId: job.id });
214+
if (jobResources.length === 0) {
215+
return `${formatPlural(job.numPositions, "open position")}`;
223216
} else {
224-
return `${jobs.length} / ${job.numPositions} open positions`;
217+
return `${jobResources.length} / ${formatPlural(
218+
job.numPositions,
219+
"open position"
220+
)}`;
225221
}
226222
};

0 commit comments

Comments
 (0)