@blotoutio/providers-shop-gpt-sdk 1.5.0 → 1.6.0
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.js
CHANGED
@@ -300,7 +300,70 @@ var ProvidersShopGptSdk = (function () {
|
|
300
300
|
['ZM', 'Zambia'],
|
301
301
|
['ZW', 'Zimbabwe'],
|
302
302
|
]);
|
303
|
-
|
303
|
+
/**
|
304
|
+
* ISO-3166 US state ISO codes
|
305
|
+
* @see https://en.wikipedia.org/wiki/ISO_3166-2:US
|
306
|
+
* */
|
307
|
+
const usStates = new Map([
|
308
|
+
['US-AL', 'Alabama'],
|
309
|
+
['US-AK', 'Alaska'],
|
310
|
+
['US-AZ', 'Arizona'],
|
311
|
+
['US-AR', 'Arkansas'],
|
312
|
+
['US-CA', 'California'],
|
313
|
+
['US-CO', 'Colorado'],
|
314
|
+
['US-CT', 'Connecticut'],
|
315
|
+
['US-DE', 'Delaware'],
|
316
|
+
['US-FL', 'Florida'],
|
317
|
+
['US-GA', 'Georgia'],
|
318
|
+
['US-HI', 'Hawaii'],
|
319
|
+
['US-ID', 'Idaho'],
|
320
|
+
['US-IL', 'Illinois'],
|
321
|
+
['US-IN', 'Indiana'],
|
322
|
+
['US-IA', 'Iowa'],
|
323
|
+
['US-KS', 'Kansas'],
|
324
|
+
['US-KY', 'Kentucky'],
|
325
|
+
['US-LA', 'Louisiana'],
|
326
|
+
['US-ME', 'Maine'],
|
327
|
+
['US-MD', 'Maryland'],
|
328
|
+
['US-MA', 'Massachusetts'],
|
329
|
+
['US-MI', 'Michigan'],
|
330
|
+
['US-MN', 'Minnesota'],
|
331
|
+
['US-MS', 'Mississippi'],
|
332
|
+
['US-MO', 'Missouri'],
|
333
|
+
['US-MT', 'Montana'],
|
334
|
+
['US-NE', 'Nebraska'],
|
335
|
+
['US-NV', 'Nevada'],
|
336
|
+
['US-NH', 'New Hampshire'],
|
337
|
+
['US-NJ', 'New Jersey'],
|
338
|
+
['US-NM', 'New Mexico'],
|
339
|
+
['US-NY', 'New York'],
|
340
|
+
['US-NC', 'North Carolina'],
|
341
|
+
['US-ND', 'North Dakota'],
|
342
|
+
['US-OH', 'Ohio'],
|
343
|
+
['US-OK', 'Oklahoma'],
|
344
|
+
['US-OR', 'Oregon'],
|
345
|
+
['US-PA', 'Pennsylvania'],
|
346
|
+
['US-RI', 'Rhode Island'],
|
347
|
+
['US-SC', 'South Carolina'],
|
348
|
+
['US-SD', 'South Dakota'],
|
349
|
+
['US-TN', 'Tennessee'],
|
350
|
+
['US-TX', 'Texas'],
|
351
|
+
['US-UT', 'Utah'],
|
352
|
+
['US-VT', 'Vermont'],
|
353
|
+
['US-VA', 'Virginia'],
|
354
|
+
['US-WA', 'Washington'],
|
355
|
+
['US-WV', 'West Virginia'],
|
356
|
+
['US-WI', 'Wisconsin'],
|
357
|
+
['US-WY', 'Wyoming'],
|
358
|
+
['US-DC', 'District of Columbia'],
|
359
|
+
['US-AS', 'American Samoa'],
|
360
|
+
['US-GU', 'Guam'],
|
361
|
+
['US-MP', 'Northern Mariana Islands'],
|
362
|
+
['US-PR', 'Puerto Rico'],
|
363
|
+
['US-UM', 'United States Minor Outlying Islands'],
|
364
|
+
['US-VI', 'Virgin Islands, U.S.'],
|
365
|
+
]);
|
366
|
+
new Set([...isoCountries.keys(), ...usStates.keys()]);
|
304
367
|
|
305
368
|
const packageName = 'shopGPT';
|
306
369
|
const DEFAULT_MAX_THREAD_AGE = 14;
|
@@ -383,6 +446,7 @@ var ProvidersShopGptSdk = (function () {
|
|
383
446
|
}
|
384
447
|
const data = (await response.json());
|
385
448
|
return {
|
449
|
+
messageId: data.messageId,
|
386
450
|
message: data.message,
|
387
451
|
products: (_a = data.products) === null || _a === void 0 ? void 0 : _a.filter((item) => !!item).map((item) => ({ ...item, quantity: 1 })),
|
388
452
|
chatTitle: data.chatTitle,
|
@@ -453,6 +517,20 @@ var ProvidersShopGptSdk = (function () {
|
|
453
517
|
throw new Error(`Failed to delete all chat threads - ${response.status}: ${await response.text()}`);
|
454
518
|
}
|
455
519
|
};
|
520
|
+
const saveFeedback = async (messageId, feedback) => {
|
521
|
+
const response = await fetchImpl(getURL('/feedback'), {
|
522
|
+
method: 'POST',
|
523
|
+
headers: getHeaders(),
|
524
|
+
credentials: 'include',
|
525
|
+
body: JSON.stringify({
|
526
|
+
messageId,
|
527
|
+
feedback,
|
528
|
+
}),
|
529
|
+
});
|
530
|
+
if (!response.ok) {
|
531
|
+
throw new Error(`Failed to save feedback - ${response.status}: ${await response.text()}`);
|
532
|
+
}
|
533
|
+
};
|
456
534
|
return {
|
457
535
|
processQuery,
|
458
536
|
fetchChatHistory,
|
@@ -460,6 +538,7 @@ var ProvidersShopGptSdk = (function () {
|
|
460
538
|
createChatThread,
|
461
539
|
deleteSingleThread,
|
462
540
|
deleteAllThreads,
|
541
|
+
saveFeedback,
|
463
542
|
};
|
464
543
|
};
|
465
544
|
|
@@ -2003,6 +2082,26 @@ var ProvidersShopGptSdk = (function () {
|
|
2003
2082
|
}
|
2004
2083
|
}
|
2005
2084
|
|
2085
|
+
.bot-response-actions {
|
2086
|
+
display: flex;
|
2087
|
+
margin-left: 12px;
|
2088
|
+
margin-top: -10px;
|
2089
|
+
|
2090
|
+
button {
|
2091
|
+
display: flex;
|
2092
|
+
align-items: center;
|
2093
|
+
justify-content: center;
|
2094
|
+
padding: 8px;
|
2095
|
+
background: none;
|
2096
|
+
color: rgb(140, 137, 156);
|
2097
|
+
border-radius: 50%;
|
2098
|
+
|
2099
|
+
&:hover {
|
2100
|
+
background-color: rgba(47, 43, 61, 0.08);
|
2101
|
+
}
|
2102
|
+
}
|
2103
|
+
}
|
2104
|
+
|
2006
2105
|
.bot-icon {
|
2007
2106
|
display: flex;
|
2008
2107
|
padding: 8px 11px;
|
@@ -2262,6 +2361,18 @@ var ProvidersShopGptSdk = (function () {
|
|
2262
2361
|
const crossBtn = b `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
|
2263
2362
|
<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"/>
|
2264
2363
|
</svg>`;
|
2364
|
+
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">
|
2365
|
+
<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>
|
2366
|
+
</svg>`;
|
2367
|
+
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">
|
2368
|
+
<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>
|
2369
|
+
</svg>`;
|
2370
|
+
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">
|
2371
|
+
<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>
|
2372
|
+
</svg>`;
|
2373
|
+
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">
|
2374
|
+
<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>
|
2375
|
+
</svg>`;
|
2265
2376
|
|
2266
2377
|
const personalizeDialogStyles = i$4 `
|
2267
2378
|
:host {
|
@@ -3165,6 +3276,212 @@ var ProvidersShopGptSdk = (function () {
|
|
3165
3276
|
customElements.define('confirm-dialog', ConfirmDialog);
|
3166
3277
|
}
|
3167
3278
|
|
3279
|
+
const feedbackDialogStyles = i$4 `
|
3280
|
+
:host {
|
3281
|
+
font-family: 'Inter', sans-serif;
|
3282
|
+
font-size: 16px;
|
3283
|
+
line-height: 24px;
|
3284
|
+
font-weight: 400;
|
3285
|
+
|
3286
|
+
display: flex;
|
3287
|
+
position: absolute;
|
3288
|
+
top: 0;
|
3289
|
+
left: 0;
|
3290
|
+
width: 100%;
|
3291
|
+
height: 100%;
|
3292
|
+
background: #00000050;
|
3293
|
+
}
|
3294
|
+
|
3295
|
+
.modal {
|
3296
|
+
width: 75%;
|
3297
|
+
max-width: 400px;
|
3298
|
+
background: #fff;
|
3299
|
+
padding: 24px;
|
3300
|
+
margin: auto;
|
3301
|
+
|
3302
|
+
border-radius: 8px;
|
3303
|
+
box-shadow: rgba(47, 43, 61, 0.28) 0px 8px 23px 0px;
|
3304
|
+
|
3305
|
+
z-index: 2000;
|
3306
|
+
}
|
3307
|
+
|
3308
|
+
.header {
|
3309
|
+
display: flex;
|
3310
|
+
justify-content: space-between;
|
3311
|
+
align-items: center;
|
3312
|
+
margin-bottom: 16px;
|
3313
|
+
}
|
3314
|
+
|
3315
|
+
.close {
|
3316
|
+
display: flex;
|
3317
|
+
justify-content: center;
|
3318
|
+
align-items: center;
|
3319
|
+
cursor: pointer;
|
3320
|
+
}
|
3321
|
+
|
3322
|
+
h3 {
|
3323
|
+
margin: 0;
|
3324
|
+
font-size: 20px;
|
3325
|
+
font-weight: 700;
|
3326
|
+
color: #172a41;
|
3327
|
+
line-height: 24px;
|
3328
|
+
}
|
3329
|
+
|
3330
|
+
form {
|
3331
|
+
display: flex;
|
3332
|
+
flex-direction: column;
|
3333
|
+
gap: 12px;
|
3334
|
+
margin: 0;
|
3335
|
+
}
|
3336
|
+
|
3337
|
+
textarea {
|
3338
|
+
padding: 16px;
|
3339
|
+
border: 1px solid #2f2b3d28;
|
3340
|
+
border-radius: 10px;
|
3341
|
+
font-size: 16px;
|
3342
|
+
resize: none;
|
3343
|
+
min-height: 104px;
|
3344
|
+
box-sizing: border-box;
|
3345
|
+
font-family: inherit;
|
3346
|
+
color: #4e647f;
|
3347
|
+
font-weight: 500;
|
3348
|
+
line-height: 24px;
|
3349
|
+
|
3350
|
+
&:focus {
|
3351
|
+
outline: none;
|
3352
|
+
box-shadow: rgba(57, 123, 244, 0.5) 0px 0px 4px;
|
3353
|
+
}
|
3354
|
+
|
3355
|
+
&::placeholder {
|
3356
|
+
font-style: italic;
|
3357
|
+
color: #8799af80;
|
3358
|
+
}
|
3359
|
+
}
|
3360
|
+
|
3361
|
+
.btns-container {
|
3362
|
+
display: flex;
|
3363
|
+
gap: 0 8px;
|
3364
|
+
margin-left: auto;
|
3365
|
+
margin-top: 10px;
|
3366
|
+
}
|
3367
|
+
|
3368
|
+
button {
|
3369
|
+
padding: 9px 20px;
|
3370
|
+
border: none;
|
3371
|
+
border-radius: 5px;
|
3372
|
+
cursor: pointer;
|
3373
|
+
}
|
3374
|
+
|
3375
|
+
.btn-skip {
|
3376
|
+
background-color: #dbe2eb;
|
3377
|
+
color: #172a41;
|
3378
|
+
font-weight: 500;
|
3379
|
+
|
3380
|
+
&:hover {
|
3381
|
+
background-color: rgb(219, 226, 235);
|
3382
|
+
}
|
3383
|
+
}
|
3384
|
+
|
3385
|
+
.btn-submit-feedback {
|
3386
|
+
background-color: rgb(23, 42, 65);
|
3387
|
+
color: #ffffff;
|
3388
|
+
font-weight: 500;
|
3389
|
+
|
3390
|
+
&:hover {
|
3391
|
+
background-color: rgb(9, 22, 39);
|
3392
|
+
}
|
3393
|
+
|
3394
|
+
&:disabled {
|
3395
|
+
background-color: #e0e0e0;
|
3396
|
+
cursor: not-allowed;
|
3397
|
+
}
|
3398
|
+
}
|
3399
|
+
`;
|
3400
|
+
|
3401
|
+
class FeedbackDialog extends r$2 {
|
3402
|
+
dispatchFeedbackEvent(feedback) {
|
3403
|
+
this.dispatchEvent(new CustomEvent('submit-feedback', {
|
3404
|
+
detail: {
|
3405
|
+
messageId: this.messageId,
|
3406
|
+
feedback,
|
3407
|
+
},
|
3408
|
+
composed: true,
|
3409
|
+
bubbles: true,
|
3410
|
+
}));
|
3411
|
+
}
|
3412
|
+
handleSubmit(e) {
|
3413
|
+
var _a;
|
3414
|
+
e.preventDefault();
|
3415
|
+
const form = e.target;
|
3416
|
+
const data = new FormData(form);
|
3417
|
+
this.dispatchFeedbackEvent({
|
3418
|
+
rating: 'bad',
|
3419
|
+
comment: (_a = data.get('comment')) === null || _a === void 0 ? void 0 : _a.toString().trim(),
|
3420
|
+
});
|
3421
|
+
form.reset();
|
3422
|
+
}
|
3423
|
+
handleSkipComment(e) {
|
3424
|
+
e.preventDefault();
|
3425
|
+
this.comment = '';
|
3426
|
+
this.dispatchFeedbackEvent({ rating: 'bad', comment: null });
|
3427
|
+
}
|
3428
|
+
close(e) {
|
3429
|
+
e.preventDefault();
|
3430
|
+
this.dispatchEvent(new CustomEvent('close', {
|
3431
|
+
composed: true,
|
3432
|
+
bubbles: true,
|
3433
|
+
}));
|
3434
|
+
}
|
3435
|
+
render() {
|
3436
|
+
return x `
|
3437
|
+
<div class="modal">
|
3438
|
+
<div class="header">
|
3439
|
+
<h3>Provide Additional Feedback</h3>
|
3440
|
+
<div class="close" @click=${this.close}>${closeBtn}</div>
|
3441
|
+
</div>
|
3442
|
+
<form @submit=${this.handleSubmit}>
|
3443
|
+
<textarea
|
3444
|
+
name="comment"
|
3445
|
+
@input=${(e) => { var _a; return (this.comment = (_a = e.target) === null || _a === void 0 ? void 0 : _a.value); }}
|
3446
|
+
placeholder="Share your feedback"
|
3447
|
+
required
|
3448
|
+
>
|
3449
|
+
${this.comment ? this.comment : E}</textarea
|
3450
|
+
>
|
3451
|
+
<div class="btns-container">
|
3452
|
+
<button
|
3453
|
+
type="button"
|
3454
|
+
class="btn btn-skip"
|
3455
|
+
@click=${this.handleSkipComment}
|
3456
|
+
>
|
3457
|
+
Skip
|
3458
|
+
</button>
|
3459
|
+
<button
|
3460
|
+
type="submit"
|
3461
|
+
class="btn btn-submit-feedback"
|
3462
|
+
?disabled=${!this.comment}
|
3463
|
+
>
|
3464
|
+
Submit
|
3465
|
+
</button>
|
3466
|
+
</div>
|
3467
|
+
</form>
|
3468
|
+
</div>
|
3469
|
+
`;
|
3470
|
+
}
|
3471
|
+
}
|
3472
|
+
FeedbackDialog.styles = [feedbackDialogStyles];
|
3473
|
+
__decorate([
|
3474
|
+
n({ type: String }),
|
3475
|
+
__metadata("design:type", Object)
|
3476
|
+
], FeedbackDialog.prototype, "messageId", void 0);
|
3477
|
+
__decorate([
|
3478
|
+
n({ type: String }),
|
3479
|
+
__metadata("design:type", Object)
|
3480
|
+
], FeedbackDialog.prototype, "comment", void 0);
|
3481
|
+
if (!customElements.get('feedback-dialog')) {
|
3482
|
+
customElements.define('feedback-dialog', FeedbackDialog);
|
3483
|
+
}
|
3484
|
+
|
3168
3485
|
class ChatSection extends r$2 {
|
3169
3486
|
constructor() {
|
3170
3487
|
super(...arguments);
|
@@ -3212,6 +3529,23 @@ var ProvidersShopGptSdk = (function () {
|
|
3212
3529
|
}));
|
3213
3530
|
this.deleteThreadId = '';
|
3214
3531
|
}
|
3532
|
+
handleFeedback(rating, messageId, comment) {
|
3533
|
+
if (rating === 'bad') {
|
3534
|
+
this.feedbackDetails = { messageId, comment };
|
3535
|
+
return;
|
3536
|
+
}
|
3537
|
+
this.dispatchEvent(new CustomEvent('submit-feedback', {
|
3538
|
+
detail: {
|
3539
|
+
messageId: messageId,
|
3540
|
+
feedback: {
|
3541
|
+
rating,
|
3542
|
+
comment: null,
|
3543
|
+
},
|
3544
|
+
},
|
3545
|
+
composed: true,
|
3546
|
+
bubbles: true,
|
3547
|
+
}));
|
3548
|
+
}
|
3215
3549
|
typingIndicator() {
|
3216
3550
|
return x ` <div class="typing-dots">
|
3217
3551
|
<div class="dot"></div>
|
@@ -3220,7 +3554,7 @@ var ProvidersShopGptSdk = (function () {
|
|
3220
3554
|
</div>`;
|
3221
3555
|
}
|
3222
3556
|
botMessage(message) {
|
3223
|
-
var _a;
|
3557
|
+
var _a, _b, _c, _d, _e;
|
3224
3558
|
return x `
|
3225
3559
|
<div class="message-wrapper">
|
3226
3560
|
<div class="message bot">
|
@@ -3251,6 +3585,26 @@ var ProvidersShopGptSdk = (function () {
|
|
3251
3585
|
.viewType=${this.viewType}
|
3252
3586
|
></products-list>`
|
3253
3587
|
: E}
|
3588
|
+
${message.messageId
|
3589
|
+
? x `<div class="bot-response-actions">
|
3590
|
+
<button
|
3591
|
+
type="button"
|
3592
|
+
@click=${this.handleFeedback.bind(this, 'good', message.messageId, (_b = message.feedback) === null || _b === void 0 ? void 0 : _b.comment)}
|
3593
|
+
>
|
3594
|
+
${((_c = message.feedback) === null || _c === void 0 ? void 0 : _c.rating) === 'good'
|
3595
|
+
? thumbsUpFilledBtn
|
3596
|
+
: thumbsUpBtn}
|
3597
|
+
</button>
|
3598
|
+
<button
|
3599
|
+
type="button"
|
3600
|
+
@click=${this.handleFeedback.bind(this, 'bad', message.messageId, (_d = message.feedback) === null || _d === void 0 ? void 0 : _d.comment)}
|
3601
|
+
>
|
3602
|
+
${((_e = message.feedback) === null || _e === void 0 ? void 0 : _e.rating) === 'bad'
|
3603
|
+
? thumbsDownFilledBtn
|
3604
|
+
: thumbsDownBtn}
|
3605
|
+
</button>
|
3606
|
+
</div>`
|
3607
|
+
: E}
|
3254
3608
|
</div>
|
3255
3609
|
`;
|
3256
3610
|
}
|
@@ -3271,10 +3625,19 @@ var ProvidersShopGptSdk = (function () {
|
|
3271
3625
|
</div>`
|
3272
3626
|
: ''}
|
3273
3627
|
${this.isFailed
|
3274
|
-
?
|
3275
|
-
|
3276
|
-
|
3277
|
-
|
3628
|
+
? x `<div class="message bot">
|
3629
|
+
<div>
|
3630
|
+
<div class="bot-icon">${botIcon}</div>
|
3631
|
+
</div>
|
3632
|
+
<div>
|
3633
|
+
<p>
|
3634
|
+
Uh-oh! Looks like I tripped over some alpha-stage wires.
|
3635
|
+
Things are still a bit wobbly here, buy hey, that's what
|
3636
|
+
testing is for, Let's try that again; or feel free to throw
|
3637
|
+
another challenge my way!
|
3638
|
+
</p>
|
3639
|
+
</div>
|
3640
|
+
</div>`
|
3278
3641
|
: E}
|
3279
3642
|
${this.messages.map((message) => {
|
3280
3643
|
if (message.sender === 'bot') {
|
@@ -3618,6 +3981,21 @@ var ProvidersShopGptSdk = (function () {
|
|
3618
3981
|
</confirm-dialog>
|
3619
3982
|
`
|
3620
3983
|
: E}
|
3984
|
+
${this.feedbackDetails
|
3985
|
+
? x `
|
3986
|
+
<feedback-dialog
|
3987
|
+
.messageId=${this.feedbackDetails.messageId}
|
3988
|
+
.comment=${this.feedbackDetails.comment}
|
3989
|
+
@submit-feedback=${() => {
|
3990
|
+
this.feedbackDetails = undefined;
|
3991
|
+
}}
|
3992
|
+
@close=${(e) => {
|
3993
|
+
e.stopPropagation();
|
3994
|
+
this.feedbackDetails = undefined;
|
3995
|
+
}}
|
3996
|
+
></feedback-dialog>
|
3997
|
+
`
|
3998
|
+
: E}
|
3621
3999
|
`;
|
3622
4000
|
}
|
3623
4001
|
}
|
@@ -3702,6 +4080,10 @@ var ProvidersShopGptSdk = (function () {
|
|
3702
4080
|
e$3('personalize-dialog'),
|
3703
4081
|
__metadata("design:type", Object)
|
3704
4082
|
], ChatSection.prototype, "personalizeDialogElement", void 0);
|
4083
|
+
__decorate([
|
4084
|
+
r(),
|
4085
|
+
__metadata("design:type", Object)
|
4086
|
+
], ChatSection.prototype, "feedbackDetails", void 0);
|
3705
4087
|
__decorate([
|
3706
4088
|
n({ type: String }),
|
3707
4089
|
__metadata("design:type", Object)
|
@@ -3822,6 +4204,7 @@ var ProvidersShopGptSdk = (function () {
|
|
3822
4204
|
}
|
3823
4205
|
this.messages = [
|
3824
4206
|
{
|
4207
|
+
messageId: reply.messageId,
|
3825
4208
|
sender: 'bot',
|
3826
4209
|
message: reply.message,
|
3827
4210
|
products: reply.products,
|
@@ -3889,10 +4272,12 @@ var ProvidersShopGptSdk = (function () {
|
|
3889
4272
|
latestAvailableProducts = products;
|
3890
4273
|
}
|
3891
4274
|
return {
|
4275
|
+
messageId: message.messageId,
|
3892
4276
|
message: message.message,
|
3893
4277
|
sender: message.sender,
|
3894
4278
|
products,
|
3895
4279
|
welcomePrompts: message.welcomePrompts,
|
4280
|
+
feedback: message.feedback,
|
3896
4281
|
};
|
3897
4282
|
});
|
3898
4283
|
this.products = latestAvailableProducts;
|
@@ -3973,6 +4358,7 @@ var ProvidersShopGptSdk = (function () {
|
|
3973
4358
|
}
|
3974
4359
|
this.messages = [
|
3975
4360
|
{
|
4361
|
+
messageId: reply.messageId,
|
3976
4362
|
sender: 'bot',
|
3977
4363
|
message: reply.message,
|
3978
4364
|
products: reply.products,
|
@@ -3992,6 +4378,20 @@ var ProvidersShopGptSdk = (function () {
|
|
3992
4378
|
this.isTyping = false;
|
3993
4379
|
}
|
3994
4380
|
}
|
4381
|
+
submitFeedback(e) {
|
4382
|
+
e.stopPropagation();
|
4383
|
+
this.shopGPTAPI
|
4384
|
+
.saveFeedback(e.detail.messageId, e.detail.feedback)
|
4385
|
+
.then(() => {
|
4386
|
+
const messages = this.messages;
|
4387
|
+
const messageIndex = messages.findIndex(({ messageId }) => messageId === e.detail.messageId);
|
4388
|
+
messages[messageIndex] = {
|
4389
|
+
...messages[messageIndex],
|
4390
|
+
feedback: e.detail.feedback,
|
4391
|
+
};
|
4392
|
+
this.messages = [...messages];
|
4393
|
+
});
|
4394
|
+
}
|
3995
4395
|
getSiteCurrency() {
|
3996
4396
|
return this.storeAPI.getSiteCurrency();
|
3997
4397
|
}
|
@@ -4008,6 +4408,7 @@ var ProvidersShopGptSdk = (function () {
|
|
4008
4408
|
id="shop-gpt-dialog-overlay"
|
4009
4409
|
@delete-thread=${this.handleThreadDelete}
|
4010
4410
|
@delete-all-threads=${this.handleAllThreadsDelete}
|
4411
|
+
@submit-feedback=${this.submitFeedback}
|
4011
4412
|
>
|
4012
4413
|
<div class="mobile-version">
|
4013
4414
|
Please switch to the desktop version for the best experience.
|
@@ -4072,6 +4473,7 @@ var ProvidersShopGptSdk = (function () {
|
|
4072
4473
|
id="shop-gpt-modal"
|
4073
4474
|
@delete-thread=${this.handleThreadDelete}
|
4074
4475
|
@delete-all-threads=${this.handleAllThreadsDelete}
|
4476
|
+
@submit-feedback=${this.submitFeedback}
|
4075
4477
|
>
|
4076
4478
|
<chat-section
|
4077
4479
|
.prompts=${this.quickPrompts}
|