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

Commit b0d6864

Browse files
committed
fix: show unsupported job skills
ref issue #84
1 parent c375bb5 commit b0d6864

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

src/components/TCForm/utils.js

+25-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,27 @@
44
import _ from "lodash";
55
import { FORM_FIELD_TYPE } from "../../constants";
66

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+
728
/**
829
* Extract value from field by type
930
* @param {any} value value
@@ -18,12 +39,14 @@ const extractValue = (value, field) => {
1839
switch (field.type) {
1940
case FORM_FIELD_TYPE.SELECT: {
2041
return field.isMulti
21-
? value.map((x) => field.selectOptions.find((y) => y.value === x))
22-
: field.selectOptions.find((y) => y.value === value);
42+
? value.map((valueItem) => getSelectOptionByValue(valueItem, field.selectOptions))
43+
: getSelectOptionByValue(value, field.selectOptions)
2344
}
45+
2446
case FORM_FIELD_TYPE.DATE: {
2547
return new Date(value);
2648
}
49+
2750
default: {
2851
return value;
2952
}

0 commit comments

Comments
 (0)