Skip to content

Commit dac06df

Browse files
committed
some adjusts
1 parent f64ac07 commit dac06df

File tree

2 files changed

+32
-7
lines changed

2 files changed

+32
-7
lines changed

components/gem/actions/create-candidate/create-candidate.mjs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { SOURCED_FROM } from "../../common/constants.mjs";
2+
import { parseObject } from "../../common/utils.mjs";
23
import gem from "../../gem.app.mjs";
34

45
export default {
@@ -81,7 +82,7 @@ export default {
8182
optional: true,
8283
},
8384
workInfo: {
84-
type: "string",
85+
type: "string[]",
8586
label: "Work Info",
8687
description: "A list of objects containing candidate's work information. **Format: [{\"company\": \"string\", \"title\": \"string\", \"work_start_date\": \"string\", \"work_end_date\": \"string\", \"is_current\": \"string\"}]**. [See the documentation](https://api.gem.com/v0/reference#tag/Candidates/paths/~1v0~1candidates/post) for further details.",
8788
optional: true,
@@ -132,7 +133,7 @@ export default {
132133
is_primary: true,
133134
},
134135
];
135-
if (this.additionalEmails) emails.push(...this.additionalEmails.map((email) => ({
136+
if (this.additionalEmails) emails.push(...parseObject(this.additionalEmails).map((email) => ({
136137
email_address: email,
137138
is_primary: false,
138139
})));
@@ -153,12 +154,12 @@ export default {
153154
company: this.company,
154155
location: this.location,
155156
school: this.school,
156-
educational_info: this.educationalInfo,
157-
work_info: this.workInfo,
158-
profile_urls: this.profileUrls,
157+
educational_info: parseObject(this.educationalInfo),
158+
work_info: parseObject(this.workInfo),
159+
profile_urls: parseObject(this.profileUrls),
159160
phone_number: this.phoneNumber,
160-
project_ids: this.projectIds,
161-
custom_fields: this.customFields,
161+
project_ids: parseObject(this.projectIds),
162+
custom_fields: parseObject(this.customFields),
162163
sourced_from: this.sourcedFrom,
163164
autofill: this.autofill,
164165
},

components/gem/common/utils.mjs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
export const parseObject = (obj) => {
2+
if (!obj) return [];
3+
4+
if (Array.isArray(obj)) {
5+
return obj.map((item) => {
6+
if (typeof item === "string") {
7+
try {
8+
return JSON.parse(item);
9+
} catch (e) {
10+
return item;
11+
}
12+
}
13+
return item;
14+
});
15+
}
16+
if (typeof obj === "string") {
17+
try {
18+
return JSON.parse(obj);
19+
} catch (e) {
20+
return obj;
21+
}
22+
}
23+
return obj;
24+
};

0 commit comments

Comments
 (0)