Skip to content

Commit 0f16150

Browse files
committed
Add some props
1 parent 7a2b467 commit 0f16150

File tree

1 file changed

+118
-5
lines changed

1 file changed

+118
-5
lines changed

components/richpanel/actions/create-ticket/create-ticket.mjs

Lines changed: 118 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,28 @@ export default {
2424
"status",
2525
],
2626
},
27+
subject: {
28+
type: "string",
29+
label: "Subject",
30+
description: "The subject of the ticket.",
31+
optional: true,
32+
},
2733
commentBody: {
2834
propDefinition: [
2935
richpanel,
3036
"commentBody",
3137
],
3238
},
39+
priority: {
40+
type: "string",
41+
label: "Priority",
42+
description: "The priority of the ticket.",
43+
options: [
44+
"HIGH",
45+
"LOW",
46+
],
47+
optional: true,
48+
},
3349
commentSenderType: {
3450
propDefinition: [
3551
richpanel,
@@ -39,18 +55,57 @@ export default {
3955
viaChannel: {
4056
type: "string",
4157
label: "Via Channel",
42-
description: "The channel via which the ticket is created",
58+
description: "The channel via which the ticket is created.",
59+
reloadProps: true,
4360
options: VIA_CHANNEL_OPTIONS,
4461
},
62+
viaSourceFromAddress: {
63+
type: "string",
64+
label: "Via Source From Address",
65+
description: "The email address of the source from.",
66+
hidden: true,
67+
},
68+
viaSourceFromName: {
69+
type: "string",
70+
label: "Via Source From Name",
71+
description: "The name of the source from.",
72+
hidden: true,
73+
},
74+
viaSourceToAddress: {
75+
type: "string",
76+
label: "Via Source To Address",
77+
description: "The email address of the source to.",
78+
hidden: true,
79+
},
80+
viaSourceToName: {
81+
type: "string",
82+
label: "Via Source To Name",
83+
description: "The name of the source to.",
84+
hidden: true,
85+
},
86+
viaSourceFromNumber: {
87+
type: "string",
88+
label: "Via Source From Number",
89+
description: "The phone number of the source from.",
90+
hidden: true,
91+
},
92+
viaSourceToNumber: {
93+
type: "string",
94+
label: "Via Source To Number",
95+
description: "The phone number of the source to.",
96+
hidden: true,
97+
},
4598
viaSourceFrom: {
4699
type: "object",
47100
label: "Via Source From",
48101
description: "The object source from which the ticket was created. **Examples: {\"address\": \"[email protected]\"} or {\"id\": \"+16692668044\"}. It depends on the selected channel**.",
102+
hidden: true,
49103
},
50104
viaSourceTo: {
51105
type: "object",
52106
label: "Via Source To",
53107
description: "The object source to which the ticket was created. **Examples: {\"address\": \"[email protected]\"} or {\"id\": \"+16692668044\"}. It depends on the selected channel**.",
108+
hidden: true,
54109
},
55110
tags: {
56111
propDefinition: [
@@ -60,24 +115,82 @@ export default {
60115
optional: true,
61116
},
62117
},
118+
async additionalProps(props) {
119+
switch (this.viaChannel) {
120+
case "email" :
121+
props.viaSourceFromAddress.hidden = false;
122+
props.viaSourceFromName.hidden = false;
123+
props.viaSourceToAddress.hidden = false;
124+
props.viaSourceToName.hidden = false;
125+
props.viaSourceFrom.hidden = true;
126+
props.viaSourceTo.hidden = true;
127+
props.viaSourceFromNumber.hidden = true;
128+
props.viaSourceToNumber.hidden = true;
129+
break;
130+
case "aircall" :
131+
props.viaSourceFromNumber.hidden = false;
132+
props.viaSourceToNumber.hidden = false;
133+
props.viaSourceFrom.hidden = true;
134+
props.viaSourceTo.hidden = true;
135+
props.viaSourceFromAddress.hidden = true;
136+
props.viaSourceFromName.hidden = true;
137+
props.viaSourceToAddress.hidden = true;
138+
props.viaSourceToName.hidden = true;
139+
break;
140+
default:
141+
props.viaSourceFrom.hidden = false;
142+
props.viaSourceTo.hidden = false;
143+
props.viaSourceFromAddress.hidden = true;
144+
props.viaSourceFromName.hidden = true;
145+
props.viaSourceToAddress.hidden = true;
146+
props.viaSourceToName.hidden = true;
147+
props.viaSourceFromNumber.hidden = true;
148+
props.viaSourceToNumber.hidden = true;
149+
}
150+
return {};
151+
},
63152
async run({ $ }) {
64153
try {
154+
const source = {};
155+
switch (this.viaChannel) {
156+
case "email" :
157+
source.from = {
158+
address: this.viaSourceFromAddress,
159+
name: this.viaSourceFromName,
160+
};
161+
source.to = {
162+
address: this.viaSourceToAddress,
163+
name: this.viaSourceToName,
164+
};
165+
break;
166+
case "aircall" :
167+
source.from = {
168+
id: this.viaSourceFromNumber,
169+
};
170+
source.to = {
171+
id: this.viaSourceToNumber,
172+
};
173+
break;
174+
default:
175+
source.from = parseObject(this.viaSourceFrom);
176+
source.to = parseObject(this.viaSourceTo);
177+
}
178+
65179
const response = await this.richpanel.createTicket({
66180
$,
67181
data: {
68182
ticket: {
69183
id: this.id,
70184
status: this.status,
185+
subject: this.subject,
71186
comment: {
72187
body: this.commentBody,
73188
sender_type: this.commentSenderType,
74189
},
190+
priority: this.priority,
75191
via: {
76192
channel: this.viaChannel,
77-
source: {
78-
from: parseObject(this.viaSourceFrom),
79-
to: parseObject(this.viaSourceTo),
80-
},
193+
source,
81194
},
82195
tags: parseObject(this.tags),
83196
},

0 commit comments

Comments
 (0)