@blotoutio/providers-shop-gpt-sdk 1.5.0 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs.js +408 -6
- package/index.js +408 -6
- package/index.mjs +408 -6
- package/package.json +1 -1
package/index.mjs
CHANGED
@@ -297,7 +297,70 @@ const isoCountries = new Map([
|
|
297
297
|
['ZM', 'Zambia'],
|
298
298
|
['ZW', 'Zimbabwe'],
|
299
299
|
]);
|
300
|
-
|
300
|
+
/**
|
301
|
+
* ISO-3166 US state ISO codes
|
302
|
+
* @see https://en.wikipedia.org/wiki/ISO_3166-2:US
|
303
|
+
* */
|
304
|
+
const usStates = new Map([
|
305
|
+
['US-AL', 'Alabama'],
|
306
|
+
['US-AK', 'Alaska'],
|
307
|
+
['US-AZ', 'Arizona'],
|
308
|
+
['US-AR', 'Arkansas'],
|
309
|
+
['US-CA', 'California'],
|
310
|
+
['US-CO', 'Colorado'],
|
311
|
+
['US-CT', 'Connecticut'],
|
312
|
+
['US-DE', 'Delaware'],
|
313
|
+
['US-FL', 'Florida'],
|
314
|
+
['US-GA', 'Georgia'],
|
315
|
+
['US-HI', 'Hawaii'],
|
316
|
+
['US-ID', 'Idaho'],
|
317
|
+
['US-IL', 'Illinois'],
|
318
|
+
['US-IN', 'Indiana'],
|
319
|
+
['US-IA', 'Iowa'],
|
320
|
+
['US-KS', 'Kansas'],
|
321
|
+
['US-KY', 'Kentucky'],
|
322
|
+
['US-LA', 'Louisiana'],
|
323
|
+
['US-ME', 'Maine'],
|
324
|
+
['US-MD', 'Maryland'],
|
325
|
+
['US-MA', 'Massachusetts'],
|
326
|
+
['US-MI', 'Michigan'],
|
327
|
+
['US-MN', 'Minnesota'],
|
328
|
+
['US-MS', 'Mississippi'],
|
329
|
+
['US-MO', 'Missouri'],
|
330
|
+
['US-MT', 'Montana'],
|
331
|
+
['US-NE', 'Nebraska'],
|
332
|
+
['US-NV', 'Nevada'],
|
333
|
+
['US-NH', 'New Hampshire'],
|
334
|
+
['US-NJ', 'New Jersey'],
|
335
|
+
['US-NM', 'New Mexico'],
|
336
|
+
['US-NY', 'New York'],
|
337
|
+
['US-NC', 'North Carolina'],
|
338
|
+
['US-ND', 'North Dakota'],
|
339
|
+
['US-OH', 'Ohio'],
|
340
|
+
['US-OK', 'Oklahoma'],
|
341
|
+
['US-OR', 'Oregon'],
|
342
|
+
['US-PA', 'Pennsylvania'],
|
343
|
+
['US-RI', 'Rhode Island'],
|
344
|
+
['US-SC', 'South Carolina'],
|
345
|
+
['US-SD', 'South Dakota'],
|
346
|
+
['US-TN', 'Tennessee'],
|
347
|
+
['US-TX', 'Texas'],
|
348
|
+
['US-UT', 'Utah'],
|
349
|
+
['US-VT', 'Vermont'],
|
350
|
+
['US-VA', 'Virginia'],
|
351
|
+
['US-WA', 'Washington'],
|
352
|
+
['US-WV', 'West Virginia'],
|
353
|
+
['US-WI', 'Wisconsin'],
|
354
|
+
['US-WY', 'Wyoming'],
|
355
|
+
['US-DC', 'District of Columbia'],
|
356
|
+
['US-AS', 'American Samoa'],
|
357
|
+
['US-GU', 'Guam'],
|
358
|
+
['US-MP', 'Northern Mariana Islands'],
|
359
|
+
['US-PR', 'Puerto Rico'],
|
360
|
+
['US-UM', 'United States Minor Outlying Islands'],
|
361
|
+
['US-VI', 'Virgin Islands, U.S.'],
|
362
|
+
]);
|
363
|
+
new Set([...isoCountries.keys(), ...usStates.keys()]);
|
301
364
|
|
302
365
|
const packageName = 'shopGPT';
|
303
366
|
const DEFAULT_MAX_THREAD_AGE = 14;
|
@@ -380,6 +443,7 @@ const createShopGPTAPI = ({ fetch: fetchImpl = window.fetch, baseURL, userId, st
|
|
380
443
|
}
|
381
444
|
const data = (await response.json());
|
382
445
|
return {
|
446
|
+
messageId: data.messageId,
|
383
447
|
message: data.message,
|
384
448
|
products: (_a = data.products) === null || _a === void 0 ? void 0 : _a.filter((item) => !!item).map((item) => ({ ...item, quantity: 1 })),
|
385
449
|
chatTitle: data.chatTitle,
|
@@ -450,6 +514,20 @@ const createShopGPTAPI = ({ fetch: fetchImpl = window.fetch, baseURL, userId, st
|
|
450
514
|
throw new Error(`Failed to delete all chat threads - ${response.status}: ${await response.text()}`);
|
451
515
|
}
|
452
516
|
};
|
517
|
+
const saveFeedback = async (messageId, feedback) => {
|
518
|
+
const response = await fetchImpl(getURL('/feedback'), {
|
519
|
+
method: 'POST',
|
520
|
+
headers: getHeaders(),
|
521
|
+
credentials: 'include',
|
522
|
+
body: JSON.stringify({
|
523
|
+
messageId,
|
524
|
+
feedback,
|
525
|
+
}),
|
526
|
+
});
|
527
|
+
if (!response.ok) {
|
528
|
+
throw new Error(`Failed to save feedback - ${response.status}: ${await response.text()}`);
|
529
|
+
}
|
530
|
+
};
|
453
531
|
return {
|
454
532
|
processQuery,
|
455
533
|
fetchChatHistory,
|
@@ -457,6 +535,7 @@ const createShopGPTAPI = ({ fetch: fetchImpl = window.fetch, baseURL, userId, st
|
|
457
535
|
createChatThread,
|
458
536
|
deleteSingleThread,
|
459
537
|
deleteAllThreads,
|
538
|
+
saveFeedback,
|
460
539
|
};
|
461
540
|
};
|
462
541
|
|
@@ -2000,6 +2079,26 @@ const chatSectionStyles = i$4 `
|
|
2000
2079
|
}
|
2001
2080
|
}
|
2002
2081
|
|
2082
|
+
.bot-response-actions {
|
2083
|
+
display: flex;
|
2084
|
+
margin-left: 12px;
|
2085
|
+
margin-top: -10px;
|
2086
|
+
|
2087
|
+
button {
|
2088
|
+
display: flex;
|
2089
|
+
align-items: center;
|
2090
|
+
justify-content: center;
|
2091
|
+
padding: 8px;
|
2092
|
+
background: none;
|
2093
|
+
color: rgb(140, 137, 156);
|
2094
|
+
border-radius: 50%;
|
2095
|
+
|
2096
|
+
&:hover {
|
2097
|
+
background-color: rgba(47, 43, 61, 0.08);
|
2098
|
+
}
|
2099
|
+
}
|
2100
|
+
}
|
2101
|
+
|
2003
2102
|
.bot-icon {
|
2004
2103
|
display: flex;
|
2005
2104
|
padding: 8px 11px;
|
@@ -2259,6 +2358,18 @@ const timerBtn = b `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="2
|
|
2259
2358
|
const crossBtn = b `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
|
2260
2359
|
<path d="M18 7.05L16.95 6L12 10.95L7.05 6L6 7.05L10.95 12L6 16.95L7.05 18L12 13.05L16.95 18L18 16.95L13.05 12L18 7.05Z" fill="white"/>
|
2261
2360
|
</svg>`;
|
2361
|
+
const thumbsUpBtn = b `<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--tabler" font-size="1.375rem" width="1em" height="1em" viewBox="0 0 24 24">
|
2362
|
+
<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M7 11v8a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1v-7a1 1 0 0 1 1-1h3a4 4 0 0 0 4-4V6a2 2 0 0 1 4 0v5h3a2 2 0 0 1 2 2l-1 5a2 3 0 0 1-2 2h-7a3 3 0 0 1-3-3"></path>
|
2363
|
+
</svg>`;
|
2364
|
+
const thumbsUpFilledBtn = b `<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--tabler" font-size="1.375rem" width="1em" height="1em" viewBox="0 0 24 24">
|
2365
|
+
<path fill="currentColor" d="M13 3a3 3 0 0 1 2.995 2.824L16 6v4h2a3 3 0 0 1 2.98 2.65l.015.174L21 13l-.02.196l-1.006 5.032c-.381 1.626-1.502 2.796-2.81 2.78L17 21H9a1 1 0 0 1-.993-.883L8 20l.001-9.536a1 1 0 0 1 .5-.865a3 3 0 0 0 1.492-2.397L10 7V6a3 3 0 0 1 3-3m-8 7a1 1 0 0 1 .993.883L6 11v9a1 1 0 0 1-.883.993L5 21H4a2 2 0 0 1-1.995-1.85L2 19v-7a2 2 0 0 1 1.85-1.995L4 10z"></path>
|
2366
|
+
</svg>`;
|
2367
|
+
const thumbsDownBtn = b `<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--tabler" font-size="1.375rem" width="1em" height="1em" viewBox="0 0 24 24">
|
2368
|
+
<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M7 13V5a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v7a1 1 0 0 0 1 1h3a4 4 0 0 1 4 4v1a2 2 0 0 0 4 0v-5h3a2 2 0 0 0 2-2l-1-5a2 3 0 0 0-2-2h-7a3 3 0 0 0-3 3"></path>
|
2369
|
+
</svg>`;
|
2370
|
+
const thumbsDownFilledBtn = b `<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--tabler" font-size="1.375rem" width="1em" height="1em" viewBox="0 0 24 24">
|
2371
|
+
<path fill="currentColor" d="M13 21.008a3 3 0 0 0 2.995-2.823l.005-.177v-4h2a3 3 0 0 0 2.98-2.65l.015-.173l.005-.177l-.02-.196l-1.006-5.032c-.381-1.625-1.502-2.796-2.81-2.78L17 3.008H9a1 1 0 0 0-.993.884L8 4.008l.001 9.536a1 1 0 0 0 .5.866a3 3 0 0 1 1.492 2.396l.007.202v1a3 3 0 0 0 3 3m-8-7a1 1 0 0 0 .993-.883L6 13.008v-9a1 1 0 0 0-.883-.993L5 3.008H4A2 2 0 0 0 2.005 4.86L2 5.01v7a2 2 0 0 0 1.85 1.994l.15.005h1z"></path>
|
2372
|
+
</svg>`;
|
2262
2373
|
|
2263
2374
|
const personalizeDialogStyles = i$4 `
|
2264
2375
|
:host {
|
@@ -3162,6 +3273,212 @@ if (!customElements.get('confirm-dialog')) {
|
|
3162
3273
|
customElements.define('confirm-dialog', ConfirmDialog);
|
3163
3274
|
}
|
3164
3275
|
|
3276
|
+
const feedbackDialogStyles = i$4 `
|
3277
|
+
:host {
|
3278
|
+
font-family: 'Inter', sans-serif;
|
3279
|
+
font-size: 16px;
|
3280
|
+
line-height: 24px;
|
3281
|
+
font-weight: 400;
|
3282
|
+
|
3283
|
+
display: flex;
|
3284
|
+
position: absolute;
|
3285
|
+
top: 0;
|
3286
|
+
left: 0;
|
3287
|
+
width: 100%;
|
3288
|
+
height: 100%;
|
3289
|
+
background: #00000050;
|
3290
|
+
}
|
3291
|
+
|
3292
|
+
.modal {
|
3293
|
+
width: 75%;
|
3294
|
+
max-width: 400px;
|
3295
|
+
background: #fff;
|
3296
|
+
padding: 24px;
|
3297
|
+
margin: auto;
|
3298
|
+
|
3299
|
+
border-radius: 8px;
|
3300
|
+
box-shadow: rgba(47, 43, 61, 0.28) 0px 8px 23px 0px;
|
3301
|
+
|
3302
|
+
z-index: 2000;
|
3303
|
+
}
|
3304
|
+
|
3305
|
+
.header {
|
3306
|
+
display: flex;
|
3307
|
+
justify-content: space-between;
|
3308
|
+
align-items: center;
|
3309
|
+
margin-bottom: 16px;
|
3310
|
+
}
|
3311
|
+
|
3312
|
+
.close {
|
3313
|
+
display: flex;
|
3314
|
+
justify-content: center;
|
3315
|
+
align-items: center;
|
3316
|
+
cursor: pointer;
|
3317
|
+
}
|
3318
|
+
|
3319
|
+
h3 {
|
3320
|
+
margin: 0;
|
3321
|
+
font-size: 20px;
|
3322
|
+
font-weight: 700;
|
3323
|
+
color: #172a41;
|
3324
|
+
line-height: 24px;
|
3325
|
+
}
|
3326
|
+
|
3327
|
+
form {
|
3328
|
+
display: flex;
|
3329
|
+
flex-direction: column;
|
3330
|
+
gap: 12px;
|
3331
|
+
margin: 0;
|
3332
|
+
}
|
3333
|
+
|
3334
|
+
textarea {
|
3335
|
+
padding: 16px;
|
3336
|
+
border: 1px solid #2f2b3d28;
|
3337
|
+
border-radius: 10px;
|
3338
|
+
font-size: 16px;
|
3339
|
+
resize: none;
|
3340
|
+
min-height: 104px;
|
3341
|
+
box-sizing: border-box;
|
3342
|
+
font-family: inherit;
|
3343
|
+
color: #4e647f;
|
3344
|
+
font-weight: 500;
|
3345
|
+
line-height: 24px;
|
3346
|
+
|
3347
|
+
&:focus {
|
3348
|
+
outline: none;
|
3349
|
+
box-shadow: rgba(57, 123, 244, 0.5) 0px 0px 4px;
|
3350
|
+
}
|
3351
|
+
|
3352
|
+
&::placeholder {
|
3353
|
+
font-style: italic;
|
3354
|
+
color: #8799af80;
|
3355
|
+
}
|
3356
|
+
}
|
3357
|
+
|
3358
|
+
.btns-container {
|
3359
|
+
display: flex;
|
3360
|
+
gap: 0 8px;
|
3361
|
+
margin-left: auto;
|
3362
|
+
margin-top: 10px;
|
3363
|
+
}
|
3364
|
+
|
3365
|
+
button {
|
3366
|
+
padding: 9px 20px;
|
3367
|
+
border: none;
|
3368
|
+
border-radius: 5px;
|
3369
|
+
cursor: pointer;
|
3370
|
+
}
|
3371
|
+
|
3372
|
+
.btn-skip {
|
3373
|
+
background-color: #dbe2eb;
|
3374
|
+
color: #172a41;
|
3375
|
+
font-weight: 500;
|
3376
|
+
|
3377
|
+
&:hover {
|
3378
|
+
background-color: rgb(219, 226, 235);
|
3379
|
+
}
|
3380
|
+
}
|
3381
|
+
|
3382
|
+
.btn-submit-feedback {
|
3383
|
+
background-color: rgb(23, 42, 65);
|
3384
|
+
color: #ffffff;
|
3385
|
+
font-weight: 500;
|
3386
|
+
|
3387
|
+
&:hover {
|
3388
|
+
background-color: rgb(9, 22, 39);
|
3389
|
+
}
|
3390
|
+
|
3391
|
+
&:disabled {
|
3392
|
+
background-color: #e0e0e0;
|
3393
|
+
cursor: not-allowed;
|
3394
|
+
}
|
3395
|
+
}
|
3396
|
+
`;
|
3397
|
+
|
3398
|
+
class FeedbackDialog extends r$2 {
|
3399
|
+
dispatchFeedbackEvent(feedback) {
|
3400
|
+
this.dispatchEvent(new CustomEvent('submit-feedback', {
|
3401
|
+
detail: {
|
3402
|
+
messageId: this.messageId,
|
3403
|
+
feedback,
|
3404
|
+
},
|
3405
|
+
composed: true,
|
3406
|
+
bubbles: true,
|
3407
|
+
}));
|
3408
|
+
}
|
3409
|
+
handleSubmit(e) {
|
3410
|
+
var _a;
|
3411
|
+
e.preventDefault();
|
3412
|
+
const form = e.target;
|
3413
|
+
const data = new FormData(form);
|
3414
|
+
this.dispatchFeedbackEvent({
|
3415
|
+
rating: 'bad',
|
3416
|
+
comment: (_a = data.get('comment')) === null || _a === void 0 ? void 0 : _a.toString().trim(),
|
3417
|
+
});
|
3418
|
+
form.reset();
|
3419
|
+
}
|
3420
|
+
handleSkipComment(e) {
|
3421
|
+
e.preventDefault();
|
3422
|
+
this.comment = '';
|
3423
|
+
this.dispatchFeedbackEvent({ rating: 'bad', comment: null });
|
3424
|
+
}
|
3425
|
+
close(e) {
|
3426
|
+
e.preventDefault();
|
3427
|
+
this.dispatchEvent(new CustomEvent('close', {
|
3428
|
+
composed: true,
|
3429
|
+
bubbles: true,
|
3430
|
+
}));
|
3431
|
+
}
|
3432
|
+
render() {
|
3433
|
+
return x `
|
3434
|
+
<div class="modal">
|
3435
|
+
<div class="header">
|
3436
|
+
<h3>Provide Additional Feedback</h3>
|
3437
|
+
<div class="close" @click=${this.close}>${closeBtn}</div>
|
3438
|
+
</div>
|
3439
|
+
<form @submit=${this.handleSubmit}>
|
3440
|
+
<textarea
|
3441
|
+
name="comment"
|
3442
|
+
@input=${(e) => { var _a; return (this.comment = (_a = e.target) === null || _a === void 0 ? void 0 : _a.value); }}
|
3443
|
+
placeholder="Share your feedback"
|
3444
|
+
required
|
3445
|
+
>
|
3446
|
+
${this.comment ? this.comment : E}</textarea
|
3447
|
+
>
|
3448
|
+
<div class="btns-container">
|
3449
|
+
<button
|
3450
|
+
type="button"
|
3451
|
+
class="btn btn-skip"
|
3452
|
+
@click=${this.handleSkipComment}
|
3453
|
+
>
|
3454
|
+
Skip
|
3455
|
+
</button>
|
3456
|
+
<button
|
3457
|
+
type="submit"
|
3458
|
+
class="btn btn-submit-feedback"
|
3459
|
+
?disabled=${!this.comment}
|
3460
|
+
>
|
3461
|
+
Submit
|
3462
|
+
</button>
|
3463
|
+
</div>
|
3464
|
+
</form>
|
3465
|
+
</div>
|
3466
|
+
`;
|
3467
|
+
}
|
3468
|
+
}
|
3469
|
+
FeedbackDialog.styles = [feedbackDialogStyles];
|
3470
|
+
__decorate([
|
3471
|
+
n({ type: String }),
|
3472
|
+
__metadata("design:type", Object)
|
3473
|
+
], FeedbackDialog.prototype, "messageId", void 0);
|
3474
|
+
__decorate([
|
3475
|
+
n({ type: String }),
|
3476
|
+
__metadata("design:type", Object)
|
3477
|
+
], FeedbackDialog.prototype, "comment", void 0);
|
3478
|
+
if (!customElements.get('feedback-dialog')) {
|
3479
|
+
customElements.define('feedback-dialog', FeedbackDialog);
|
3480
|
+
}
|
3481
|
+
|
3165
3482
|
class ChatSection extends r$2 {
|
3166
3483
|
constructor() {
|
3167
3484
|
super(...arguments);
|
@@ -3209,6 +3526,23 @@ class ChatSection extends r$2 {
|
|
3209
3526
|
}));
|
3210
3527
|
this.deleteThreadId = '';
|
3211
3528
|
}
|
3529
|
+
handleFeedback(rating, messageId, comment) {
|
3530
|
+
if (rating === 'bad') {
|
3531
|
+
this.feedbackDetails = { messageId, comment };
|
3532
|
+
return;
|
3533
|
+
}
|
3534
|
+
this.dispatchEvent(new CustomEvent('submit-feedback', {
|
3535
|
+
detail: {
|
3536
|
+
messageId: messageId,
|
3537
|
+
feedback: {
|
3538
|
+
rating,
|
3539
|
+
comment: null,
|
3540
|
+
},
|
3541
|
+
},
|
3542
|
+
composed: true,
|
3543
|
+
bubbles: true,
|
3544
|
+
}));
|
3545
|
+
}
|
3212
3546
|
typingIndicator() {
|
3213
3547
|
return x ` <div class="typing-dots">
|
3214
3548
|
<div class="dot"></div>
|
@@ -3217,7 +3551,7 @@ class ChatSection extends r$2 {
|
|
3217
3551
|
</div>`;
|
3218
3552
|
}
|
3219
3553
|
botMessage(message) {
|
3220
|
-
var _a;
|
3554
|
+
var _a, _b, _c, _d, _e;
|
3221
3555
|
return x `
|
3222
3556
|
<div class="message-wrapper">
|
3223
3557
|
<div class="message bot">
|
@@ -3248,6 +3582,26 @@ class ChatSection extends r$2 {
|
|
3248
3582
|
.viewType=${this.viewType}
|
3249
3583
|
></products-list>`
|
3250
3584
|
: E}
|
3585
|
+
${message.messageId
|
3586
|
+
? x `<div class="bot-response-actions">
|
3587
|
+
<button
|
3588
|
+
type="button"
|
3589
|
+
@click=${this.handleFeedback.bind(this, 'good', message.messageId, (_b = message.feedback) === null || _b === void 0 ? void 0 : _b.comment)}
|
3590
|
+
>
|
3591
|
+
${((_c = message.feedback) === null || _c === void 0 ? void 0 : _c.rating) === 'good'
|
3592
|
+
? thumbsUpFilledBtn
|
3593
|
+
: thumbsUpBtn}
|
3594
|
+
</button>
|
3595
|
+
<button
|
3596
|
+
type="button"
|
3597
|
+
@click=${this.handleFeedback.bind(this, 'bad', message.messageId, (_d = message.feedback) === null || _d === void 0 ? void 0 : _d.comment)}
|
3598
|
+
>
|
3599
|
+
${((_e = message.feedback) === null || _e === void 0 ? void 0 : _e.rating) === 'bad'
|
3600
|
+
? thumbsDownFilledBtn
|
3601
|
+
: thumbsDownBtn}
|
3602
|
+
</button>
|
3603
|
+
</div>`
|
3604
|
+
: E}
|
3251
3605
|
</div>
|
3252
3606
|
`;
|
3253
3607
|
}
|
@@ -3268,10 +3622,19 @@ class ChatSection extends r$2 {
|
|
3268
3622
|
</div>`
|
3269
3623
|
: ''}
|
3270
3624
|
${this.isFailed
|
3271
|
-
?
|
3272
|
-
|
3273
|
-
|
3274
|
-
|
3625
|
+
? x `<div class="message bot">
|
3626
|
+
<div>
|
3627
|
+
<div class="bot-icon">${botIcon}</div>
|
3628
|
+
</div>
|
3629
|
+
<div>
|
3630
|
+
<p>
|
3631
|
+
Uh-oh! Looks like I tripped over some alpha-stage wires.
|
3632
|
+
Things are still a bit wobbly here, buy hey, that's what
|
3633
|
+
testing is for, Let's try that again; or feel free to throw
|
3634
|
+
another challenge my way!
|
3635
|
+
</p>
|
3636
|
+
</div>
|
3637
|
+
</div>`
|
3275
3638
|
: E}
|
3276
3639
|
${this.messages.map((message) => {
|
3277
3640
|
if (message.sender === 'bot') {
|
@@ -3615,6 +3978,21 @@ class ChatSection extends r$2 {
|
|
3615
3978
|
</confirm-dialog>
|
3616
3979
|
`
|
3617
3980
|
: E}
|
3981
|
+
${this.feedbackDetails
|
3982
|
+
? x `
|
3983
|
+
<feedback-dialog
|
3984
|
+
.messageId=${this.feedbackDetails.messageId}
|
3985
|
+
.comment=${this.feedbackDetails.comment}
|
3986
|
+
@submit-feedback=${() => {
|
3987
|
+
this.feedbackDetails = undefined;
|
3988
|
+
}}
|
3989
|
+
@close=${(e) => {
|
3990
|
+
e.stopPropagation();
|
3991
|
+
this.feedbackDetails = undefined;
|
3992
|
+
}}
|
3993
|
+
></feedback-dialog>
|
3994
|
+
`
|
3995
|
+
: E}
|
3618
3996
|
`;
|
3619
3997
|
}
|
3620
3998
|
}
|
@@ -3699,6 +4077,10 @@ __decorate([
|
|
3699
4077
|
e$3('personalize-dialog'),
|
3700
4078
|
__metadata("design:type", Object)
|
3701
4079
|
], ChatSection.prototype, "personalizeDialogElement", void 0);
|
4080
|
+
__decorate([
|
4081
|
+
r(),
|
4082
|
+
__metadata("design:type", Object)
|
4083
|
+
], ChatSection.prototype, "feedbackDetails", void 0);
|
3702
4084
|
__decorate([
|
3703
4085
|
n({ type: String }),
|
3704
4086
|
__metadata("design:type", Object)
|
@@ -3819,6 +4201,7 @@ class ShopGPT extends r$2 {
|
|
3819
4201
|
}
|
3820
4202
|
this.messages = [
|
3821
4203
|
{
|
4204
|
+
messageId: reply.messageId,
|
3822
4205
|
sender: 'bot',
|
3823
4206
|
message: reply.message,
|
3824
4207
|
products: reply.products,
|
@@ -3886,10 +4269,12 @@ class ShopGPT extends r$2 {
|
|
3886
4269
|
latestAvailableProducts = products;
|
3887
4270
|
}
|
3888
4271
|
return {
|
4272
|
+
messageId: message.messageId,
|
3889
4273
|
message: message.message,
|
3890
4274
|
sender: message.sender,
|
3891
4275
|
products,
|
3892
4276
|
welcomePrompts: message.welcomePrompts,
|
4277
|
+
feedback: message.feedback,
|
3893
4278
|
};
|
3894
4279
|
});
|
3895
4280
|
this.products = latestAvailableProducts;
|
@@ -3970,6 +4355,7 @@ class ShopGPT extends r$2 {
|
|
3970
4355
|
}
|
3971
4356
|
this.messages = [
|
3972
4357
|
{
|
4358
|
+
messageId: reply.messageId,
|
3973
4359
|
sender: 'bot',
|
3974
4360
|
message: reply.message,
|
3975
4361
|
products: reply.products,
|
@@ -3989,6 +4375,20 @@ class ShopGPT extends r$2 {
|
|
3989
4375
|
this.isTyping = false;
|
3990
4376
|
}
|
3991
4377
|
}
|
4378
|
+
submitFeedback(e) {
|
4379
|
+
e.stopPropagation();
|
4380
|
+
this.shopGPTAPI
|
4381
|
+
.saveFeedback(e.detail.messageId, e.detail.feedback)
|
4382
|
+
.then(() => {
|
4383
|
+
const messages = this.messages;
|
4384
|
+
const messageIndex = messages.findIndex(({ messageId }) => messageId === e.detail.messageId);
|
4385
|
+
messages[messageIndex] = {
|
4386
|
+
...messages[messageIndex],
|
4387
|
+
feedback: e.detail.feedback,
|
4388
|
+
};
|
4389
|
+
this.messages = [...messages];
|
4390
|
+
});
|
4391
|
+
}
|
3992
4392
|
getSiteCurrency() {
|
3993
4393
|
return this.storeAPI.getSiteCurrency();
|
3994
4394
|
}
|
@@ -4005,6 +4405,7 @@ class ShopGPT extends r$2 {
|
|
4005
4405
|
id="shop-gpt-dialog-overlay"
|
4006
4406
|
@delete-thread=${this.handleThreadDelete}
|
4007
4407
|
@delete-all-threads=${this.handleAllThreadsDelete}
|
4408
|
+
@submit-feedback=${this.submitFeedback}
|
4008
4409
|
>
|
4009
4410
|
<div class="mobile-version">
|
4010
4411
|
Please switch to the desktop version for the best experience.
|
@@ -4069,6 +4470,7 @@ class ShopGPT extends r$2 {
|
|
4069
4470
|
id="shop-gpt-modal"
|
4070
4471
|
@delete-thread=${this.handleThreadDelete}
|
4071
4472
|
@delete-all-threads=${this.handleAllThreadsDelete}
|
4473
|
+
@submit-feedback=${this.submitFeedback}
|
4072
4474
|
>
|
4073
4475
|
<chat-section
|
4074
4476
|
.prompts=${this.quickPrompts}
|