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

Commit e021dc7

Browse files
authored
Merge pull request #127 from yoution/issue-120
fix: issue #120
2 parents 98354e5 + 9c837f7 commit e021dc7

File tree

5 files changed

+46
-25
lines changed

5 files changed

+46
-25
lines changed

src/components/TCForm/utils.js

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,9 @@
22
* TC Form utilty
33
*/
44
import _ from "lodash";
5+
import { getSelectOptionByValue } from "utils/helpers";
56
import { FORM_FIELD_TYPE } from "../../constants";
67

7-
/**
8-
* Returns the option from list of option by value
9-
*
10-
* @param {any} value value of option
11-
* @param {[{ label: string, value: any }]} selectOptions list of option
12-
*
13-
* @returns {{ label: string, value: any }} select option
14-
*/
15-
const getSelectOptionByValue = (value, selectOptions) => {
16-
const option = _.find(selectOptions, { value });
17-
18-
if (!option) {
19-
return {
20-
label: `Unsuppored value: ${value}`,
21-
value,
22-
};
23-
}
24-
25-
return option;
26-
};
27-
288
/**
299
* Extract value from field by type
3010
* @param {any} value value

src/constants/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,17 @@ export const WORKLOAD_OPTIONS = [
266266
{ value: "fractional", label: "fractional" },
267267
];
268268

269+
/**
270+
* resourceType options
271+
*/
272+
export const RESOURCE_TYPE_OPTIONS = [
273+
{ value: null, label: "" },
274+
{ value: "designer", label: "Designer" },
275+
{ value: "software-developer", label: "Software Developer" },
276+
{ value: "data-scientist", label: "Data Scientist" },
277+
{ value: "data-engineer", label: "Data Engineer" },
278+
];
279+
269280
/**
270281
* status options
271282
*/

src/routes/JobDetails/index.jsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66
*/
77
import React, { useEffect, useState } from "react";
88
import PT from "prop-types";
9+
import _ from "lodash";
910
import Page from "../../components/Page";
1011
import PageHeader from "../../components/PageHeader";
1112
import { useData } from "hooks/useData";
1213
import { getJobById } from "services/jobs";
1314
import { getSkills } from "services/skills";
15+
import { getSelectOptionByValue } from "utils/helpers";
1416
import LoadingIndicator from "../../components/LoadingIndicator";
1517
import MarkdownEditorViewer from "../../components/MarkdownEditorViewer";
1618
import withAuthentication from "../../hoc/withAuthentication";
@@ -20,6 +22,7 @@ import IconComputer from "../../assets/images/icon-computer.svg";
2022
import IconDescription from "../../assets/images/icon-description.svg";
2123
import IconOpenings from "../../assets/images/icon-openings.svg";
2224
import Button from "../../components/Button";
25+
import { RESOURCE_TYPE_OPTIONS } from "../../constants";
2326
import { formatDate } from "utils/format";
2427
import "./styles.module.scss";
2528
import { hasPermission } from "utils/permissions";
@@ -82,7 +85,13 @@ const JobDetails = ({ teamId, jobId }) => {
8285
{job.duration || "TBD"}
8386
</DataItem>
8487
<DataItem title="Resource Type" icon={<IconDescription />}>
85-
{job.resourceType}
88+
{_.get(
89+
getSelectOptionByValue(
90+
job.resourceType,
91+
RESOURCE_TYPE_OPTIONS
92+
),
93+
"label"
94+
)}
8695
</DataItem>
8796
<DataItem
8897
title="Resource Rate Frequency"

src/routes/JobForm/utils.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
RATE_TYPE_OPTIONS,
88
STATUS_OPTIONS,
99
WORKLOAD_OPTIONS,
10+
RESOURCE_TYPE_OPTIONS,
1011
FORM_ROW_TYPE,
1112
FORM_FIELD_TYPE,
1213
} from "../../constants";
@@ -85,10 +86,9 @@ export const getEditJobConfig = (
8586
},
8687
{
8788
label: "Resource Type",
88-
type: FORM_FIELD_TYPE.TEXT,
89+
type: FORM_FIELD_TYPE.SELECT,
8990
name: "resourceType",
90-
maxLength: 255,
91-
placeholder: "Resource Type",
91+
selectOptions: RESOURCE_TYPE_OPTIONS,
9292
},
9393
{
9494
label: "Resource Rate Frequency",

src/utils/helpers.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,24 @@ export const delay = (duration) =>
1717
new Promise((resolve) => {
1818
setTimeout(resolve, duration);
1919
});
20+
21+
/**
22+
* Returns the option from list of option by value
23+
*
24+
* @param {any} value value of option
25+
* @param {[{ label: string, value: any }]} selectOptions list of option
26+
*
27+
* @returns {{ label: string, value: any }} select option
28+
*/
29+
export const getSelectOptionByValue = (value, selectOptions) => {
30+
const option = _.find(selectOptions, { value });
31+
32+
if (!option) {
33+
return {
34+
label: `Unsuppored value: ${value}`,
35+
value,
36+
};
37+
}
38+
39+
return option;
40+
};

0 commit comments

Comments
 (0)