feat: remove chatwood
This commit is contained in:
@@ -1,53 +0,0 @@
|
|||||||
import * as React from 'react';
|
|
||||||
import { useTheme } from '@mui/material/styles';
|
|
||||||
import useMediaQuery from '@mui/material/useMediaQuery';
|
|
||||||
|
|
||||||
import appConfig from 'config/app';
|
|
||||||
import useCurrentUser from 'hooks/useCurrentUser';
|
|
||||||
|
|
||||||
const Chatwoot = ({ ready }) => {
|
|
||||||
const theme = useTheme();
|
|
||||||
const { data } = useCurrentUser();
|
|
||||||
const currentUser = data?.data;
|
|
||||||
const matchSmallScreens = useMediaQuery(theme.breakpoints.down('md'));
|
|
||||||
|
|
||||||
React.useEffect(function initiateChatwoot() {
|
|
||||||
window.chatwootSDK.run({
|
|
||||||
websiteToken: 'EFyq5MTsvS7XwUrwSH36VskT',
|
|
||||||
baseUrl: appConfig.chatwootBaseUrl,
|
|
||||||
});
|
|
||||||
|
|
||||||
return function removeChatwoot() {
|
|
||||||
window.$chatwoot.reset();
|
|
||||||
window.$chatwoot.toggleBubbleVisibility('hide');
|
|
||||||
};
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
React.useEffect(
|
|
||||||
function initiateUser() {
|
|
||||||
if (!currentUser?.id || !ready) return;
|
|
||||||
window.$chatwoot.setUser(currentUser.id, {
|
|
||||||
email: currentUser.email,
|
|
||||||
name: currentUser.fullName,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!matchSmallScreens) {
|
|
||||||
window.$chatwoot.toggleBubbleVisibility('show');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
[currentUser, ready, matchSmallScreens],
|
|
||||||
);
|
|
||||||
React.useLayoutEffect(
|
|
||||||
function hideChatwoot() {
|
|
||||||
if (matchSmallScreens) {
|
|
||||||
window.$chatwoot?.toggleBubbleVisibility('hide');
|
|
||||||
} else {
|
|
||||||
window.$chatwoot?.toggleBubbleVisibility('show');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
[matchSmallScreens],
|
|
||||||
);
|
|
||||||
|
|
||||||
return <React.Fragment />;
|
|
||||||
};
|
|
||||||
export default Chatwoot;
|
|
@@ -1,47 +0,0 @@
|
|||||||
import * as React from 'react';
|
|
||||||
import appConfig from 'config/app';
|
|
||||||
import useAuthentication from 'hooks/useAuthentication';
|
|
||||||
import useCloud from 'hooks/useCloud';
|
|
||||||
import Chatwoot from './Chatwoot.ee';
|
|
||||||
const LiveChat = () => {
|
|
||||||
const isCloud = useCloud();
|
|
||||||
const { isAuthenticated } = useAuthentication();
|
|
||||||
const [isLoaded, setLoaded] = React.useState(false);
|
|
||||||
const [isReady, setReady] = React.useState(false);
|
|
||||||
const shouldShow = isCloud && isAuthenticated;
|
|
||||||
React.useLayoutEffect(() => {
|
|
||||||
window.addEventListener(
|
|
||||||
'chatwoot:ready',
|
|
||||||
function () {
|
|
||||||
setReady(true);
|
|
||||||
},
|
|
||||||
{ once: true },
|
|
||||||
);
|
|
||||||
}, []);
|
|
||||||
React.useLayoutEffect(
|
|
||||||
function addChatwootScript() {
|
|
||||||
if (!shouldShow) return;
|
|
||||||
window.chatwootSettings = {
|
|
||||||
hideMessageBubble: true,
|
|
||||||
position: 'right',
|
|
||||||
type: 'standard',
|
|
||||||
launcherTitle: 'Give us feedback',
|
|
||||||
};
|
|
||||||
const g = document.createElement('script');
|
|
||||||
const s = document.getElementsByTagName('script')[0];
|
|
||||||
g.src = appConfig.chatwootBaseUrl + '/packs/js/sdk.js';
|
|
||||||
g.defer = true;
|
|
||||||
g.async = true;
|
|
||||||
if (s.parentNode) {
|
|
||||||
s.parentNode.insertBefore(g, s);
|
|
||||||
}
|
|
||||||
g.onload = function () {
|
|
||||||
setLoaded(true);
|
|
||||||
};
|
|
||||||
},
|
|
||||||
[shouldShow],
|
|
||||||
);
|
|
||||||
if (!shouldShow || !isLoaded) return <React.Fragment />;
|
|
||||||
return <Chatwoot ready={isReady} />;
|
|
||||||
};
|
|
||||||
export default LiveChat;
|
|
@@ -18,7 +18,6 @@ const config = {
|
|||||||
baseUrl: process.env.REACT_APP_BASE_URL,
|
baseUrl: process.env.REACT_APP_BASE_URL,
|
||||||
graphqlUrl: computeUrl('/graphql', backendUrl),
|
graphqlUrl: computeUrl('/graphql', backendUrl),
|
||||||
restApiUrl: computeUrl('/api', backendUrl),
|
restApiUrl: computeUrl('/api', backendUrl),
|
||||||
chatwootBaseUrl: 'https://app.chatwoot.com',
|
|
||||||
supportEmailAddress: 'support@automatisch.io',
|
supportEmailAddress: 'support@automatisch.io',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -7,7 +7,6 @@ import MetadataProvider from 'components/MetadataProvider';
|
|||||||
import { AuthenticationProvider } from 'contexts/Authentication';
|
import { AuthenticationProvider } from 'contexts/Authentication';
|
||||||
import QueryClientProvider from 'components/QueryClientProvider';
|
import QueryClientProvider from 'components/QueryClientProvider';
|
||||||
import Router from 'components/Router';
|
import Router from 'components/Router';
|
||||||
import LiveChat from 'components/LiveChat/index.ee';
|
|
||||||
import routes from 'routes';
|
import routes from 'routes';
|
||||||
import reportWebVitals from './reportWebVitals';
|
import reportWebVitals from './reportWebVitals';
|
||||||
|
|
||||||
@@ -22,10 +21,7 @@ root.render(
|
|||||||
<ApolloProvider>
|
<ApolloProvider>
|
||||||
<IntlProvider>
|
<IntlProvider>
|
||||||
<ThemeProvider>
|
<ThemeProvider>
|
||||||
<MetadataProvider>
|
<MetadataProvider>{routes}</MetadataProvider>
|
||||||
{routes}
|
|
||||||
<LiveChat />
|
|
||||||
</MetadataProvider>
|
|
||||||
</ThemeProvider>
|
</ThemeProvider>
|
||||||
</IntlProvider>
|
</IntlProvider>
|
||||||
</ApolloProvider>
|
</ApolloProvider>
|
||||||
|
Reference in New Issue
Block a user