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

Commit 9c837f7

Browse files
committed
fix: issue #120
1 parent 57e25c6 commit 9c837f7

File tree

3 files changed

+26
-24
lines changed

3 files changed

+26
-24
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/routes/JobDetails/index.jsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import PageHeader from "../../components/PageHeader";
1212
import { useData } from "hooks/useData";
1313
import { getJobById } from "services/jobs";
1414
import { getSkills } from "services/skills";
15+
import { getSelectOptionByValue } from "utils/helpers";
1516
import LoadingIndicator from "../../components/LoadingIndicator";
1617
import MarkdownEditorViewer from "../../components/MarkdownEditorViewer";
1718
import withAuthentication from "../../hoc/withAuthentication";
@@ -85,9 +86,9 @@ const JobDetails = ({ teamId, jobId }) => {
8586
</DataItem>
8687
<DataItem title="Resource Type" icon={<IconDescription />}>
8788
{_.get(
88-
_.find(
89-
RESOURCE_TYPE_OPTIONS,
90-
(t) => t.value === job.resourceType
89+
getSelectOptionByValue(
90+
job.resourceType,
91+
RESOURCE_TYPE_OPTIONS
9192
),
9293
"label"
9394
)}

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)