@memori.ai/memori-react 6.2.0 → 6.3.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/CHANGELOG.md +33 -0
- package/dist/components/Header/Header.css +14 -1
- package/dist/components/Header/Header.js +1 -1
- package/dist/components/Header/Header.js.map +1 -1
- package/dist/components/MediaWidget/MediaItemWidget.js +7 -1
- package/dist/components/MediaWidget/MediaItemWidget.js.map +1 -1
- package/dist/components/MemoriWidget/MemoriWidget.js +43 -19
- package/dist/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/dist/components/PositionDrawer/PositionDrawer.d.ts +4 -3
- package/dist/components/PositionDrawer/PositionDrawer.js +5 -2
- package/dist/components/PositionDrawer/PositionDrawer.js.map +1 -1
- package/dist/components/StartPanel/StartPanel.js +2 -1
- package/dist/components/StartPanel/StartPanel.js.map +1 -1
- package/dist/components/VenueWidget/VenueWidget.d.ts +3 -2
- package/dist/components/VenueWidget/VenueWidget.js +31 -14
- package/dist/components/VenueWidget/VenueWidget.js.map +1 -1
- package/dist/components/ui/Drawer.d.ts +1 -0
- package/dist/components/ui/Drawer.js +1 -1
- package/dist/components/ui/Drawer.js.map +1 -1
- package/dist/helpers/configuration.js +1 -0
- package/dist/helpers/configuration.js.map +1 -1
- package/dist/locales/en.json +3 -1
- package/dist/locales/it.json +3 -2
- package/esm/components/Header/Header.css +14 -1
- package/esm/components/Header/Header.js +1 -1
- package/esm/components/Header/Header.js.map +1 -1
- package/esm/components/MediaWidget/MediaItemWidget.js +7 -1
- package/esm/components/MediaWidget/MediaItemWidget.js.map +1 -1
- package/esm/components/MemoriWidget/MemoriWidget.js +43 -19
- package/esm/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/esm/components/PositionDrawer/PositionDrawer.d.ts +4 -3
- package/esm/components/PositionDrawer/PositionDrawer.js +6 -3
- package/esm/components/PositionDrawer/PositionDrawer.js.map +1 -1
- package/esm/components/StartPanel/StartPanel.js +2 -1
- package/esm/components/StartPanel/StartPanel.js.map +1 -1
- package/esm/components/VenueWidget/VenueWidget.d.ts +3 -2
- package/esm/components/VenueWidget/VenueWidget.js +31 -14
- package/esm/components/VenueWidget/VenueWidget.js.map +1 -1
- package/esm/components/ui/Drawer.d.ts +1 -0
- package/esm/components/ui/Drawer.js +1 -1
- package/esm/components/ui/Drawer.js.map +1 -1
- package/esm/helpers/configuration.js +1 -0
- package/esm/helpers/configuration.js.map +1 -1
- package/esm/locales/en.json +3 -1
- package/esm/locales/it.json +3 -2
- package/package.json +1 -1
- package/src/components/Header/Header.css +14 -1
- package/src/components/Header/Header.tsx +8 -4
- package/src/components/Header/__snapshots__/Header.test.tsx.snap +2 -1
- package/src/components/MediaWidget/MediaItemWidget.stories.tsx +24 -0
- package/src/components/MediaWidget/MediaItemWidget.test.tsx +29 -0
- package/src/components/MediaWidget/MediaItemWidget.tsx +18 -5
- package/src/components/MediaWidget/__snapshots__/MediaItemWidget.test.tsx.snap +190 -0
- package/src/components/MemoriWidget/MemoriWidget.tsx +46 -15
- package/src/components/PositionDrawer/PositionDrawer.stories.tsx +7 -2
- package/src/components/PositionDrawer/PositionDrawer.test.tsx +9 -3
- package/src/components/PositionDrawer/PositionDrawer.tsx +16 -4
- package/src/components/PositionDrawer/__snapshots__/PositionDrawer.test.tsx.snap +14 -2
- package/src/components/StartPanel/StartPanel.tsx +5 -1
- package/src/components/StartPanel/__snapshots__/StartPanel.test.tsx.snap +18 -2
- package/src/components/VenueWidget/VenueWidget.tsx +44 -15
- package/src/components/VenueWidget/__snapshots__/VenueWidget.test.tsx.snap +39 -4
- package/src/components/ui/Drawer.tsx +5 -2
- package/src/helpers/configuration.ts +1 -0
- package/src/locales/en.json +3 -1
- package/src/locales/it.json +3 -2
|
@@ -12,7 +12,6 @@ import {
|
|
|
12
12
|
Invitation,
|
|
13
13
|
GamificationLevel,
|
|
14
14
|
Tenant,
|
|
15
|
-
Asset,
|
|
16
15
|
MemoriSession,
|
|
17
16
|
User,
|
|
18
17
|
ExpertReference,
|
|
@@ -561,7 +560,11 @@ const MemoriWidget = ({
|
|
|
561
560
|
});
|
|
562
561
|
|
|
563
562
|
if (currentState && response.resultCode === 0) {
|
|
564
|
-
|
|
563
|
+
_setCurrentDialogState(cds => ({
|
|
564
|
+
...cds,
|
|
565
|
+
...currentState,
|
|
566
|
+
hints: currentState.hints?.length ? currentState.hints : cds?.hints,
|
|
567
|
+
}));
|
|
565
568
|
}
|
|
566
569
|
}
|
|
567
570
|
};
|
|
@@ -569,8 +572,21 @@ const MemoriWidget = ({
|
|
|
569
572
|
const setPosition = (venue?: Venue) => {
|
|
570
573
|
_setPosition(venue);
|
|
571
574
|
applyPosition(venue);
|
|
575
|
+
|
|
576
|
+
if (venue) {
|
|
577
|
+
setLocalConfig('position', JSON.stringify(venue));
|
|
578
|
+
} else {
|
|
579
|
+
removeLocalConfig('position');
|
|
580
|
+
}
|
|
572
581
|
};
|
|
573
582
|
|
|
583
|
+
useEffect(() => {
|
|
584
|
+
const position = getLocalConfig<Venue | undefined>('position', undefined);
|
|
585
|
+
if (position) {
|
|
586
|
+
_setPosition(position);
|
|
587
|
+
}
|
|
588
|
+
}, []);
|
|
589
|
+
|
|
574
590
|
/**
|
|
575
591
|
* History e gestione invio messaggi
|
|
576
592
|
*/
|
|
@@ -966,6 +982,8 @@ const MemoriWidget = ({
|
|
|
966
982
|
) {
|
|
967
983
|
setSessionId(session.sessionID);
|
|
968
984
|
|
|
985
|
+
if (position) applyPosition(position, session.sessionID);
|
|
986
|
+
|
|
969
987
|
setLoading(false);
|
|
970
988
|
return {
|
|
971
989
|
dialogState: session.currentState,
|
|
@@ -1245,7 +1263,6 @@ const MemoriWidget = ({
|
|
|
1245
1263
|
const session = sessionID ?? sessionId;
|
|
1246
1264
|
const dialogState = state ?? currentDialogState;
|
|
1247
1265
|
|
|
1248
|
-
console.log('sendDateChangedEvent', dialogState);
|
|
1249
1266
|
if (!session || !memori.needsDateTime || dialogState?.hints?.length) {
|
|
1250
1267
|
return;
|
|
1251
1268
|
}
|
|
@@ -2381,8 +2398,9 @@ const MemoriWidget = ({
|
|
|
2381
2398
|
tag: personification?.tag,
|
|
2382
2399
|
pin: personification?.pin,
|
|
2383
2400
|
initialContextVars: {
|
|
2384
|
-
PATHNAME: window.location.pathname,
|
|
2385
|
-
ROUTE:
|
|
2401
|
+
PATHNAME: window.location.pathname?.toUpperCase(),
|
|
2402
|
+
ROUTE:
|
|
2403
|
+
window.location.pathname?.split('/')?.pop()?.toUpperCase() || '',
|
|
2386
2404
|
...(initialContextVars || {}),
|
|
2387
2405
|
},
|
|
2388
2406
|
initialQuestion,
|
|
@@ -2481,8 +2499,10 @@ const MemoriWidget = ({
|
|
|
2481
2499
|
memori?.giverTag,
|
|
2482
2500
|
memori?.giverPIN,
|
|
2483
2501
|
{
|
|
2484
|
-
PATHNAME: window.location.pathname,
|
|
2485
|
-
ROUTE:
|
|
2502
|
+
PATHNAME: window.location.pathname?.toUpperCase(),
|
|
2503
|
+
ROUTE:
|
|
2504
|
+
window.location.pathname?.split('/')?.pop()?.toUpperCase() ||
|
|
2505
|
+
'',
|
|
2486
2506
|
...(initialContextVars || {}),
|
|
2487
2507
|
},
|
|
2488
2508
|
initialQuestion,
|
|
@@ -2532,8 +2552,10 @@ const MemoriWidget = ({
|
|
|
2532
2552
|
personification.tag,
|
|
2533
2553
|
personification.pin,
|
|
2534
2554
|
{
|
|
2535
|
-
PATHNAME: window.location.pathname,
|
|
2536
|
-
ROUTE:
|
|
2555
|
+
PATHNAME: window.location.pathname?.toUpperCase(),
|
|
2556
|
+
ROUTE:
|
|
2557
|
+
window.location.pathname?.split('/')?.pop()?.toUpperCase() ||
|
|
2558
|
+
'',
|
|
2537
2559
|
...(initialContextVars || {}),
|
|
2538
2560
|
},
|
|
2539
2561
|
initialQuestion,
|
|
@@ -2583,8 +2605,10 @@ const MemoriWidget = ({
|
|
|
2583
2605
|
undefined,
|
|
2584
2606
|
undefined,
|
|
2585
2607
|
{
|
|
2586
|
-
PATHNAME: window.location.pathname,
|
|
2587
|
-
ROUTE:
|
|
2608
|
+
PATHNAME: window.location.pathname?.toUpperCase(),
|
|
2609
|
+
ROUTE:
|
|
2610
|
+
window.location.pathname?.split('/')?.pop()?.toUpperCase() ||
|
|
2611
|
+
'',
|
|
2588
2612
|
...(initialContextVars || {}),
|
|
2589
2613
|
},
|
|
2590
2614
|
initialQuestion,
|
|
@@ -2959,8 +2983,10 @@ const MemoriWidget = ({
|
|
|
2959
2983
|
instruct ? memori.giverTag : personification?.tag,
|
|
2960
2984
|
instruct ? memori.giverPIN : personification?.pin,
|
|
2961
2985
|
{
|
|
2962
|
-
PATHNAME: window.location.pathname,
|
|
2963
|
-
ROUTE:
|
|
2986
|
+
PATHNAME: window.location.pathname?.toUpperCase(),
|
|
2987
|
+
ROUTE:
|
|
2988
|
+
window.location.pathname?.split('/')?.pop()?.toUpperCase() ||
|
|
2989
|
+
'',
|
|
2964
2990
|
...(initialContextVars || {}),
|
|
2965
2991
|
},
|
|
2966
2992
|
initialQuestion,
|
|
@@ -2998,8 +3024,12 @@ const MemoriWidget = ({
|
|
|
2998
3024
|
instruct ? memori.giverTag : personification?.tag,
|
|
2999
3025
|
instruct ? memori.giverPIN : personification?.pin,
|
|
3000
3026
|
{
|
|
3001
|
-
PATHNAME: window.location.pathname,
|
|
3002
|
-
ROUTE:
|
|
3027
|
+
PATHNAME: window.location.pathname?.toUpperCase(),
|
|
3028
|
+
ROUTE:
|
|
3029
|
+
window.location.pathname
|
|
3030
|
+
?.split('/')
|
|
3031
|
+
?.pop()
|
|
3032
|
+
?.toUpperCase() || '',
|
|
3003
3033
|
...(initialContextVars || {}),
|
|
3004
3034
|
},
|
|
3005
3035
|
initialQuestion,
|
|
@@ -3041,6 +3071,7 @@ const MemoriWidget = ({
|
|
|
3041
3071
|
|
|
3042
3072
|
{showPositionDrawer && (
|
|
3043
3073
|
<PositionDrawer
|
|
3074
|
+
memori={memori}
|
|
3044
3075
|
open={!!showPositionDrawer}
|
|
3045
3076
|
venue={position}
|
|
3046
3077
|
setVenue={setPosition}
|
|
@@ -3,7 +3,7 @@ import { Meta, Story } from '@storybook/react';
|
|
|
3
3
|
import I18nWrapper from '../../I18nWrapper';
|
|
4
4
|
import PositionDrawer, { Props } from './PositionDrawer';
|
|
5
5
|
import { Venue } from '@memori.ai/memori-api-client/dist/types';
|
|
6
|
-
import { venue } from '../../mocks/data';
|
|
6
|
+
import { venue, memori } from '../../mocks/data';
|
|
7
7
|
|
|
8
8
|
const meta: Meta = {
|
|
9
9
|
title: 'Widget/PositionDrawer',
|
|
@@ -27,7 +27,12 @@ const Template: Story<Props> = args => {
|
|
|
27
27
|
|
|
28
28
|
return (
|
|
29
29
|
<I18nWrapper>
|
|
30
|
-
<PositionDrawer
|
|
30
|
+
<PositionDrawer
|
|
31
|
+
{...args}
|
|
32
|
+
memori={memori}
|
|
33
|
+
venue={venue}
|
|
34
|
+
setVenue={setVenue}
|
|
35
|
+
/>
|
|
31
36
|
</I18nWrapper>
|
|
32
37
|
);
|
|
33
38
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { render } from '@testing-library/react';
|
|
3
3
|
import PositionDrawer from './PositionDrawer';
|
|
4
|
-
import { venue } from '../../mocks/data';
|
|
4
|
+
import { venue, memori } from '../../mocks/data';
|
|
5
5
|
|
|
6
6
|
beforeEach(() => {
|
|
7
7
|
// @ts-ignore
|
|
@@ -15,7 +15,12 @@ beforeEach(() => {
|
|
|
15
15
|
|
|
16
16
|
it('renders PositionDrawer unchanged', () => {
|
|
17
17
|
const { container } = render(
|
|
18
|
-
<PositionDrawer
|
|
18
|
+
<PositionDrawer
|
|
19
|
+
memori={memori}
|
|
20
|
+
open={true}
|
|
21
|
+
onClose={jest.fn()}
|
|
22
|
+
setVenue={jest.fn()}
|
|
23
|
+
/>
|
|
19
24
|
);
|
|
20
25
|
expect(container).toMatchSnapshot();
|
|
21
26
|
});
|
|
@@ -23,7 +28,8 @@ it('renders PositionDrawer unchanged', () => {
|
|
|
23
28
|
it('renders VenueWidget with venue set', () => {
|
|
24
29
|
const { container } = render(
|
|
25
30
|
<PositionDrawer
|
|
26
|
-
|
|
31
|
+
memori={memori}
|
|
32
|
+
open={true}
|
|
27
33
|
onClose={jest.fn()}
|
|
28
34
|
venue={venue}
|
|
29
35
|
setVenue={jest.fn()}
|
|
@@ -1,26 +1,38 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Venue } from '@memori.ai/memori-api-client/dist/types';
|
|
2
|
+
import { Memori, Venue } from '@memori.ai/memori-api-client/dist/types';
|
|
3
3
|
import Drawer from '../ui/Drawer';
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
5
|
import VenueWidget from '../VenueWidget/VenueWidget';
|
|
6
6
|
|
|
7
7
|
export interface Props {
|
|
8
|
+
memori: Memori;
|
|
8
9
|
open: boolean;
|
|
9
10
|
onClose: (venue?: Venue) => void;
|
|
10
11
|
venue?: Venue;
|
|
11
|
-
setVenue: (venue
|
|
12
|
+
setVenue: (venue: Venue) => void;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
const PositionDrawer = ({ open, onClose, venue, setVenue }: Props) => {
|
|
15
|
+
const PositionDrawer = ({ memori, open, onClose, venue, setVenue }: Props) => {
|
|
15
16
|
const { t } = useTranslation();
|
|
17
|
+
|
|
16
18
|
return (
|
|
17
19
|
<Drawer
|
|
18
20
|
className="memori-position-drawer"
|
|
19
21
|
open={open}
|
|
20
22
|
onClose={() => onClose(venue)}
|
|
21
23
|
title={t('widget.position') || 'Position'}
|
|
24
|
+
animated={false}
|
|
22
25
|
>
|
|
23
|
-
<
|
|
26
|
+
<p>{t('write_and_speak.requirePositionHelp', { name: memori.name })}</p>
|
|
27
|
+
<VenueWidget
|
|
28
|
+
venue={venue}
|
|
29
|
+
setVenue={setVenue}
|
|
30
|
+
showUncertainty={false}
|
|
31
|
+
saveAndClose={venue => {
|
|
32
|
+
setVenue(venue);
|
|
33
|
+
onClose(venue);
|
|
34
|
+
}}
|
|
35
|
+
/>
|
|
24
36
|
</Drawer>
|
|
25
37
|
);
|
|
26
38
|
};
|
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`renders PositionDrawer unchanged 1`] =
|
|
3
|
+
exports[`renders PositionDrawer unchanged 1`] = `
|
|
4
|
+
<div>
|
|
5
|
+
<div
|
|
6
|
+
style="position: fixed; top: 1px; left: 1px; width: 1px; height: 0px; padding: 0px; margin: -1px; overflow: hidden; clip: rect(0px, 0px, 0px, 0px); white-space: nowrap; border-width: 0px; display: none;"
|
|
7
|
+
/>
|
|
8
|
+
</div>
|
|
9
|
+
`;
|
|
4
10
|
|
|
5
|
-
exports[`renders VenueWidget with venue set 1`] =
|
|
11
|
+
exports[`renders VenueWidget with venue set 1`] = `
|
|
12
|
+
<div>
|
|
13
|
+
<div
|
|
14
|
+
style="position: fixed; top: 1px; left: 1px; width: 1px; height: 0px; padding: 0px; margin: -1px; overflow: hidden; clip: rect(0px, 0px, 0px, 0px); white-space: nowrap; border-width: 0px; display: none;"
|
|
15
|
+
/>
|
|
16
|
+
</div>
|
|
17
|
+
`;
|
|
@@ -18,6 +18,7 @@ import AI from '../icons/AI';
|
|
|
18
18
|
import Group from '../icons/Group';
|
|
19
19
|
import DeepThought from '../icons/DeepThought';
|
|
20
20
|
import CompletionProviderStatus from '../CompletionProviderStatus/CompletionProviderStatus';
|
|
21
|
+
import MapMarker from '../icons/MapMarker';
|
|
21
22
|
|
|
22
23
|
export interface Props {
|
|
23
24
|
memori: Memori;
|
|
@@ -192,11 +193,14 @@ const StartPanel: React.FC<Props> = ({
|
|
|
192
193
|
<h2 className="memori--title">{memori.name}</h2>
|
|
193
194
|
{memori.needsPosition && !position && (
|
|
194
195
|
<div className="memori--needsPosition">
|
|
195
|
-
<p>
|
|
196
|
+
<p>
|
|
197
|
+
{t('write_and_speak.requirePositionHelp', { name: memori.name })}
|
|
198
|
+
</p>
|
|
196
199
|
<Button
|
|
197
200
|
primary
|
|
198
201
|
onClick={() => openPositionDrawer()}
|
|
199
202
|
className="memori--start-button"
|
|
203
|
+
icon={<MapMarker />}
|
|
200
204
|
>
|
|
201
205
|
{t('widget.position')}
|
|
202
206
|
</Button>
|
|
@@ -1448,11 +1448,27 @@ exports[`renders StartPanel with position required unchanged 1`] = `
|
|
|
1448
1448
|
class="memori--needsPosition"
|
|
1449
1449
|
>
|
|
1450
1450
|
<p>
|
|
1451
|
-
write_and_speak.
|
|
1451
|
+
write_and_speak.requirePositionHelp
|
|
1452
1452
|
</p>
|
|
1453
1453
|
<button
|
|
1454
|
-
class="memori-button memori-button--primary memori-button--rounded memori-button--padded memori--start-button"
|
|
1454
|
+
class="memori-button memori-button--primary memori-button--rounded memori-button--padded memori-button--with-icon memori--start-button"
|
|
1455
1455
|
>
|
|
1456
|
+
<span
|
|
1457
|
+
class="memori-button--icon"
|
|
1458
|
+
>
|
|
1459
|
+
<svg
|
|
1460
|
+
aria-hidden="true"
|
|
1461
|
+
focusable="false"
|
|
1462
|
+
role="img"
|
|
1463
|
+
viewBox="0 0 384 512"
|
|
1464
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
1465
|
+
>
|
|
1466
|
+
<path
|
|
1467
|
+
d="M172.268 501.67C26.97 291.031 0 269.413 0 192 0 85.961 85.961 0 192 0s192 85.961 192 192c0 77.413-26.97 99.031-172.268 309.67-9.535 13.774-29.93 13.773-39.464 0zM192 272c44.183 0 80-35.817 80-80s-35.817-80-80-80-80 35.817-80 80 35.817 80 80 80z"
|
|
1468
|
+
fill="currentColor"
|
|
1469
|
+
/>
|
|
1470
|
+
</svg>
|
|
1471
|
+
</span>
|
|
1456
1472
|
widget.position
|
|
1457
1473
|
</button>
|
|
1458
1474
|
</div>
|
|
@@ -6,7 +6,6 @@ import { MapContainer, TileLayer, Marker, Popup, useMap } from 'react-leaflet';
|
|
|
6
6
|
import { useLeafletContext } from '@react-leaflet/core';
|
|
7
7
|
import L from 'leaflet';
|
|
8
8
|
import toast from 'react-hot-toast';
|
|
9
|
-
import Select from '../ui/Select';
|
|
10
9
|
import Button from '../ui/Button';
|
|
11
10
|
import { useDebounceFn } from '../../helpers/utils';
|
|
12
11
|
import { Combobox, Transition } from '@headlessui/react';
|
|
@@ -40,9 +39,10 @@ export type NominatimItem = {
|
|
|
40
39
|
|
|
41
40
|
export interface Props {
|
|
42
41
|
venue?: Venue;
|
|
43
|
-
setVenue: (venue
|
|
42
|
+
setVenue: (venue: Venue) => void;
|
|
44
43
|
showUncertainty?: boolean;
|
|
45
44
|
showGpsButton?: boolean;
|
|
45
|
+
saveAndClose?: (venue: Venue) => void;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
const Circle = ({
|
|
@@ -122,7 +122,10 @@ const getPlaceName = (venue?: NominatimItem) => {
|
|
|
122
122
|
venue.address.state,
|
|
123
123
|
venue.address.country,
|
|
124
124
|
]
|
|
125
|
+
// remove undefined values
|
|
125
126
|
.filter(Boolean)
|
|
127
|
+
// remove duplicates
|
|
128
|
+
.filter((v, i, a) => a.indexOf(v) === i)
|
|
126
129
|
.join(', ');
|
|
127
130
|
} else if (venue?.display_name) {
|
|
128
131
|
placeName = venue.display_name;
|
|
@@ -136,6 +139,7 @@ const VenueWidget = ({
|
|
|
136
139
|
setVenue,
|
|
137
140
|
showUncertainty = false,
|
|
138
141
|
showGpsButton = true,
|
|
142
|
+
saveAndClose,
|
|
139
143
|
}: Props) => {
|
|
140
144
|
const { t } = useTranslation();
|
|
141
145
|
const [isClient, setIsClient] = useState(false);
|
|
@@ -150,6 +154,13 @@ const VenueWidget = ({
|
|
|
150
154
|
|
|
151
155
|
navigator.geolocation.getCurrentPosition(
|
|
152
156
|
async coords => {
|
|
157
|
+
let venue: Venue = {
|
|
158
|
+
latitude: coords.coords.latitude,
|
|
159
|
+
longitude: coords.coords.longitude,
|
|
160
|
+
placeName: 'Position',
|
|
161
|
+
uncertainty: coords.coords.accuracy / 1000,
|
|
162
|
+
};
|
|
163
|
+
|
|
153
164
|
try {
|
|
154
165
|
const result = await fetch(
|
|
155
166
|
`https://nominatim.openstreetmap.org/reverse?lat=${coords.coords.latitude}&lon=${coords.coords.longitude}&format=jsonv2&addressdetails=1`
|
|
@@ -157,24 +168,21 @@ const VenueWidget = ({
|
|
|
157
168
|
const response = (await result.json()) as NominatimItem;
|
|
158
169
|
|
|
159
170
|
const placeName = getPlaceName(response);
|
|
160
|
-
|
|
161
|
-
setVenue({
|
|
171
|
+
venue = {
|
|
162
172
|
latitude: coords.coords.latitude,
|
|
163
173
|
longitude: coords.coords.longitude,
|
|
164
174
|
placeName: placeName,
|
|
165
175
|
uncertainty: coords.coords.accuracy / 1000,
|
|
166
|
-
}
|
|
176
|
+
};
|
|
177
|
+
setVenue(venue);
|
|
167
178
|
} catch (e) {
|
|
168
179
|
let err = e as Error;
|
|
169
180
|
console.error('[POSITION ERROR]', err);
|
|
170
181
|
if (err?.message) toast.error(err.message);
|
|
171
182
|
|
|
172
|
-
setVenue(
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
placeName: 'Position',
|
|
176
|
-
uncertainty: coords.coords.accuracy / 1000,
|
|
177
|
-
});
|
|
183
|
+
setVenue(venue);
|
|
184
|
+
} finally {
|
|
185
|
+
if (saveAndClose) saveAndClose(venue);
|
|
178
186
|
}
|
|
179
187
|
|
|
180
188
|
setUpdatingPosition(false);
|
|
@@ -253,7 +261,7 @@ const VenueWidget = ({
|
|
|
253
261
|
<div className="memori--venue-widget-search">
|
|
254
262
|
<Combobox
|
|
255
263
|
value={
|
|
256
|
-
(venue
|
|
264
|
+
(venue?.latitude && venue?.longitude
|
|
257
265
|
? {
|
|
258
266
|
place_id: 0,
|
|
259
267
|
lat: venue?.latitude,
|
|
@@ -266,7 +274,9 @@ const VenueWidget = ({
|
|
|
266
274
|
>
|
|
267
275
|
<Combobox.Input
|
|
268
276
|
className="memori--venue-widget-search--input"
|
|
269
|
-
displayValue={(i: NominatimItem) =>
|
|
277
|
+
displayValue={(i: NominatimItem) =>
|
|
278
|
+
i ? getPlaceName(i) : ''
|
|
279
|
+
}
|
|
270
280
|
placeholder={t('searchVenue')}
|
|
271
281
|
onChange={e => onQueryChange(e.target.value)}
|
|
272
282
|
/>
|
|
@@ -320,10 +330,11 @@ const VenueWidget = ({
|
|
|
320
330
|
)}
|
|
321
331
|
</Combobox>
|
|
322
332
|
</div>
|
|
333
|
+
|
|
323
334
|
{showGpsButton && (
|
|
324
335
|
<Button
|
|
325
336
|
className="memori--venue-widget__gps-button"
|
|
326
|
-
|
|
337
|
+
primary
|
|
327
338
|
loading={updatingPosition}
|
|
328
339
|
onClick={() => {
|
|
329
340
|
setUpdatingPosition(true);
|
|
@@ -336,6 +347,24 @@ const VenueWidget = ({
|
|
|
336
347
|
</>
|
|
337
348
|
)}
|
|
338
349
|
</div>
|
|
350
|
+
<div>
|
|
351
|
+
<Button
|
|
352
|
+
outlined
|
|
353
|
+
className="memori--venue-widget__no-location-button"
|
|
354
|
+
onClick={() => {
|
|
355
|
+
let venue: Venue = {
|
|
356
|
+
latitude: 0,
|
|
357
|
+
longitude: 0,
|
|
358
|
+
placeName: 'Position',
|
|
359
|
+
uncertainty: 0,
|
|
360
|
+
};
|
|
361
|
+
setVenue(venue);
|
|
362
|
+
if (saveAndClose) saveAndClose(venue);
|
|
363
|
+
}}
|
|
364
|
+
>
|
|
365
|
+
{t('write_and_speak.dontWantToProvidePosition')}
|
|
366
|
+
</Button>
|
|
367
|
+
</div>
|
|
339
368
|
{showUncertainty && (
|
|
340
369
|
<label className="memori--venue-widget__select-label">
|
|
341
370
|
<span>{t('uncertain')}: </span>
|
|
@@ -374,7 +403,7 @@ const VenueWidget = ({
|
|
|
374
403
|
)}
|
|
375
404
|
</div>
|
|
376
405
|
<div className="memori--venue-widget__form-item">
|
|
377
|
-
{venue?.placeName && (
|
|
406
|
+
{venue?.placeName && venue.placeName !== 'Position' && (
|
|
378
407
|
<p className="memori--venue--widget__place-name">
|
|
379
408
|
<strong>{t('venue')}</strong>: {venue.placeName}
|
|
380
409
|
</p>
|
|
@@ -30,11 +30,18 @@ exports[`renders VenueWidget with venue set, exact location 1`] = `
|
|
|
30
30
|
/>
|
|
31
31
|
</div>
|
|
32
32
|
<button
|
|
33
|
-
class="memori-button memori-button--
|
|
33
|
+
class="memori-button memori-button--primary memori-button--rounded memori-button--padded memori--venue-widget__gps-button"
|
|
34
34
|
>
|
|
35
35
|
write_and_speak.useMyPosition
|
|
36
36
|
</button>
|
|
37
37
|
</div>
|
|
38
|
+
<div>
|
|
39
|
+
<button
|
|
40
|
+
class="memori-button memori-button--outlined memori-button--rounded memori-button--padded memori--venue-widget__no-location-button"
|
|
41
|
+
>
|
|
42
|
+
write_and_speak.dontWantToProvidePosition
|
|
43
|
+
</button>
|
|
44
|
+
</div>
|
|
38
45
|
</div>
|
|
39
46
|
<div
|
|
40
47
|
class="memori--venue-widget__form-item"
|
|
@@ -101,11 +108,18 @@ exports[`renders VenueWidget with venue set, with uncertainty radius 1`] = `
|
|
|
101
108
|
/>
|
|
102
109
|
</div>
|
|
103
110
|
<button
|
|
104
|
-
class="memori-button memori-button--
|
|
111
|
+
class="memori-button memori-button--primary memori-button--rounded memori-button--padded memori--venue-widget__gps-button"
|
|
105
112
|
>
|
|
106
113
|
write_and_speak.useMyPosition
|
|
107
114
|
</button>
|
|
108
115
|
</div>
|
|
116
|
+
<div>
|
|
117
|
+
<button
|
|
118
|
+
class="memori-button memori-button--outlined memori-button--rounded memori-button--padded memori--venue-widget__no-location-button"
|
|
119
|
+
>
|
|
120
|
+
write_and_speak.dontWantToProvidePosition
|
|
121
|
+
</button>
|
|
122
|
+
</div>
|
|
109
123
|
</div>
|
|
110
124
|
<div
|
|
111
125
|
class="memori--venue-widget__form-item"
|
|
@@ -172,6 +186,13 @@ exports[`renders VenueWidget without gps button unchanged 1`] = `
|
|
|
172
186
|
/>
|
|
173
187
|
</div>
|
|
174
188
|
</div>
|
|
189
|
+
<div>
|
|
190
|
+
<button
|
|
191
|
+
class="memori-button memori-button--outlined memori-button--rounded memori-button--padded memori--venue-widget__no-location-button"
|
|
192
|
+
>
|
|
193
|
+
write_and_speak.dontWantToProvidePosition
|
|
194
|
+
</button>
|
|
195
|
+
</div>
|
|
175
196
|
</div>
|
|
176
197
|
<div
|
|
177
198
|
class="memori--venue-widget__form-item"
|
|
@@ -238,11 +259,18 @@ exports[`renders VenueWidget without uncertainty unchanged 1`] = `
|
|
|
238
259
|
/>
|
|
239
260
|
</div>
|
|
240
261
|
<button
|
|
241
|
-
class="memori-button memori-button--
|
|
262
|
+
class="memori-button memori-button--primary memori-button--rounded memori-button--padded memori--venue-widget__gps-button"
|
|
242
263
|
>
|
|
243
264
|
write_and_speak.useMyPosition
|
|
244
265
|
</button>
|
|
245
266
|
</div>
|
|
267
|
+
<div>
|
|
268
|
+
<button
|
|
269
|
+
class="memori-button memori-button--outlined memori-button--rounded memori-button--padded memori--venue-widget__no-location-button"
|
|
270
|
+
>
|
|
271
|
+
write_and_speak.dontWantToProvidePosition
|
|
272
|
+
</button>
|
|
273
|
+
</div>
|
|
246
274
|
</div>
|
|
247
275
|
<div
|
|
248
276
|
class="memori--venue-widget__form-item"
|
|
@@ -309,11 +337,18 @@ exports[`renders empty VenueWidget unchanged 1`] = `
|
|
|
309
337
|
/>
|
|
310
338
|
</div>
|
|
311
339
|
<button
|
|
312
|
-
class="memori-button memori-button--
|
|
340
|
+
class="memori-button memori-button--primary memori-button--rounded memori-button--padded memori--venue-widget__gps-button"
|
|
313
341
|
>
|
|
314
342
|
write_and_speak.useMyPosition
|
|
315
343
|
</button>
|
|
316
344
|
</div>
|
|
345
|
+
<div>
|
|
346
|
+
<button
|
|
347
|
+
class="memori-button memori-button--outlined memori-button--rounded memori-button--padded memori--venue-widget__no-location-button"
|
|
348
|
+
>
|
|
349
|
+
write_and_speak.dontWantToProvidePosition
|
|
350
|
+
</button>
|
|
351
|
+
</div>
|
|
317
352
|
</div>
|
|
318
353
|
<div
|
|
319
354
|
class="memori--venue-widget__form-item"
|
|
@@ -14,6 +14,7 @@ export interface Props {
|
|
|
14
14
|
children: JSX.Element | React.ReactNode;
|
|
15
15
|
footer?: JSX.Element | React.ReactNode;
|
|
16
16
|
loading?: boolean;
|
|
17
|
+
animated?: boolean;
|
|
17
18
|
closable?: boolean;
|
|
18
19
|
side?: 'left' | 'right';
|
|
19
20
|
width?: string;
|
|
@@ -30,6 +31,7 @@ const Drawer: FC<Props> = ({
|
|
|
30
31
|
children,
|
|
31
32
|
footer,
|
|
32
33
|
loading = false,
|
|
34
|
+
animated = true,
|
|
33
35
|
side = 'right',
|
|
34
36
|
closable = true,
|
|
35
37
|
width = '100%',
|
|
@@ -56,13 +58,14 @@ const Drawer: FC<Props> = ({
|
|
|
56
58
|
<div className="memori-drawer--container">
|
|
57
59
|
<div className="memori-drawer--container-scrollable">
|
|
58
60
|
<Transition.Child
|
|
61
|
+
static
|
|
59
62
|
as={React.Fragment}
|
|
60
63
|
enter="ease-out duration-300"
|
|
61
|
-
enterFrom=
|
|
64
|
+
enterFrom={animated ? 'max-w-0 opacity-0' : 'opacity-0'}
|
|
62
65
|
enterTo="max-w-80 opacity-100"
|
|
63
66
|
leave="ease-in duration-200"
|
|
64
67
|
leaveFrom="max-w-80 opacity-100"
|
|
65
|
-
leaveTo=
|
|
68
|
+
leaveTo={animated ? 'max-w-0 opacity-0' : 'opacity-0'}
|
|
66
69
|
>
|
|
67
70
|
<Dialog.Panel
|
|
68
71
|
className={cx('memori-drawer--panel', {
|
|
@@ -7,6 +7,7 @@ export const keys: { [key: string]: string } = {
|
|
|
7
7
|
controlsPosition: '@memori:controlsPosition',
|
|
8
8
|
hideEmissions: '@memori:hideEmissions',
|
|
9
9
|
loginToken: '@memori:loginToken',
|
|
10
|
+
location: '@memori:location',
|
|
10
11
|
};
|
|
11
12
|
|
|
12
13
|
export const getLocalConfig = <Type>(key: string, defaultValue: Type): Type => {
|
package/src/locales/en.json
CHANGED
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"instruct": "Instruct",
|
|
87
87
|
"test": "Test",
|
|
88
88
|
"sound": "Sound",
|
|
89
|
-
"position": "Position",
|
|
89
|
+
"position": "Position preferences",
|
|
90
90
|
"settings": "Settings",
|
|
91
91
|
"share": "Share",
|
|
92
92
|
"sendOnKeypress": "Hit Enter to send",
|
|
@@ -126,6 +126,8 @@
|
|
|
126
126
|
"updatingPosition": "Updating position...",
|
|
127
127
|
"placeNotFound": "Place not found!",
|
|
128
128
|
"requirePosition": "Insert your position before start",
|
|
129
|
+
"requirePositionHelp": "To talk to {{name}} you have to decide whether to provide your position or not. This is because different answers that it can provide you may depend on where you are.",
|
|
130
|
+
"dontWantToProvidePosition": "I don't want to provide my position",
|
|
129
131
|
"attachmentsLabel": "Enrich your message",
|
|
130
132
|
"iWantToTalkToIn": "I want to talk to {{name}} in"
|
|
131
133
|
},
|
package/src/locales/it.json
CHANGED
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"instruct": "Istruisci",
|
|
87
87
|
"test": "Prova",
|
|
88
88
|
"sound": "Audio",
|
|
89
|
-
"position": "
|
|
89
|
+
"position": "Preferenze posizione",
|
|
90
90
|
"settings": "Impostazioni",
|
|
91
91
|
"share": "Condividi",
|
|
92
92
|
"sendOnKeypress": "Premi Invio per inviare",
|
|
@@ -125,7 +125,8 @@
|
|
|
125
125
|
"myPosition": "Posizione corrente",
|
|
126
126
|
"updatingPosition": "Aggiorno la posizione...",
|
|
127
127
|
"placeNotFound": "Luogo sconosciuto!",
|
|
128
|
-
"
|
|
128
|
+
"requirePositionHelp": "Per parlare con {{name}} devi decidere se fornire o meno la tua posizione. Questo perchè diverse risposte che potrà fornirti potrebbero dipendere da dove ti trovi.",
|
|
129
|
+
"dontWantToProvidePosition": "Non voglio fornire la mia posizione",
|
|
129
130
|
"attachmentsLabel": "Arricchisci il tuo messaggio",
|
|
130
131
|
"iWantToTalkToIn": "Voglio parlare con {{name}} in"
|
|
131
132
|
},
|