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