added button to open crisp chat from the chat menu
This commit is contained in:
parent
c79c6baa1f
commit
baf59a2b78
9 changed files with 183 additions and 29 deletions
|
|
@ -14,6 +14,7 @@ import { AppThemeProvider } from 'theme/AppThemeProvider'
|
|||
import HTTPProvider from 'providers/http'
|
||||
import { Crisp } from "crisp-sdk-web";
|
||||
import { useMobile, useSnackbar } from 'hooks'
|
||||
import { initCrisp } from '../chat/CrispChat'
|
||||
// import FirmwareLoader from './FirmwareLoader'
|
||||
|
||||
const reducer = (state: GlobalState, action: GlobalStateAction): GlobalState => {
|
||||
|
|
@ -113,20 +114,14 @@ export default function UserWrapper(props: Props) {
|
|||
}, [setGlobal])
|
||||
|
||||
useEffect(() => {
|
||||
if (!crispInitialized.current && global?.user) {
|
||||
Crisp.configure(import.meta.env.VITE_CRISP_WEBSITE_ID);
|
||||
crispInitialized.current = true;
|
||||
Crisp.session.reset();
|
||||
Crisp.user.setEmail(global?.user.settings.email);
|
||||
// Optional: Set nickname or other info
|
||||
Crisp.user.setNickname(global?.user.settings.name || global?.user.settings.email);
|
||||
Crisp.user.setPhone(global?.user.settings.phoneNumber);
|
||||
|
||||
// For extra security (marks email as verified, prevents spoofing):
|
||||
// Crisp.user.setEmail(user.email, "your-hmac-signature-here"); // See Crisp docs for signing
|
||||
|
||||
// Optional: For session continuity across devices/browsers
|
||||
Crisp.setTokenId(global?.user.id()); // e.g., your DB user ID
|
||||
if (global?.user) {
|
||||
initCrisp({
|
||||
websiteId: import.meta.env.VITE_CRISP_WEBSITE_ID,
|
||||
email: global.user.settings.email,
|
||||
nickname: global.user.settings.name || global.user.settings.email,
|
||||
phone: global.user.settings.phoneNumber,
|
||||
tokenId: global.user.id(),
|
||||
});
|
||||
}
|
||||
}, [global]);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue