File tree 3 files changed +37
-2
lines changed 3 files changed +37
-2
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ import "./styles.module.scss";
13
13
import { formatDateRange } from "utils/format" ;
14
14
import { Link } from "@reach/router" ;
15
15
16
- const TeamPositions = ( { teamId, positions } ) => {
16
+ const TeamPositions = ( { teamId, positions, getOpenPositionsLabel } ) => {
17
17
return (
18
18
< div styleName = "team-positions" >
19
19
< div styleName = "team-position-header" >
@@ -41,6 +41,7 @@ const TeamPositions = ({ teamId, positions }) => {
41
41
< strong > { position . title } </ strong >
42
42
</ Link >
43
43
< SkillsList skills = { position . skills } limit = { 5 } />
44
+ < div > { getOpenPositionsLabel ( position ) } </ div >
44
45
</ div >
45
46
< div styleName = "table-group-first-inner" >
46
47
< div styleName = "table-cell cell-date" >
@@ -78,6 +79,7 @@ const TeamPositions = ({ teamId, positions }) => {
78
79
79
80
TeamPositions . propTypes = {
80
81
teamId : PT . string ,
82
+ getOpenPositionsLabel : PT . func ,
81
83
positions : PT . arrayOf (
82
84
PT . shape ( {
83
85
title : PT . string ,
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import PageHeader from "components/PageHeader";
11
11
import { useData } from "hooks/useData" ;
12
12
import { getTeamById } from "services/teams" ;
13
13
import LoadingIndicator from "components/LoadingIndicator" ;
14
+ import { formatOpenPositions } from "utils/format" ;
14
15
import TeamSummary from "./components/TeamSummary" ;
15
16
import TeamMembers from "./components/TeamMembers" ;
16
17
import TeamPositions from "./components/TeamPositions" ;
@@ -19,6 +20,10 @@ import withAuthentication from "../../hoc/withAuthentication";
19
20
const MyTeamsDetails = ( { teamId } ) => {
20
21
const [ team , loadingError ] = useData ( getTeamById , teamId ) ;
21
22
23
+ const getOpenPositionsLabel = ( job ) => {
24
+ return formatOpenPositions ( job , team . resources ) ;
25
+ } ;
26
+
22
27
return (
23
28
< Page title = "Team Details" >
24
29
{ ! team ? (
@@ -28,7 +33,11 @@ const MyTeamsDetails = ({ teamId }) => {
28
33
< PageHeader title = { team . name } backTo = "/taas/myteams" />
29
34
< TeamSummary team = { team } />
30
35
< TeamMembers team = { team } />
31
- < TeamPositions positions = { team . jobs || [ ] } teamId = { teamId } />
36
+ < TeamPositions
37
+ positions = { team . jobs || [ ] }
38
+ teamId = { teamId }
39
+ getOpenPositionsLabel = { getOpenPositionsLabel }
40
+ />
32
41
</ >
33
42
) }
34
43
</ Page >
Original file line number Diff line number Diff line change @@ -200,3 +200,27 @@ export const formatPageTitle = (pageTitle) => {
200
200
201
201
return formattedPageTitle ;
202
202
} ;
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
+ } ;
You can’t perform that action at this time.
0 commit comments