Skip to content

Commit 18f6f6c

Browse files
committed
some adjusts
1 parent ad9d922 commit 18f6f6c

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

components/leaddyno/actions/create-purchase/create-purchase.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { parseObject } from "../../common/utils.mjs";
12
import leaddyno from "../../leaddyno.app.mjs";
23

34
export default {
@@ -76,7 +77,7 @@ export default {
7677
commission_amount_override: this.commissionAmount && parseFloat(this.commissionAmount),
7778
description: this.description,
7879
reassign_affiliate: this.reassignAffiliate,
79-
line_items: this.lineItems,
80+
line_items: parseObject(this.lineItems),
8081
},
8182
});
8283

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 undefined;
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)