@memori.ai/memori-react 5.1.0 → 6.0.0-rc.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 +8 -0
- package/README.md +1 -0
- package/dist/components/AttachmentMediaModal/AttachmentMediaModal.d.ts +14 -0
- package/dist/components/AttachmentMediaModal/AttachmentMediaModal.js +66 -0
- package/dist/components/AttachmentMediaModal/AttachmentMediaModal.js.map +1 -0
- package/dist/components/Header/Header.css +2 -1
- package/dist/components/Header/Header.d.ts +2 -0
- package/dist/components/Header/Header.js +3 -2
- package/dist/components/Header/Header.js.map +1 -1
- package/dist/components/ImageUpload/ImageUpload.css +168 -0
- package/dist/components/ImageUpload/ImageUpload.d.ts +28 -0
- package/dist/components/ImageUpload/ImageUpload.js +163 -0
- package/dist/components/ImageUpload/ImageUpload.js.map +1 -0
- package/dist/components/LoginDrawer/LoginDrawer.css +84 -0
- package/dist/components/LoginDrawer/LoginDrawer.d.ts +15 -0
- package/dist/components/LoginDrawer/LoginDrawer.js +129 -0
- package/dist/components/LoginDrawer/LoginDrawer.js.map +1 -0
- package/dist/components/MemoriWidget/MemoriWidget.d.ts +2 -1
- package/dist/components/MemoriWidget/MemoriWidget.js +33 -5
- package/dist/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/dist/components/StartPanel/StartPanel.d.ts +2 -0
- package/dist/components/StartPanel/StartPanel.js +2 -2
- package/dist/components/StartPanel/StartPanel.js.map +1 -1
- package/dist/components/layouts/Default.d.ts +17 -0
- package/dist/components/layouts/Default.js +8 -0
- package/dist/components/layouts/Default.js.map +1 -0
- package/dist/components/ui/Message.d.ts +17 -0
- package/dist/components/ui/Message.js +13 -0
- package/dist/components/ui/Message.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/locales/en.json +25 -0
- package/dist/locales/it.json +25 -0
- package/dist/styles.css +1 -0
- package/esm/components/AttachmentMediaModal/AttachmentMediaModal.d.ts +14 -0
- package/esm/components/AttachmentMediaModal/AttachmentMediaModal.js +63 -0
- package/esm/components/AttachmentMediaModal/AttachmentMediaModal.js.map +1 -0
- package/esm/components/Header/Header.css +2 -1
- package/esm/components/Header/Header.d.ts +2 -0
- package/esm/components/Header/Header.js +3 -2
- package/esm/components/Header/Header.js.map +1 -1
- package/esm/components/ImageUpload/ImageUpload.css +168 -0
- package/esm/components/ImageUpload/ImageUpload.d.ts +28 -0
- package/esm/components/ImageUpload/ImageUpload.js +160 -0
- package/esm/components/ImageUpload/ImageUpload.js.map +1 -0
- package/esm/components/LoginDrawer/LoginDrawer.css +84 -0
- package/esm/components/LoginDrawer/LoginDrawer.d.ts +15 -0
- package/esm/components/LoginDrawer/LoginDrawer.js +125 -0
- package/esm/components/LoginDrawer/LoginDrawer.js.map +1 -0
- package/esm/components/MemoriWidget/MemoriWidget.d.ts +2 -1
- package/esm/components/MemoriWidget/MemoriWidget.js +33 -5
- package/esm/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/esm/components/StartPanel/StartPanel.d.ts +2 -0
- package/esm/components/StartPanel/StartPanel.js +2 -2
- package/esm/components/StartPanel/StartPanel.js.map +1 -1
- package/esm/components/layouts/Default.d.ts +17 -0
- package/esm/components/layouts/Default.js +5 -0
- package/esm/components/layouts/Default.js.map +1 -0
- package/esm/components/ui/Message.d.ts +17 -0
- package/esm/components/ui/Message.js +10 -0
- package/esm/components/ui/Message.js.map +1 -0
- package/esm/index.d.ts +1 -0
- package/esm/index.js +3 -2
- package/esm/index.js.map +1 -1
- package/esm/locales/en.json +25 -0
- package/esm/locales/it.json +25 -0
- package/esm/styles.css +1 -0
- package/package.json +1 -1
- package/src/components/Header/Header.css +2 -1
- package/src/components/Header/Header.stories.tsx +27 -1
- package/src/components/Header/Header.test.tsx +14 -1
- package/src/components/Header/Header.tsx +17 -0
- package/src/components/Header/__snapshots__/Header.test.tsx.snap +260 -0
- package/src/components/LoginDrawer/LoginDrawer.css +84 -0
- package/src/components/LoginDrawer/LoginDrawer.stories.tsx +58 -0
- package/src/components/LoginDrawer/LoginDrawer.test.tsx +86 -0
- package/src/components/LoginDrawer/LoginDrawer.tsx +330 -0
- package/src/components/LoginDrawer/__snapshots__/LoginDrawer.test.tsx.snap +35 -0
- package/src/components/MemoriWidget/MemoriWidget.tsx +48 -4
- package/src/components/StartPanel/StartPanel.stories.tsx +3 -1
- package/src/components/StartPanel/StartPanel.test.tsx +12 -0
- package/src/components/StartPanel/StartPanel.tsx +11 -0
- package/src/components/StartPanel/__snapshots__/StartPanel.test.tsx.snap +7 -0
- package/src/components/layouts/__snapshots__/Chat.test.tsx.snap +20 -0
- package/src/components/layouts/__snapshots__/FullPage.test.tsx.snap +20 -0
- package/src/components/layouts/__snapshots__/Totem.test.tsx.snap +20 -0
- package/src/index.stories.tsx +0 -1
- package/src/index.tsx +4 -0
- package/src/locales/en.json +25 -0
- package/src/locales/it.json +25 -0
- package/src/mocks/data.ts +2 -2
- package/src/styles.css +1 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
.memori--login-drawer {
|
|
2
|
+
z-index: 1000;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.memori--login-drawer .memori-drawer--panel {
|
|
6
|
+
--memori-drawer--width: 100%;
|
|
7
|
+
--memori-drawer--width--md: 60%;
|
|
8
|
+
--memori-drawer--width--lg: 40%;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.memori--login-drawer.memori--login-drawer--logged .memori-drawer--panel {
|
|
12
|
+
--memori-drawer--width: 100%;
|
|
13
|
+
--memori-drawer--width--md: 40%;
|
|
14
|
+
--memori-drawer--width--lg: 30%;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
h2.memori--login-drawer--title {
|
|
18
|
+
margin: 0;
|
|
19
|
+
font-size: inherit;
|
|
20
|
+
font-weight: 400;
|
|
21
|
+
line-height: inherit;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
form.memori--login-drawer--form {
|
|
25
|
+
display: flex;
|
|
26
|
+
flex-direction: column;
|
|
27
|
+
padding: 1rem 0.5rem;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
p.memori--login-drawer--error {
|
|
31
|
+
margin: 0.5rem 0;
|
|
32
|
+
color: var(--memori-error-color);
|
|
33
|
+
text-align: center;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.memori--login-drawer--form label:not(.memori-checkbox) {
|
|
37
|
+
display: block;
|
|
38
|
+
width: 100%;
|
|
39
|
+
margin: 0.5rem 0;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.memori--login-drawer--form label.memori-checkbox {
|
|
43
|
+
width: 100%;
|
|
44
|
+
margin: 0.5rem 0;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.memori--login-drawer--form input {
|
|
48
|
+
width: 100%;
|
|
49
|
+
padding: 10px;
|
|
50
|
+
border: 1px solid var(--memori-button-border-color, #ccc);
|
|
51
|
+
border-radius: 5px;
|
|
52
|
+
margin: 0.5rem 0;
|
|
53
|
+
font-size: 16px;
|
|
54
|
+
line-height: 1.5;
|
|
55
|
+
transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.memori--login-drawer--form button:focus,
|
|
59
|
+
.memori--login-drawer--form input:focus,
|
|
60
|
+
.memori--login-drawer--form input[type="checkbox"]:focus+.memori-checkbox--inner {
|
|
61
|
+
border-color: var(--memori-primary);
|
|
62
|
+
box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
|
|
63
|
+
outline: none;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.memori--login-drawer--form a {
|
|
67
|
+
color: var(--memori-primary);
|
|
68
|
+
text-decoration: underline;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.memori--login-drawer--form a:hover,
|
|
72
|
+
.memori--login-drawer--form a:focus,
|
|
73
|
+
.memori--login-drawer--form a:active {
|
|
74
|
+
opacity: 0.8;
|
|
75
|
+
outline-color: var(--memori-primary);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.memori--login-drawer--form button[type="submit"] {
|
|
79
|
+
margin-top: 1rem;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
p.memori--login-drawer--signup {
|
|
83
|
+
margin-top: 1.25rem;
|
|
84
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { User, Tenant } from '@memori.ai/memori-api-client/dist/types';
|
|
2
|
+
export declare const mailRegEx: RegExp;
|
|
3
|
+
export interface Props {
|
|
4
|
+
open?: boolean;
|
|
5
|
+
onClose: () => void;
|
|
6
|
+
user?: User;
|
|
7
|
+
loginToken?: string;
|
|
8
|
+
onLogin: (user: User, token: string) => void;
|
|
9
|
+
onLogout: () => void;
|
|
10
|
+
tenant: Tenant;
|
|
11
|
+
apiUrl: string;
|
|
12
|
+
__TEST__needMissingData?: boolean;
|
|
13
|
+
}
|
|
14
|
+
declare const LoginDrawer: ({ open, onClose, onLogin, onLogout, user, loginToken, tenant, apiUrl, __TEST__needMissingData, }: Props) => JSX.Element;
|
|
15
|
+
export default LoginDrawer;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
|
+
import Button from '../ui/Button';
|
|
4
|
+
import Drawer from '../ui/Drawer';
|
|
5
|
+
import toast from 'react-hot-toast';
|
|
6
|
+
import { useTranslation } from 'react-i18next';
|
|
7
|
+
import cx from 'classnames';
|
|
8
|
+
import memoriApiClient from '@memori.ai/memori-api-client';
|
|
9
|
+
import { getErrori18nKey } from '../../helpers/error';
|
|
10
|
+
export const mailRegEx = /^\w+([.-]?[+]?\w+)*@\w+([.-]?\w+)*(\.\w{2,})+$/;
|
|
11
|
+
const LoginDrawer = ({ open = false, onClose, onLogin, onLogout, user, loginToken, tenant, apiUrl, __TEST__needMissingData = false, }) => {
|
|
12
|
+
var _a;
|
|
13
|
+
const { t, i18n } = useTranslation();
|
|
14
|
+
const lang = i18n.language === 'it' ? 'it' : 'en';
|
|
15
|
+
const client = memoriApiClient(apiUrl);
|
|
16
|
+
const { userLogin, updateUser } = client.backend;
|
|
17
|
+
const [loading, setLoading] = useState(false);
|
|
18
|
+
const [needsMissingData, setNeedsMissingData] = useState(__TEST__needMissingData
|
|
19
|
+
? {
|
|
20
|
+
token: 'token',
|
|
21
|
+
birthDate: true,
|
|
22
|
+
tnCAndPPAccepted: true,
|
|
23
|
+
}
|
|
24
|
+
: {});
|
|
25
|
+
const [error, setError] = useState(null);
|
|
26
|
+
const [redirectTo, setRedirectTo] = useState(null);
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
setRedirectTo(window.location.href);
|
|
29
|
+
}, []);
|
|
30
|
+
const isUserLoggedIn = user && loginToken;
|
|
31
|
+
const login = (e) => {
|
|
32
|
+
e.preventDefault();
|
|
33
|
+
const form = e.currentTarget;
|
|
34
|
+
const userNameOrEmail = form.userNameOrEmail.value;
|
|
35
|
+
const password = form.password.value;
|
|
36
|
+
const isEmail = mailRegEx.test(userNameOrEmail);
|
|
37
|
+
const user = isEmail
|
|
38
|
+
? {
|
|
39
|
+
tenant: tenant === null || tenant === void 0 ? void 0 : tenant.id,
|
|
40
|
+
eMail: userNameOrEmail,
|
|
41
|
+
password: password,
|
|
42
|
+
}
|
|
43
|
+
: {
|
|
44
|
+
tenant: tenant === null || tenant === void 0 ? void 0 : tenant.id,
|
|
45
|
+
userName: userNameOrEmail,
|
|
46
|
+
password: password,
|
|
47
|
+
};
|
|
48
|
+
setLoading(true);
|
|
49
|
+
setError(null);
|
|
50
|
+
userLogin(user)
|
|
51
|
+
.then(data => {
|
|
52
|
+
var _a, _b, _c, _d;
|
|
53
|
+
if (data.resultCode !== 0) {
|
|
54
|
+
console.error(data);
|
|
55
|
+
toast.error(t(getErrori18nKey(data.resultCode), { ns: 'common' }));
|
|
56
|
+
setError(data.resultMessage);
|
|
57
|
+
}
|
|
58
|
+
else if (data.user && data.token) {
|
|
59
|
+
onLogin(data.user, data.token);
|
|
60
|
+
if (!((_a = data.user) === null || _a === void 0 ? void 0 : _a.tnCAndPPAccepted) || !((_b = data.user) === null || _b === void 0 ? void 0 : _b.birthDate)) {
|
|
61
|
+
setNeedsMissingData({
|
|
62
|
+
token: data.token,
|
|
63
|
+
birthDate: !((_c = data.user) === null || _c === void 0 ? void 0 : _c.birthDate),
|
|
64
|
+
tnCAndPPAccepted: !((_d = data.user) === null || _d === void 0 ? void 0 : _d.tnCAndPPAccepted),
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
})
|
|
69
|
+
.catch(err => {
|
|
70
|
+
console.error('[LOGIN]', err);
|
|
71
|
+
toast.error(err);
|
|
72
|
+
if (err.message)
|
|
73
|
+
setError(err.message);
|
|
74
|
+
})
|
|
75
|
+
.finally(() => {
|
|
76
|
+
setLoading(false);
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
const updateMissingData = async (e) => {
|
|
80
|
+
var _a, _b, _c;
|
|
81
|
+
e.preventDefault();
|
|
82
|
+
const form = e.currentTarget;
|
|
83
|
+
const birthDate = (_a = form.birthDate) === null || _a === void 0 ? void 0 : _a.value;
|
|
84
|
+
const tnCAndPPAccepted = (_b = form.tnCAndPPAccepted) === null || _b === void 0 ? void 0 : _b.checked;
|
|
85
|
+
const pAndCUAccepted = (_c = form.pAndCUAccepted) === null || _c === void 0 ? void 0 : _c.checked;
|
|
86
|
+
if (!(user === null || user === void 0 ? void 0 : user.userID) || !(needsMissingData === null || needsMissingData === void 0 ? void 0 : needsMissingData.token)) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (!birthDate || !tnCAndPPAccepted) {
|
|
90
|
+
setError(t('missingData'));
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
let newUser = {
|
|
94
|
+
userID: user.userID,
|
|
95
|
+
birthDate: (user === null || user === void 0 ? void 0 : user.birthDate) || !needsMissingData.birthDate ? undefined : birthDate,
|
|
96
|
+
tnCAndPPAccepted: tnCAndPPAccepted || (user === null || user === void 0 ? void 0 : user.tnCAndPPAccepted),
|
|
97
|
+
tnCAndPPAcceptanceDate: tnCAndPPAccepted
|
|
98
|
+
? new Date().toISOString()
|
|
99
|
+
: undefined,
|
|
100
|
+
pAndCUAccepted: pAndCUAccepted || (user === null || user === void 0 ? void 0 : user.pAndCUAccepted),
|
|
101
|
+
pAndCUAcceptanceDate: pAndCUAccepted
|
|
102
|
+
? new Date().toISOString()
|
|
103
|
+
: undefined,
|
|
104
|
+
};
|
|
105
|
+
const { user: patchedUser, ...resp } = await updateUser(needsMissingData.token, user.userID, newUser);
|
|
106
|
+
if (resp.resultCode !== 0) {
|
|
107
|
+
console.error(resp);
|
|
108
|
+
toast.error(t(getErrori18nKey(resp.resultCode), { ns: 'common' }));
|
|
109
|
+
setError(resp.resultMessage);
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
toast.success(t('success'));
|
|
113
|
+
onLogin(patchedUser || newUser, needsMissingData.token);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
return (_jsx(Drawer, { open: open, onClose: onClose, className: cx('memori--login-drawer', {
|
|
117
|
+
'memori--login-drawer--logged': isUserLoggedIn,
|
|
118
|
+
}), title: _jsx("h2", { className: "memori--login-drawer--title", children: isUserLoggedIn
|
|
119
|
+
? t('login.loggedDrawerTitle', { name: user.userName })
|
|
120
|
+
: t('login.loginDrawerTitle') }), children: isUserLoggedIn ? (_jsx("div", { className: "memori--login-drawer--logged", children: _jsx(Button, { primary: true, onClick: () => {
|
|
121
|
+
onLogout();
|
|
122
|
+
}, children: t('login.logout') }) })) : ((_a = needsMissingData === null || needsMissingData === void 0 ? void 0 : needsMissingData.token) === null || _a === void 0 ? void 0 : _a.length) ? (_jsxs(_Fragment, { children: [_jsx("h3", { children: t('login.missingData') }), _jsx("p", { children: t('login.missingDataHelper') }), _jsxs("form", { className: "memori--login-drawer--form", onSubmit: updateMissingData, children: [needsMissingData.birthDate && (_jsxs(_Fragment, { children: [_jsxs("label", { htmlFor: "#birthDate", children: [t('login.birthDate'), _jsx("input", { id: "birthDate", name: "birthDate", type: "date", required: true, autoComplete: "bday" })] }), _jsx("p", { children: _jsx("small", { children: t('login.birthDateHelper') }) })] })), (needsMissingData === null || needsMissingData === void 0 ? void 0 : needsMissingData.tnCAndPPAccepted) && (_jsxs(_Fragment, { children: [_jsxs("label", { className: "memori-checkbox", children: [_jsxs("span", { className: "memori-checkbox--input-wrapper", children: [_jsx("input", { type: "checkbox", name: "tnCAndPPAccepted", className: "memori-checkbox--input" }), _jsx("span", { className: "memori-checkbox--inner" })] }), _jsxs("span", { className: "memori-checkbox--text", children: [t('login.privacyLabel'), ' ', _jsx("a", { href: `https://memori.ai/${lang}/privacy_and_cookie`, target: "_blank", rel: "noopener noreferrer", children: t('login.privacyAndCookiePolicy') }), ' ', t('login.and'), ' ', _jsx("a", { href: `https://memori.ai/${lang}/tos`, target: "_blank", rel: "noopener noreferrer", children: t('login.termsOfService') })] })] }), _jsxs("label", { className: "memori-checkbox", children: [_jsxs("span", { className: "memori-checkbox--input-wrapper", children: [_jsx("input", { type: "checkbox", name: "pAndCUAccepted", defaultChecked: user === null || user === void 0 ? void 0 : user.pAndCUAccepted, className: "memori-checkbox--input" }), _jsx("span", { className: "memori-checkbox--inner" })] }), _jsxs("span", { className: "memori-checkbox--text", children: [t('login.pAndCUAccepted'), ' ', _jsx("small", { children: _jsxs("em", { children: ["(", t('login.optional'), ")"] }) })] })] }), _jsx("p", { children: _jsx("small", { children: t('login.goToAccountToChangeYourPreferences') }) }), _jsx("p", { children: _jsx("small", { children: t('login.deepThoughtExplaination') }) })] })), _jsx(Button, { htmlType: "submit", primary: true, loading: loading, children: t('login.save') })] })] })) : (_jsxs(_Fragment, { children: [_jsxs("form", { className: "memori--login-drawer--form", onSubmit: login, children: [_jsxs("label", { htmlFor: "#userNameOrEmail", children: [t('login.userNameOrEmail'), _jsx("input", { id: "userNameOrEmail", name: "userNameOrEmail", required: true, autoComplete: "email", placeholder: "Username/email" })] }), _jsxs("label", { htmlFor: "#password", children: ["Password", _jsx("input", { id: "password", name: "password", type: "password", required: true, autoComplete: "password", placeholder: "Password" })] }), _jsx(Button, { htmlType: "submit", primary: true, loading: loading, children: t('login.login') }), !(tenant === null || tenant === void 0 ? void 0 : tenant.disableRegistration) && (_jsxs("p", { className: "memori--login-drawer--signup", children: [t('login.newUserSignUp'), ' ', _jsx("a", { href: `https://${tenant.name || 'www.aisuru.com'}/${lang}/auth?signup=1&redirectTo=${redirectTo}`, children: t('login.signUp') })] }))] }), error && (_jsx("p", { role: "alert", className: "memori--login-drawer--error", children: error }))] })) }));
|
|
123
|
+
};
|
|
124
|
+
export default LoginDrawer;
|
|
125
|
+
//# sourceMappingURL=LoginDrawer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LoginDrawer.js","sourceRoot":"","sources":["../../../src/components/LoginDrawer/LoginDrawer.tsx"],"names":[],"mappings":";AACA,OAAc,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,MAAM,MAAM,cAAc,CAAC;AAClC,OAAO,MAAM,MAAM,cAAc,CAAC;AAClC,OAAO,KAAK,MAAM,iBAAiB,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,eAAe,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,MAAM,CAAC,MAAM,SAAS,GAAG,gDAAgD,CAAC;AAc1E,MAAM,WAAW,GAAG,CAAC,EACnB,IAAI,GAAG,KAAK,EACZ,OAAO,EACP,OAAO,EACP,QAAQ,EACR,IAAI,EACJ,UAAU,EACV,MAAM,EACN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,kBAAkB,aAC9B,CAAC,CAAC,uBAAuB,CAAC,EAC3B,gBACE,EAAE,EAAC,iBAAiB,EACpB,IAAI,EAAC,iBAAiB,EACtB,QAAQ,QACR,YAAY,EAAC,OAAO,EACpB,WAAW,EAAC,gBAAgB,GAC5B,IACI,EAER,iBAAO,OAAO,EAAC,WAAW,yBAExB,gBACE,EAAE,EAAC,UAAU,EACb,IAAI,EAAC,UAAU,EACf,IAAI,EAAC,UAAU,EACf,QAAQ,QACR,YAAY,EAAC,UAAU,EACvB,WAAW,EAAC,UAAU,GACtB,IACI,EAER,KAAC,MAAM,IAAC,QAAQ,EAAC,QAAQ,EAAC,OAAO,QAAC,OAAO,EAAE,OAAO,YAC/C,CAAC,CAAC,aAAa,CAAC,GACV,EAER,CAAC,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,mBAAmB,CAAA,IAAI,CAC/B,aAAG,SAAS,EAAC,8BAA8B,aACxC,CAAC,CAAC,qBAAqB,CAAC,EAAE,GAAG,EAC9B,YACE,IAAI,EAAE,WACJ,MAAM,CAAC,IAAI,IAAI,gBACjB,IAAI,IAAI,6BAA6B,UAAU,EAAE,YAEhD,CAAC,CAAC,cAAc,CAAC,GAChB,IACF,CACL,IACI,EAEN,KAAK,IAAI,CACR,YAAG,IAAI,EAAC,OAAO,EAAC,SAAS,EAAC,6BAA6B,YACpD,KAAK,GACJ,CACL,IACA,CACJ,GACM,CACV,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -77,6 +77,7 @@ export interface Props {
|
|
|
77
77
|
showClear?: boolean;
|
|
78
78
|
showOnlyLastMessages?: boolean;
|
|
79
79
|
showTypingText?: boolean;
|
|
80
|
+
showLogin?: boolean;
|
|
80
81
|
preview?: boolean;
|
|
81
82
|
embed?: boolean;
|
|
82
83
|
height?: number | string;
|
|
@@ -106,5 +107,5 @@ export interface Props {
|
|
|
106
107
|
additionalSettings?: JSX.Element | null;
|
|
107
108
|
userAvatar?: string | JSX.Element;
|
|
108
109
|
}
|
|
109
|
-
declare const MemoriWidget: ({ memori, memoriConfigs, memoriLang, multilingual, integration, layout, customLayout, showInstruct, showShare, preview, embed, showInputs, showDates, showContextPerLine, showSettings, showTypingText, showClear, showOnlyLastMessages, height, secret, baseUrl, apiUrl, initialContextVars, initialQuestion, ogImage, sessionID: initialSessionID, tenant, personification, authToken, AZURE_COGNITIVE_SERVICES_TTS_KEY, defaultSpeakerActive, onStateChange, additionalInfo, additionalSettings, customMediaRenderer, userAvatar, }: Props) => JSX.Element;
|
|
110
|
+
declare const MemoriWidget: ({ memori, memoriConfigs, memoriLang, multilingual, integration, layout, customLayout, showInstruct, showShare, preview, embed, showInputs, showDates, showContextPerLine, showSettings, showTypingText, showClear, showLogin, showOnlyLastMessages, height, secret, baseUrl, apiUrl, initialContextVars, initialQuestion, ogImage, sessionID: initialSessionID, tenant, personification, authToken, AZURE_COGNITIVE_SERVICES_TTS_KEY, defaultSpeakerActive, onStateChange, additionalInfo, additionalSettings, customMediaRenderer, userAvatar, }: Props) => JSX.Element;
|
|
110
111
|
export default MemoriWidget;
|
|
@@ -17,6 +17,7 @@ import AgeVerificationModal from '../AgeVerificationModal/AgeVerificationModal';
|
|
|
17
17
|
import SettingsDrawer from '../SettingsDrawer/SettingsDrawer';
|
|
18
18
|
import KnownFacts from '../KnownFacts/KnownFacts';
|
|
19
19
|
import ExpertsDrawer from '../ExpertsDrawer/ExpertsDrawer';
|
|
20
|
+
import LoginDrawer from '../LoginDrawer/LoginDrawer';
|
|
20
21
|
import FullPageLayout from '../layouts/FullPage';
|
|
21
22
|
import TotemLayout from '../layouts/Totem';
|
|
22
23
|
import ChatLayout from '../layouts/Chat';
|
|
@@ -145,7 +146,7 @@ let audioContext;
|
|
|
145
146
|
let memoriPassword;
|
|
146
147
|
let speakerMuted = false;
|
|
147
148
|
let memoriSpeaking = false;
|
|
148
|
-
const MemoriWidget = ({ memori, memoriConfigs, memoriLang, multilingual, integration, layout = 'DEFAULT', customLayout, showInstruct = false, showShare, preview = false, embed = false, showInputs = true, showDates = false, showContextPerLine = false, showSettings = true, showTypingText = false, showClear = false, showOnlyLastMessages, height = '100vh', secret, baseUrl = 'https://aisuru.com', apiUrl = 'https://backend.memori.ai', initialContextVars, initialQuestion, ogImage, sessionID: initialSessionID, tenant, personification, authToken, AZURE_COGNITIVE_SERVICES_TTS_KEY, defaultSpeakerActive = true, onStateChange, additionalInfo, additionalSettings, customMediaRenderer, userAvatar, }) => {
|
|
149
|
+
const MemoriWidget = ({ memori, memoriConfigs, memoriLang, multilingual, integration, layout = 'DEFAULT', customLayout, showInstruct = false, showShare, preview = false, embed = false, showInputs = true, showDates = false, showContextPerLine = false, showSettings = true, showTypingText = false, showClear = false, showLogin = true, showOnlyLastMessages, height = '100vh', secret, baseUrl = 'https://aisuru.com', apiUrl = 'https://backend.memori.ai', initialContextVars, initialQuestion, ogImage, sessionID: initialSessionID, tenant, personification, authToken, AZURE_COGNITIVE_SERVICES_TTS_KEY, defaultSpeakerActive = true, onStateChange, additionalInfo, additionalSettings, customMediaRenderer, userAvatar, }) => {
|
|
149
150
|
var _a, _b, _c, _d, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _t, _u, _v, _w, _x, _y, _z;
|
|
150
151
|
const { t, i18n } = useTranslation();
|
|
151
152
|
const [isClient, setIsClient] = useState(false);
|
|
@@ -160,13 +161,19 @@ const MemoriWidget = ({ memori, memoriConfigs, memoriLang, multilingual, integra
|
|
|
160
161
|
avatarURL: typeof userAvatar === 'string' ? userAvatar : undefined,
|
|
161
162
|
});
|
|
162
163
|
useEffect(() => {
|
|
163
|
-
if (loginToken) {
|
|
164
|
+
if (loginToken && !(user === null || user === void 0 ? void 0 : user.userID)) {
|
|
164
165
|
client.backend.getCurrentUser(loginToken).then(({ user, resultCode }) => {
|
|
165
|
-
if (user && resultCode === 0)
|
|
166
|
+
if (user && resultCode === 0) {
|
|
166
167
|
setUser(user);
|
|
168
|
+
setLocalConfig('loginToken', loginToken);
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
setLocalConfig('loginToken', undefined);
|
|
172
|
+
}
|
|
167
173
|
});
|
|
168
174
|
}
|
|
169
|
-
}, [loginToken]);
|
|
175
|
+
}, [loginToken, user === null || user === void 0 ? void 0 : user.userID]);
|
|
176
|
+
const [showLoginDrawer, setShowLoginDrawer] = useState(false);
|
|
170
177
|
const [clickedStart, setClickedStart] = useState(false);
|
|
171
178
|
const [gotErrorInOpening, setGotErrorInOpening] = useState(false);
|
|
172
179
|
const language = ((_d = (_c = (_b = memori.culture) === null || _b === void 0 ? void 0 : _b.split('-')) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.toUpperCase()) ||
|
|
@@ -218,6 +225,9 @@ const MemoriWidget = ({ memori, memoriConfigs, memoriLang, multilingual, integra
|
|
|
218
225
|
setContinuousSpeechTimeout(getLocalConfig('continuousSpeechTimeout', 2));
|
|
219
226
|
setControlsPosition(getLocalConfig('controlsPosition', defaultControlsPosition));
|
|
220
227
|
setHideEmissions(getLocalConfig('hideEmissions', false));
|
|
228
|
+
if (!(additionalInfo === null || additionalInfo === void 0 ? void 0 : additionalInfo.loginToken) && !authToken) {
|
|
229
|
+
setLoginToken(getLocalConfig('loginToken', undefined));
|
|
230
|
+
}
|
|
221
231
|
}, []);
|
|
222
232
|
const [memoriPwd, setMemoriPwd] = useState(secret);
|
|
223
233
|
const [memoriTokens, setMemoriTokens] = useState();
|
|
@@ -1826,6 +1836,8 @@ const MemoriWidget = ({ memori, memoriConfigs, memoriLang, multilingual, integra
|
|
|
1826
1836
|
showReload: selectedLayout === 'TOTEM',
|
|
1827
1837
|
showClear,
|
|
1828
1838
|
clearHistory: () => setHistory(h => h.slice(-1)),
|
|
1839
|
+
showLogin,
|
|
1840
|
+
setShowLoginDrawer,
|
|
1829
1841
|
loginToken,
|
|
1830
1842
|
user,
|
|
1831
1843
|
sessionID: sessionId,
|
|
@@ -1862,6 +1874,8 @@ const MemoriWidget = ({ memori, memoriConfigs, memoriLang, multilingual, integra
|
|
|
1862
1874
|
onClickStart: onClickStart,
|
|
1863
1875
|
initializeTTS: initializeTTS,
|
|
1864
1876
|
isUserLoggedIn: !!loginToken,
|
|
1877
|
+
showLogin,
|
|
1878
|
+
setShowLoginDrawer,
|
|
1865
1879
|
user,
|
|
1866
1880
|
};
|
|
1867
1881
|
const chatProps = {
|
|
@@ -1999,7 +2013,21 @@ const MemoriWidget = ({ memori, memoriConfigs, memoriLang, multilingual, integra
|
|
|
1999
2013
|
setShowAgeVerification(false);
|
|
2000
2014
|
setClickedStart(false);
|
|
2001
2015
|
}
|
|
2002
|
-
} })), showSettingsDrawer && (_jsx(SettingsDrawer, { layout: selectedLayout, open: !!showSettingsDrawer, onClose: () => setShowSettingsDrawer(false), microphoneMode: continuousSpeech ? 'CONTINUOUS' : 'HOLD_TO_TALK', continuousSpeechTimeout: continuousSpeechTimeout, setMicrophoneMode: mode => setContinuousSpeech(mode === 'CONTINUOUS'), setContinuousSpeechTimeout: setContinuousSpeechTimeout, controlsPosition: controlsPosition, setControlsPosition: setControlsPosition, hideEmissions: hideEmissions, setHideEmissions: setHideEmissions, additionalSettings: additionalSettings })), showKnownFactsDrawer && sessionId && (_jsx(KnownFacts, { apiURL: apiUrl, memori: memori, sessionID: sessionId, visible: showKnownFactsDrawer, closeDrawer: () => setShowKnownFactsDrawer(false) })), showExpertsDrawer && !!experts && (_jsx(ExpertsDrawer, { apiUrl: apiUrl, baseUrl: baseUrl, tenant: tenant, experts: experts, open: showExpertsDrawer, onClose: () => setShowExpertsDrawer(false) }))
|
|
2016
|
+
} })), showSettingsDrawer && (_jsx(SettingsDrawer, { layout: selectedLayout, open: !!showSettingsDrawer, onClose: () => setShowSettingsDrawer(false), microphoneMode: continuousSpeech ? 'CONTINUOUS' : 'HOLD_TO_TALK', continuousSpeechTimeout: continuousSpeechTimeout, setMicrophoneMode: mode => setContinuousSpeech(mode === 'CONTINUOUS'), setContinuousSpeechTimeout: setContinuousSpeechTimeout, controlsPosition: controlsPosition, setControlsPosition: setControlsPosition, hideEmissions: hideEmissions, setHideEmissions: setHideEmissions, additionalSettings: additionalSettings })), showKnownFactsDrawer && sessionId && (_jsx(KnownFacts, { apiURL: apiUrl, memori: memori, sessionID: sessionId, visible: showKnownFactsDrawer, closeDrawer: () => setShowKnownFactsDrawer(false) })), showExpertsDrawer && !!experts && (_jsx(ExpertsDrawer, { apiUrl: apiUrl, baseUrl: baseUrl, tenant: tenant, experts: experts, open: showExpertsDrawer, onClose: () => setShowExpertsDrawer(false) })), showLoginDrawer && (tenant === null || tenant === void 0 ? void 0 : tenant.id) && (_jsx(LoginDrawer, { tenant: tenant, apiUrl: apiUrl, open: !!showLoginDrawer, user: user, loginToken: loginToken, onClose: () => setShowLoginDrawer(false), onLogin: (user, token) => {
|
|
2017
|
+
setUser(user);
|
|
2018
|
+
setLoginToken(token);
|
|
2019
|
+
setShowLoginDrawer(false);
|
|
2020
|
+
setLocalConfig('loginToken', token);
|
|
2021
|
+
}, onLogout: () => {
|
|
2022
|
+
if (!loginToken)
|
|
2023
|
+
return;
|
|
2024
|
+
client.backend.userLogout(loginToken).then(() => {
|
|
2025
|
+
setShowLoginDrawer(false);
|
|
2026
|
+
setUser(undefined);
|
|
2027
|
+
setLoginToken(undefined);
|
|
2028
|
+
setLocalConfig('loginToken', undefined);
|
|
2029
|
+
});
|
|
2030
|
+
} }))] }));
|
|
2003
2031
|
};
|
|
2004
2032
|
export default MemoriWidget;
|
|
2005
2033
|
//# sourceMappingURL=MemoriWidget.js.map
|