Skip to content

Commit 04060d5

Browse files
committed
1 parent cbd5869 commit 04060d5

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import "./styles.module.scss";
1313
import { formatDateRange } from "utils/format";
1414
import { Link } from "@reach/router";
1515

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

7980
TeamPositions.propTypes = {
8081
teamId: PT.string,
82+
getOpenPositionsLabel: PT.func,
8183
positions: PT.arrayOf(
8284
PT.shape({
8385
title: PT.string,

src/routes/MyTeamsDetails/index.jsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ 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";
1415
import TeamSummary from "./components/TeamSummary";
1516
import TeamMembers from "./components/TeamMembers";
1617
import TeamPositions from "./components/TeamPositions";
@@ -19,6 +20,10 @@ import withAuthentication from "../../hoc/withAuthentication";
1920
const MyTeamsDetails = ({ teamId }) => {
2021
const [team, loadingError] = useData(getTeamById, teamId);
2122

23+
const getOpenPositionsLabel = (job) => {
24+
return formatOpenPositions(job, team.resources);
25+
};
26+
2227
return (
2328
<Page title="Team Details">
2429
{!team ? (
@@ -28,7 +33,11 @@ const MyTeamsDetails = ({ teamId }) => {
2833
<PageHeader title={team.name} backTo="/taas/myteams" />
2934
<TeamSummary team={team} />
3035
<TeamMembers team={team} />
31-
<TeamPositions positions={team.jobs || []} teamId={teamId} />
36+
<TeamPositions
37+
positions={team.jobs || []}
38+
teamId={teamId}
39+
getOpenPositionsLabel={getOpenPositionsLabel}
40+
/>
3241
</>
3342
)}
3443
</Page>

src/utils/format.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,3 +200,27 @@ export const formatPageTitle = (pageTitle) => {
200200

201201
return formattedPageTitle;
202202
};
203+
204+
/**
205+
* Format open positions.
206+
*
207+
* @param {Object} job job object
208+
* @param {Array} resources resource list
209+
*
210+
* @returns {string} open positions string
211+
*/
212+
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`;
223+
} else {
224+
return `${jobs.length} / ${job.numPositions} open positions`;
225+
}
226+
};

0 commit comments

Comments
 (0)