This repository was archived by the owner on Mar 13, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +26
-24
lines changed Expand file tree Collapse file tree 3 files changed +26
-24
lines changed Original file line number Diff line number Diff line change 2
2
* TC Form utilty
3
3
*/
4
4
import _ from "lodash" ;
5
+ import { getSelectOptionByValue } from "utils/helpers" ;
5
6
import { FORM_FIELD_TYPE } from "../../constants" ;
6
7
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
-
28
8
/**
29
9
* Extract value from field by type
30
10
* @param {any } value value
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import PageHeader from "../../components/PageHeader";
12
12
import { useData } from "hooks/useData" ;
13
13
import { getJobById } from "services/jobs" ;
14
14
import { getSkills } from "services/skills" ;
15
+ import { getSelectOptionByValue } from "utils/helpers" ;
15
16
import LoadingIndicator from "../../components/LoadingIndicator" ;
16
17
import MarkdownEditorViewer from "../../components/MarkdownEditorViewer" ;
17
18
import withAuthentication from "../../hoc/withAuthentication" ;
@@ -85,9 +86,9 @@ const JobDetails = ({ teamId, jobId }) => {
85
86
</ DataItem >
86
87
< DataItem title = "Resource Type" icon = { < IconDescription /> } >
87
88
{ _ . get (
88
- _ . find (
89
- RESOURCE_TYPE_OPTIONS ,
90
- ( t ) => t . value === job . resourceType
89
+ getSelectOptionByValue (
90
+ job . resourceType ,
91
+ RESOURCE_TYPE_OPTIONS
91
92
) ,
92
93
"label"
93
94
) }
Original file line number Diff line number Diff line change @@ -17,3 +17,24 @@ export const delay = (duration) =>
17
17
new Promise ( ( resolve ) => {
18
18
setTimeout ( resolve , duration ) ;
19
19
} ) ;
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
+ } ;
You can’t perform that action at this time.
0 commit comments