@memori.ai/memori-react 6.1.7 → 6.2.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/CHANGELOG.md +20 -0
- package/dist/components/ChatBubble/ChatBubble.css +5 -0
- package/dist/components/ChatBubble/ChatBubble.js +9 -7
- package/dist/components/ChatBubble/ChatBubble.js.map +1 -1
- package/dist/components/MemoriWidget/MemoriWidget.js +58 -5
- package/dist/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/dist/components/PositionDrawer/PositionDrawer.d.ts +8 -1
- package/dist/components/PositionDrawer/PositionDrawer.js +8 -1
- package/dist/components/PositionDrawer/PositionDrawer.js.map +1 -1
- package/dist/components/VenueWidget/VenueWidget.css +142 -0
- package/dist/components/VenueWidget/VenueWidget.d.ts +33 -0
- package/dist/components/VenueWidget/VenueWidget.js +195 -0
- package/dist/components/VenueWidget/VenueWidget.js.map +1 -0
- package/dist/components/ui/Select.d.ts +2 -1
- package/dist/components/ui/Select.js +2 -2
- package/dist/components/ui/Select.js.map +1 -1
- package/dist/helpers/utils.d.ts +1 -0
- package/dist/helpers/utils.js +25 -1
- package/dist/helpers/utils.js.map +1 -1
- package/dist/helpers/venue.d.ts +3 -0
- package/dist/helpers/venue.js +23 -0
- package/dist/helpers/venue.js.map +1 -0
- package/dist/locales/en.json +5 -0
- package/dist/locales/it.json +5 -0
- package/dist/styles.css +1 -0
- package/esm/components/ChatBubble/ChatBubble.css +5 -0
- package/esm/components/ChatBubble/ChatBubble.js +9 -7
- package/esm/components/ChatBubble/ChatBubble.js.map +1 -1
- package/esm/components/MemoriWidget/MemoriWidget.js +58 -5
- package/esm/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/esm/components/PositionDrawer/PositionDrawer.d.ts +8 -1
- package/esm/components/PositionDrawer/PositionDrawer.js +7 -1
- package/esm/components/PositionDrawer/PositionDrawer.js.map +1 -1
- package/esm/components/VenueWidget/VenueWidget.css +142 -0
- package/esm/components/VenueWidget/VenueWidget.d.ts +33 -0
- package/esm/components/VenueWidget/VenueWidget.js +192 -0
- package/esm/components/VenueWidget/VenueWidget.js.map +1 -0
- package/esm/components/ui/Select.d.ts +2 -1
- package/esm/components/ui/Select.js +2 -2
- package/esm/components/ui/Select.js.map +1 -1
- package/esm/helpers/utils.d.ts +1 -0
- package/esm/helpers/utils.js +24 -1
- package/esm/helpers/utils.js.map +1 -1
- package/esm/helpers/venue.d.ts +3 -0
- package/esm/helpers/venue.js +19 -0
- package/esm/helpers/venue.js.map +1 -0
- package/esm/locales/en.json +5 -0
- package/esm/locales/it.json +5 -0
- package/esm/styles.css +1 -0
- package/package.json +5 -2
- package/src/components/Chat/__snapshots__/Chat.test.tsx.snap +0 -154
- package/src/components/ChatBubble/ChatBubble.css +5 -0
- package/src/components/ChatBubble/ChatBubble.tsx +3 -1
- package/src/components/ChatBubble/__snapshots__/ChatBubble.test.tsx.snap +41 -100
- package/src/components/MemoriWidget/MemoriWidget.stories.tsx +9 -0
- package/src/components/MemoriWidget/MemoriWidget.tsx +86 -4
- package/src/components/PositionDrawer/PositionDrawer.stories.tsx +46 -0
- package/src/components/PositionDrawer/PositionDrawer.test.tsx +33 -0
- package/src/components/PositionDrawer/PositionDrawer.tsx +24 -5
- package/src/components/PositionDrawer/__snapshots__/PositionDrawer.test.tsx.snap +5 -0
- package/src/components/VenueWidget/VenueWidget.css +142 -0
- package/src/components/VenueWidget/VenueWidget.stories.tsx +66 -0
- package/src/components/VenueWidget/VenueWidget.test.tsx +49 -0
- package/src/components/VenueWidget/VenueWidget.tsx +430 -0
- package/src/components/VenueWidget/__snapshots__/VenueWidget.test.tsx.snap +335 -0
- package/src/components/ui/Select.tsx +3 -1
- package/src/components/ui/__snapshots__/Select.test.tsx.snap +0 -24
- package/src/helpers/utils.ts +36 -1
- package/src/helpers/venue.ts +36 -0
- package/src/locales/en.json +5 -0
- package/src/locales/it.json +5 -0
- package/src/mocks/data.ts +8 -0
- package/src/styles.css +1 -0
|
@@ -12,8 +12,6 @@ exports[`renders ChatBubble from user with avatar as react element unchanged 1`]
|
|
|
12
12
|
<p>
|
|
13
13
|
Proin libero ante, dignissim sit amet turpis a, pretium condimentum dolor.
|
|
14
14
|
</p>
|
|
15
|
-
|
|
16
|
-
|
|
17
15
|
</div>
|
|
18
16
|
</div>
|
|
19
17
|
<div
|
|
@@ -39,8 +37,6 @@ exports[`renders ChatBubble from user with avatar unchanged 1`] = `
|
|
|
39
37
|
<p>
|
|
40
38
|
Proin libero ante, dignissim sit amet turpis a, pretium condimentum dolor.
|
|
41
39
|
</p>
|
|
42
|
-
|
|
43
|
-
|
|
44
40
|
</div>
|
|
45
41
|
</div>
|
|
46
42
|
<picture
|
|
@@ -68,8 +64,6 @@ exports[`renders ChatBubble from user with custom avatar unchanged 1`] = `
|
|
|
68
64
|
<p>
|
|
69
65
|
Proin libero ante, dignissim sit amet turpis a, pretium condimentum dolor.
|
|
70
66
|
</p>
|
|
71
|
-
|
|
72
|
-
|
|
73
67
|
</div>
|
|
74
68
|
</div>
|
|
75
69
|
<picture
|
|
@@ -107,8 +101,6 @@ exports[`renders ChatBubble unchanged 1`] = `
|
|
|
107
101
|
<p>
|
|
108
102
|
Proin libero ante, dignissim sit amet turpis a, pretium condimentum dolor.
|
|
109
103
|
</p>
|
|
110
|
-
|
|
111
|
-
|
|
112
104
|
</div>
|
|
113
105
|
</div>
|
|
114
106
|
</div>
|
|
@@ -140,8 +132,6 @@ exports[`renders ChatBubble with initial msg unchanged 1`] = `
|
|
|
140
132
|
<p>
|
|
141
133
|
Proin libero ante, dignissim sit amet turpis a, pretium condimentum dolor.
|
|
142
134
|
</p>
|
|
143
|
-
|
|
144
|
-
|
|
145
135
|
</div>
|
|
146
136
|
</div>
|
|
147
137
|
</div>
|
|
@@ -170,16 +160,13 @@ exports[`renders ChatBubble with markdown unchanged 1`] = `
|
|
|
170
160
|
<h2>
|
|
171
161
|
Test
|
|
172
162
|
</h2>
|
|
173
|
-
|
|
174
|
-
|
|
163
|
+
<br />
|
|
175
164
|
<p>
|
|
176
165
|
Ecco tutte le possibili personalizzazioni che puoi applicare:
|
|
177
166
|
</p>
|
|
178
|
-
|
|
179
|
-
|
|
167
|
+
<br />
|
|
180
168
|
<ul>
|
|
181
|
-
|
|
182
|
-
|
|
169
|
+
<br />
|
|
183
170
|
<li>
|
|
184
171
|
<p>
|
|
185
172
|
<strong>
|
|
@@ -187,27 +174,21 @@ exports[`renders ChatBubble with markdown unchanged 1`] = `
|
|
|
187
174
|
</strong>
|
|
188
175
|
:
|
|
189
176
|
</p>
|
|
190
|
-
|
|
191
|
-
|
|
177
|
+
<br />
|
|
192
178
|
<ul>
|
|
193
|
-
|
|
194
|
-
|
|
179
|
+
<br />
|
|
195
180
|
<li>
|
|
196
181
|
Girocollo
|
|
197
182
|
</li>
|
|
198
|
-
|
|
199
|
-
|
|
183
|
+
<br />
|
|
200
184
|
<li>
|
|
201
185
|
Scollo a V
|
|
202
186
|
</li>
|
|
203
|
-
|
|
204
|
-
|
|
187
|
+
<br />
|
|
205
188
|
</ul>
|
|
206
|
-
|
|
207
|
-
|
|
189
|
+
<br />
|
|
208
190
|
</li>
|
|
209
|
-
|
|
210
|
-
|
|
191
|
+
<br />
|
|
211
192
|
<li>
|
|
212
193
|
<p>
|
|
213
194
|
<strong>
|
|
@@ -215,27 +196,21 @@ exports[`renders ChatBubble with markdown unchanged 1`] = `
|
|
|
215
196
|
</strong>
|
|
216
197
|
:
|
|
217
198
|
</p>
|
|
218
|
-
|
|
219
|
-
|
|
199
|
+
<br />
|
|
220
200
|
<ul>
|
|
221
|
-
|
|
222
|
-
|
|
201
|
+
<br />
|
|
223
202
|
<li>
|
|
224
203
|
Manica Lunga
|
|
225
204
|
</li>
|
|
226
|
-
|
|
227
|
-
|
|
205
|
+
<br />
|
|
228
206
|
<li>
|
|
229
207
|
Manica Corta
|
|
230
208
|
</li>
|
|
231
|
-
|
|
232
|
-
|
|
209
|
+
<br />
|
|
233
210
|
</ul>
|
|
234
|
-
|
|
235
|
-
|
|
211
|
+
<br />
|
|
236
212
|
</li>
|
|
237
|
-
|
|
238
|
-
|
|
213
|
+
<br />
|
|
239
214
|
<li>
|
|
240
215
|
<p>
|
|
241
216
|
<strong>
|
|
@@ -243,52 +218,41 @@ exports[`renders ChatBubble with markdown unchanged 1`] = `
|
|
|
243
218
|
</strong>
|
|
244
219
|
:
|
|
245
220
|
</p>
|
|
246
|
-
|
|
247
|
-
|
|
221
|
+
<br />
|
|
248
222
|
<ul>
|
|
249
|
-
|
|
250
|
-
|
|
223
|
+
<br />
|
|
251
224
|
<li>
|
|
252
225
|
XS
|
|
253
226
|
</li>
|
|
254
|
-
|
|
255
|
-
|
|
227
|
+
<br />
|
|
256
228
|
<li>
|
|
257
229
|
S
|
|
258
230
|
</li>
|
|
259
|
-
|
|
260
|
-
|
|
231
|
+
<br />
|
|
261
232
|
<li>
|
|
262
233
|
M
|
|
263
234
|
</li>
|
|
264
|
-
|
|
265
|
-
|
|
235
|
+
<br />
|
|
266
236
|
<li>
|
|
267
237
|
L
|
|
268
238
|
</li>
|
|
269
|
-
|
|
270
|
-
|
|
239
|
+
<br />
|
|
271
240
|
<li>
|
|
272
241
|
XL
|
|
273
242
|
</li>
|
|
274
|
-
|
|
275
|
-
|
|
243
|
+
<br />
|
|
276
244
|
<li>
|
|
277
245
|
XXL
|
|
278
246
|
</li>
|
|
279
|
-
|
|
280
|
-
|
|
247
|
+
<br />
|
|
281
248
|
<li>
|
|
282
249
|
3XL
|
|
283
250
|
</li>
|
|
284
|
-
|
|
285
|
-
|
|
251
|
+
<br />
|
|
286
252
|
</ul>
|
|
287
|
-
|
|
288
|
-
|
|
253
|
+
<br />
|
|
289
254
|
</li>
|
|
290
|
-
|
|
291
|
-
|
|
255
|
+
<br />
|
|
292
256
|
<li>
|
|
293
257
|
<p>
|
|
294
258
|
<strong>
|
|
@@ -296,37 +260,29 @@ exports[`renders ChatBubble with markdown unchanged 1`] = `
|
|
|
296
260
|
</strong>
|
|
297
261
|
:
|
|
298
262
|
</p>
|
|
299
|
-
|
|
300
|
-
|
|
263
|
+
<br />
|
|
301
264
|
<ul>
|
|
302
|
-
|
|
303
|
-
|
|
265
|
+
<br />
|
|
304
266
|
<li>
|
|
305
267
|
Fronte Petto
|
|
306
268
|
</li>
|
|
307
|
-
|
|
308
|
-
|
|
269
|
+
<br />
|
|
309
270
|
<li>
|
|
310
271
|
Retro Schiena
|
|
311
272
|
</li>
|
|
312
|
-
|
|
313
|
-
|
|
273
|
+
<br />
|
|
314
274
|
<li>
|
|
315
275
|
Fronte DX
|
|
316
276
|
</li>
|
|
317
|
-
|
|
318
|
-
|
|
277
|
+
<br />
|
|
319
278
|
<li>
|
|
320
279
|
Fronte SX
|
|
321
280
|
</li>
|
|
322
|
-
|
|
323
|
-
|
|
281
|
+
<br />
|
|
324
282
|
</ul>
|
|
325
|
-
|
|
326
|
-
|
|
283
|
+
<br />
|
|
327
284
|
</li>
|
|
328
|
-
|
|
329
|
-
|
|
285
|
+
<br />
|
|
330
286
|
<li>
|
|
331
287
|
<p>
|
|
332
288
|
<strong>
|
|
@@ -334,30 +290,23 @@ exports[`renders ChatBubble with markdown unchanged 1`] = `
|
|
|
334
290
|
</strong>
|
|
335
291
|
:
|
|
336
292
|
</p>
|
|
337
|
-
|
|
338
|
-
|
|
293
|
+
<br />
|
|
339
294
|
<ul>
|
|
340
|
-
|
|
341
|
-
|
|
295
|
+
<br />
|
|
342
296
|
<li>
|
|
343
297
|
Prompt generazione immagine
|
|
344
298
|
</li>
|
|
345
|
-
|
|
346
|
-
|
|
299
|
+
<br />
|
|
347
300
|
</ul>
|
|
348
|
-
|
|
349
|
-
|
|
301
|
+
<br />
|
|
350
302
|
</li>
|
|
351
|
-
|
|
352
|
-
|
|
303
|
+
<br />
|
|
353
304
|
</ul>
|
|
354
|
-
|
|
355
|
-
|
|
305
|
+
<br />
|
|
356
306
|
<p>
|
|
357
307
|
Seleziona le personalizzazioni che desideri applicare.
|
|
358
308
|
</p>
|
|
359
|
-
|
|
360
|
-
|
|
309
|
+
<br />
|
|
361
310
|
<p>
|
|
362
311
|
<a
|
|
363
312
|
href="https://memori.ai"
|
|
@@ -367,8 +316,6 @@ exports[`renders ChatBubble with markdown unchanged 1`] = `
|
|
|
367
316
|
Vedi altro
|
|
368
317
|
</a>
|
|
369
318
|
</p>
|
|
370
|
-
|
|
371
|
-
|
|
372
319
|
</div>
|
|
373
320
|
</div>
|
|
374
321
|
</div>
|
|
@@ -387,8 +334,6 @@ exports[`renders ChatBubble with msg from BoE expert unchanged 1`] = `
|
|
|
387
334
|
<p>
|
|
388
335
|
Proin libero ante, dignissim sit amet turpis a, pretium condimentum dolor.
|
|
389
336
|
</p>
|
|
390
|
-
|
|
391
|
-
|
|
392
337
|
</div>
|
|
393
338
|
<div
|
|
394
339
|
class="memori-chat--bubble-addon"
|
|
@@ -471,8 +416,6 @@ exports[`renders ChatBubble with msg generated by AI unchanged 1`] = `
|
|
|
471
416
|
<p>
|
|
472
417
|
Proin libero ante, dignissim sit amet turpis a, pretium condimentum dolor.
|
|
473
418
|
</p>
|
|
474
|
-
|
|
475
|
-
|
|
476
419
|
</div>
|
|
477
420
|
<div
|
|
478
421
|
class="memori-chat--bubble-addon"
|
|
@@ -555,8 +498,6 @@ exports[`renders ChatBubble with user msg unchanged 1`] = `
|
|
|
555
498
|
<p>
|
|
556
499
|
Proin libero ante, dignissim sit amet turpis a, pretium condimentum dolor.
|
|
557
500
|
</p>
|
|
558
|
-
|
|
559
|
-
|
|
560
501
|
</div>
|
|
561
502
|
</div>
|
|
562
503
|
<div
|
|
@@ -56,6 +56,15 @@ WithPosition.args = {
|
|
|
56
56
|
tenant,
|
|
57
57
|
};
|
|
58
58
|
|
|
59
|
+
export const WithDates = Template.bind({});
|
|
60
|
+
WithDates.args = {
|
|
61
|
+
memori: {
|
|
62
|
+
...memori,
|
|
63
|
+
needsDateTime: true,
|
|
64
|
+
},
|
|
65
|
+
tenant,
|
|
66
|
+
};
|
|
67
|
+
|
|
59
68
|
export const WithPublicPageIntegration = Template.bind({});
|
|
60
69
|
WithPublicPageIntegration.args = {
|
|
61
70
|
memori,
|
|
@@ -37,7 +37,7 @@ import memoriApiClient from '@memori.ai/memori-api-client';
|
|
|
37
37
|
import { AudioContext, IAudioContext } from 'standardized-audio-context';
|
|
38
38
|
import * as speechSdk from 'microsoft-cognitiveservices-speech-sdk';
|
|
39
39
|
import cx from 'classnames';
|
|
40
|
-
|
|
40
|
+
import { DateTime } from 'luxon';
|
|
41
41
|
import toast from 'react-hot-toast';
|
|
42
42
|
|
|
43
43
|
// Components
|
|
@@ -416,6 +416,7 @@ const MemoriWidget = ({
|
|
|
416
416
|
initSession,
|
|
417
417
|
postTextEnteredEvent,
|
|
418
418
|
postPlaceChangedEvent,
|
|
419
|
+
postDateChangedEvent,
|
|
419
420
|
postTimeoutEvent,
|
|
420
421
|
postTagChangedEvent,
|
|
421
422
|
getSession,
|
|
@@ -965,8 +966,6 @@ const MemoriWidget = ({
|
|
|
965
966
|
) {
|
|
966
967
|
setSessionId(session.sessionID);
|
|
967
968
|
|
|
968
|
-
if (position) applyPosition(position, session.sessionID);
|
|
969
|
-
|
|
970
969
|
setLoading(false);
|
|
971
970
|
return {
|
|
972
971
|
dialogState: session.currentState,
|
|
@@ -1082,6 +1081,8 @@ const MemoriWidget = ({
|
|
|
1082
1081
|
}
|
|
1083
1082
|
|
|
1084
1083
|
if (position) applyPosition(position, sessionID);
|
|
1084
|
+
if (memori.needsDateTime)
|
|
1085
|
+
sendDateChangedEvent({ sessionID: sessionID, state: currentState });
|
|
1085
1086
|
|
|
1086
1087
|
setLoading(false);
|
|
1087
1088
|
return {
|
|
@@ -1228,6 +1229,65 @@ const MemoriWidget = ({
|
|
|
1228
1229
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1229
1230
|
}, []);
|
|
1230
1231
|
|
|
1232
|
+
/**
|
|
1233
|
+
* Polling dates
|
|
1234
|
+
*/
|
|
1235
|
+
const sendDateChangedEvent = useCallback(
|
|
1236
|
+
async ({
|
|
1237
|
+
sessionID,
|
|
1238
|
+
date,
|
|
1239
|
+
state,
|
|
1240
|
+
}: {
|
|
1241
|
+
sessionID?: string;
|
|
1242
|
+
date?: string;
|
|
1243
|
+
state?: DialogState;
|
|
1244
|
+
}) => {
|
|
1245
|
+
const session = sessionID ?? sessionId;
|
|
1246
|
+
const dialogState = state ?? currentDialogState;
|
|
1247
|
+
|
|
1248
|
+
console.log('sendDateChangedEvent', dialogState);
|
|
1249
|
+
if (!session || !memori.needsDateTime || dialogState?.hints?.length) {
|
|
1250
|
+
return;
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
const now = (date ? DateTime.fromISO(date) : DateTime.now())
|
|
1254
|
+
.toUTC()
|
|
1255
|
+
.toFormat('yyyy/MM/dd HH:mm:ss ZZ')
|
|
1256
|
+
.split(':')
|
|
1257
|
+
.slice(0, -1)
|
|
1258
|
+
.join(':');
|
|
1259
|
+
|
|
1260
|
+
const { currentState, ...response } = await postDateChangedEvent(
|
|
1261
|
+
session,
|
|
1262
|
+
now
|
|
1263
|
+
);
|
|
1264
|
+
|
|
1265
|
+
if (response.resultCode === 0 && currentState) {
|
|
1266
|
+
_setCurrentDialogState(cds => ({
|
|
1267
|
+
...cds,
|
|
1268
|
+
...currentState,
|
|
1269
|
+
hints: currentState.hints?.length ? currentState.hints : cds?.hints,
|
|
1270
|
+
}));
|
|
1271
|
+
}
|
|
1272
|
+
},
|
|
1273
|
+
[currentDialogState, memori.needsDateTime, sessionId]
|
|
1274
|
+
);
|
|
1275
|
+
useEffect(() => {
|
|
1276
|
+
if (sessionId && memori.needsDateTime) {
|
|
1277
|
+
sendDateChangedEvent({ sessionID: sessionId, state: currentDialogState });
|
|
1278
|
+
|
|
1279
|
+
let datePolling = setInterval(() => {
|
|
1280
|
+
sendDateChangedEvent({
|
|
1281
|
+
sessionID: sessionId,
|
|
1282
|
+
});
|
|
1283
|
+
}, 60 * 1000); // 1 minute
|
|
1284
|
+
|
|
1285
|
+
return () => {
|
|
1286
|
+
clearInterval(datePolling);
|
|
1287
|
+
};
|
|
1288
|
+
}
|
|
1289
|
+
}, [memori.needsDateTime, sessionId]);
|
|
1290
|
+
|
|
1231
1291
|
/**
|
|
1232
1292
|
* Timeout conversazione
|
|
1233
1293
|
*/
|
|
@@ -2371,6 +2431,11 @@ const MemoriWidget = ({
|
|
|
2371
2431
|
// reset history
|
|
2372
2432
|
setHistory([]);
|
|
2373
2433
|
|
|
2434
|
+
// date and place events
|
|
2435
|
+
if (position) applyPosition(position, sessionID);
|
|
2436
|
+
if (memori.needsDateTime)
|
|
2437
|
+
sendDateChangedEvent({ sessionID: sessionID, state: currentState });
|
|
2438
|
+
|
|
2374
2439
|
// checks engine state for current tag
|
|
2375
2440
|
// opening session would have already correct tag
|
|
2376
2441
|
// otherwise change tag to anonymous for test, giver for instruct, receiver if set
|
|
@@ -2540,6 +2605,11 @@ const MemoriWidget = ({
|
|
|
2540
2605
|
setHasUserActivatedSpeak(true);
|
|
2541
2606
|
});
|
|
2542
2607
|
}
|
|
2608
|
+
|
|
2609
|
+
// date and place events
|
|
2610
|
+
if (position) applyPosition(position, sessionID);
|
|
2611
|
+
if (memori.needsDateTime)
|
|
2612
|
+
sendDateChangedEvent({ sessionID: sessionID, state: currentState });
|
|
2543
2613
|
} else {
|
|
2544
2614
|
// reset history
|
|
2545
2615
|
setHistory([]);
|
|
@@ -2556,7 +2626,7 @@ const MemoriWidget = ({
|
|
|
2556
2626
|
});
|
|
2557
2627
|
}
|
|
2558
2628
|
},
|
|
2559
|
-
[memoriPwd, memori, memoriTokens, birthDate, sessionId, userLang]
|
|
2629
|
+
[memoriPwd, memori, memoriTokens, birthDate, sessionId, userLang, position]
|
|
2560
2630
|
);
|
|
2561
2631
|
useEffect(() => {
|
|
2562
2632
|
const targetNode =
|
|
@@ -2969,6 +3039,18 @@ const MemoriWidget = ({
|
|
|
2969
3039
|
/>
|
|
2970
3040
|
)}
|
|
2971
3041
|
|
|
3042
|
+
{showPositionDrawer && (
|
|
3043
|
+
<PositionDrawer
|
|
3044
|
+
open={!!showPositionDrawer}
|
|
3045
|
+
venue={position}
|
|
3046
|
+
setVenue={setPosition}
|
|
3047
|
+
onClose={position => {
|
|
3048
|
+
if (position) applyPosition(position);
|
|
3049
|
+
setShowPositionDrawer(false);
|
|
3050
|
+
}}
|
|
3051
|
+
/>
|
|
3052
|
+
)}
|
|
3053
|
+
|
|
2972
3054
|
{showKnownFactsDrawer && sessionId && (
|
|
2973
3055
|
<KnownFacts
|
|
2974
3056
|
apiURL={apiUrl}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Meta, Story } from '@storybook/react';
|
|
3
|
+
import I18nWrapper from '../../I18nWrapper';
|
|
4
|
+
import PositionDrawer, { Props } from './PositionDrawer';
|
|
5
|
+
import { Venue } from '@memori.ai/memori-api-client/dist/types';
|
|
6
|
+
import { venue } from '../../mocks/data';
|
|
7
|
+
|
|
8
|
+
const meta: Meta = {
|
|
9
|
+
title: 'Widget/PositionDrawer',
|
|
10
|
+
component: PositionDrawer,
|
|
11
|
+
argTypes: {
|
|
12
|
+
open: {
|
|
13
|
+
control: {
|
|
14
|
+
type: 'boolean',
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
parameters: {
|
|
19
|
+
controls: { expanded: true },
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default meta;
|
|
24
|
+
|
|
25
|
+
const Template: Story<Props> = args => {
|
|
26
|
+
const [venue, setVenue] = React.useState<Venue | undefined>(args.venue);
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<I18nWrapper>
|
|
30
|
+
<PositionDrawer {...args} venue={venue} setVenue={setVenue} />
|
|
31
|
+
</I18nWrapper>
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// By passing using the Args format for exported stories, you can control the props for a component for reuse in a test
|
|
36
|
+
// https://storybook.js.org/docs/react/workflows/unit-testing
|
|
37
|
+
export const Default = Template.bind({});
|
|
38
|
+
Default.args = {
|
|
39
|
+
open: true,
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const WithVenue = Template.bind({});
|
|
43
|
+
WithVenue.args = {
|
|
44
|
+
open: true,
|
|
45
|
+
venue,
|
|
46
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
import PositionDrawer from './PositionDrawer';
|
|
4
|
+
import { venue } from '../../mocks/data';
|
|
5
|
+
|
|
6
|
+
beforeEach(() => {
|
|
7
|
+
// @ts-ignore
|
|
8
|
+
window.IntersectionObserver = jest.fn(() => ({
|
|
9
|
+
observe: jest.fn(),
|
|
10
|
+
unobserve: jest.fn(),
|
|
11
|
+
disconnect: jest.fn(),
|
|
12
|
+
takeRecords: jest.fn(),
|
|
13
|
+
}));
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it('renders PositionDrawer unchanged', () => {
|
|
17
|
+
const { container } = render(
|
|
18
|
+
<PositionDrawer open={false} onClose={jest.fn()} setVenue={jest.fn()} />
|
|
19
|
+
);
|
|
20
|
+
expect(container).toMatchSnapshot();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('renders VenueWidget with venue set', () => {
|
|
24
|
+
const { container } = render(
|
|
25
|
+
<PositionDrawer
|
|
26
|
+
open={false}
|
|
27
|
+
onClose={jest.fn()}
|
|
28
|
+
venue={venue}
|
|
29
|
+
setVenue={jest.fn()}
|
|
30
|
+
/>
|
|
31
|
+
);
|
|
32
|
+
expect(container).toMatchSnapshot();
|
|
33
|
+
});
|
|
@@ -1,9 +1,28 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { Venue } from '@memori.ai/memori-api-client/dist/types';
|
|
3
|
+
import Drawer from '../ui/Drawer';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import VenueWidget from '../VenueWidget/VenueWidget';
|
|
2
6
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
);
|
|
7
|
+
export interface Props {
|
|
8
|
+
open: boolean;
|
|
9
|
+
onClose: (venue?: Venue) => void;
|
|
10
|
+
venue?: Venue;
|
|
11
|
+
setVenue: (venue?: Venue) => void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const PositionDrawer = ({ open, onClose, venue, setVenue }: Props) => {
|
|
15
|
+
const { t } = useTranslation();
|
|
16
|
+
return (
|
|
17
|
+
<Drawer
|
|
18
|
+
className="memori-position-drawer"
|
|
19
|
+
open={open}
|
|
20
|
+
onClose={() => onClose(venue)}
|
|
21
|
+
title={t('widget.position') || 'Position'}
|
|
22
|
+
>
|
|
23
|
+
<VenueWidget venue={venue} setVenue={setVenue} showUncertainty={false} />
|
|
24
|
+
</Drawer>
|
|
25
|
+
);
|
|
26
|
+
};
|
|
8
27
|
|
|
9
28
|
export default PositionDrawer;
|