Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UPM-1303]/evgeniy/livechat name and email not populated #16676

Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
5c39c37
fix: [UPM-1303]/evgeniy/livechat name and email not pipulated
yauheni-deriv Aug 29, 2024
689d960
chore: remove comments
yauheni-deriv Aug 30, 2024
16e940b
Merge branch 'master' into livechat/upm-1303-name_and_email_not_popul…
yauheni-deriv Aug 30, 2024
34fe7e7
Merge branch 'master' into livechat/upm-1303-name_and_email_not_popul…
yauheni-deriv Sep 2, 2024
1dc1f5a
refactor: livechat init and usage
yauheni-deriv Sep 4, 2024
0d80eae
Merge branch 'master' into livechat/upm-1303-name_and_email_not_popul…
yauheni-deriv Sep 5, 2024
c810f9d
chore: remove old hook from redirect component
yauheni-deriv Sep 5, 2024
de223d9
chore: add tests for hooks
yauheni-deriv Sep 5, 2024
54e0e37
fix: failing test case
yauheni-deriv Sep 5, 2024
f448979
chore: removed unused import
yauheni-deriv Sep 5, 2024
d1936c3
Merge branch 'master' into livechat/upm-1303-name_and_email_not_popul…
yauheni-deriv Sep 5, 2024
03e0d59
fix: resolve conflict
yauheni-deriv Sep 6, 2024
f01b39e
chore: update package-lock
yauheni-deriv Sep 6, 2024
55b21b8
chore: remove icons, isMounted
yauheni-deriv Sep 9, 2024
93a4965
fix: reverted icons
yauheni-deriv Sep 9, 2024
f90348c
fix: revert useremote default
yauheni-deriv Sep 9, 2024
55167b0
Merge branch 'master' into livechat/upm-1303-name_and_email_not_popul…
yauheni-deriv Sep 9, 2024
6af8aa8
chore: review comments, refactor appcontent
yauheni-deriv Sep 9, 2024
909c4cf
fix: lc call in cashier
yauheni-deriv Sep 9, 2024
d3c37cd
Merge branch 'master' into livechat/upm-1303-name_and_email_not_popul…
yauheni-deriv Sep 10, 2024
e5bb049
Merge branch 'master' into livechat/upm-1303-name_and_email_not_popul…
yauheni-deriv Sep 11, 2024
2d1cfc4
fix: resolve conflict
yauheni-deriv Sep 11, 2024
a933a07
fix: resolve conflicts
yauheni-deriv Sep 13, 2024
ef7c7ce
fix: resolve conflicts
yauheni-deriv Sep 13, 2024
2784d3a
Merge branch 'master' into livechat/upm-1303-name_and_email_not_popul…
yauheni-deriv Sep 17, 2024
8b47483
Merge branch 'master' into livechat/upm-1303-name_and_email_not_popul…
yauheni-deriv Sep 18, 2024
9b16560
fix: resolve conflicts
yauheni-deriv Sep 18, 2024
9399ef3
Merge branch 'master' into livechat/upm-1303-name_and_email_not_popul…
yauheni-deriv Sep 18, 2024
f633f83
Merge branch 'master' into livechat/upm-1303-name_and_email_not_popul…
yauheni-deriv Sep 19, 2024
47fd86a
Merge branch 'master' into livechat/upm-1303-name_and_email_not_popul…
yauheni-deriv Sep 19, 2024
400534c
chore: change name of client store new field
yauheni-deriv Sep 19, 2024
7f3e79e
fix: resolve conflicts
yauheni-deriv Sep 20, 2024
e2a7fad
fix: resolve conflicts
yauheni-deriv Sep 23, 2024
29f05b2
Merge branch 'master' into livechat/upm-1303-name_and_email_not_popul…
yauheni-deriv Sep 23, 2024
70bb92f
fix: ts error
yauheni-deriv Sep 23, 2024
745aee4
fix: resolve conflicts
yauheni-deriv Sep 25, 2024
76e8bde
fix: update psckage lock
yauheni-deriv Sep 25, 2024
2b4bd0d
fix: update deps
yauheni-deriv Sep 25, 2024
a281750
Merge branch 'master' into livechat/upm-1303-name_and_email_not_popul…
yauheni-deriv Sep 27, 2024
7bd472b
fix: resolve conflicts
yauheni-deriv Sep 30, 2024
4899724
chore: update package-lock
yauheni-deriv Sep 30, 2024
70c1b1b
Merge branch 'master' into livechat/upm-1303-name_and_email_not_popul…
yauheni-deriv Sep 30, 2024
b45bcfb
fix: resolve conflicts
yauheni-deriv Sep 30, 2024
a3eb9f1
Merge branch 'master' into livechat/upm-1303-name_and_email_not_popul…
yauheni-deriv Oct 1, 2024
439c4d6
Merge branch 'master' into livechat/upm-1303-name_and_email_not_popul…
yauheni-deriv Oct 1, 2024
b1fc49e
Merge branch 'master' into livechat/upm-1303-name_and_email_not_popul…
yauheni-deriv Oct 1, 2024
f583d8d
fix: update package lock and fix code
yauheni-deriv Oct 1, 2024
eff6607
Merge branch 'master' into livechat/upm-1303-name_and_email_not_popul…
yauheni-deriv Oct 2, 2024
9beab9f
Merge branch 'master' into livechat/upm-1303-name_and_email_not_popul…
yauheni-deriv Oct 3, 2024
7fb24e0
fix: removed old lc_api call
yauheni-deriv Oct 3, 2024
97200b9
Merge branch 'master' into livechat/upm-1303-name_and_email_not_popul…
yauheni-deriv Oct 4, 2024
f067f61
fix: using old api to close opened chat after loggin out
yauheni-deriv Oct 4, 2024
df55d2c
fix: stop fetching account settings after logging out
yauheni-deriv Oct 6, 2024
5afba2f
Merge branch 'master' into livechat/upm-1303-name_and_email_not_popul…
yauheni-deriv Oct 7, 2024
c9956d0
chore: update package-lock
yauheni-deriv Oct 7, 2024
a9b7be3
Merge branch 'master' into livechat/upm-1303-name_and_email_not_popul…
yauheni-deriv Oct 9, 2024
5d44c61
Merge branch 'master' into livechat/upm-1303-name_and_email_not_popul…
yauheni-deriv Oct 11, 2024
7b19b3e
fix: close chat before hidding it after logout
yauheni-deriv Oct 11, 2024
47228e4
fix: resolve conflict
yauheni-deriv Oct 11, 2024
c1dbc93
Merge branch 'master' into livechat/upm-1303-name_and_email_not_popul…
yauheni-deriv Oct 15, 2024
db0bfe0
fix: resolve conflict
yauheni-deriv Oct 15, 2024
13d2bab
Merge branch 'master' into livechat/upm-1303-name_and_email_not_popul…
yauheni-deriv Oct 15, 2024
04acfc9
fix: resolve conflicts
yauheni-deriv Oct 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3,703 changes: 2,904 additions & 799 deletions package-lock.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import React from 'react';
import { fireEvent, render, screen } from '@testing-library/react';
import { POILimited } from '../limited';

window.LC_API = {
open_chat_window: jest.fn(),
on_chat_ended: jest.fn(),
window.LiveChatWidget = {
call: jest.fn(),
get: jest.fn(),
init: jest.fn(),
on: jest.fn(),
};

describe('<POILimited/>', () => {
Expand All @@ -16,6 +18,7 @@ describe('<POILimited/>', () => {
const live_chat_text = screen.getByText(/live chat/i);
expect(live_chat_text).toBeInTheDocument();
fireEvent.click(live_chat_text);
expect(window.LC_API.open_chat_window).toHaveBeenCalledTimes(1);
expect(window.LiveChatWidget.call).toHaveBeenCalledTimes(1);
expect(window.LiveChatWidget.call).toHaveBeenCalledWith('maximize');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ export const POILimited = () => (
<Localize
i18n_default_text='Please contact us via <0>live chat</0>.'
components={[
<span key={0} className='link link--orange' onClick={() => window.LC_API.open_chat_window()} />,
<span
key={0}
className='link link--orange'
onClick={() => window.LiveChatWidget.call('maximize')}
/>,
]}
/>
}
Expand Down
2 changes: 1 addition & 1 deletion packages/account/src/Configs/poi-error-config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Localize } from '@deriv/translations';
import { DerivLightNameDobPoiIcon, DerivLightDobPoiIcon, DerivLightNamePoiIcon } from '@deriv/quill-icons';
import { getIDVDocumentType } from '../Helpers/utils';

const handleOnClick = () => window.LC_API.open_chat_window();
const handleOnClick = () => window.LiveChatWidget.call('maximize');

export const GENERIC_ERROR_MESSAGE = (
<Localize i18n_default_text='Sorry, an internal error occurred. Hit the above checkbox to try again.' />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const WalletsMigrationFailed = observer(() => {
};

const handleLivechatButtonClick = () => {
window.LC_API?.open_chat_window();
window.LiveChatWidget.call('maximize');
setWalletsMigrationFailedPopup(false);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ const getMessage = ({
<span
key={0}
className='link link--orange'
onClick={() => window.LC_API.open_chat_window()}
onClick={() => window.LiveChatWidget.call('maximize')}
/>,
]}
/>
Expand All @@ -147,7 +147,7 @@ const getMessage = ({
<span
key={0}
className='link link--orange'
onClick={() => window.LC_API.open_chat_window()}
onClick={() => window.LiveChatWidget.call('maximize')}
/>,
]}
/>
Expand Down Expand Up @@ -378,7 +378,7 @@ const getMessage = ({
<span
key={0}
className='link link--orange'
onClick={() => window.LC_API.open_chat_window()}
onClick={() => window.LiveChatWidget.call('maximize')}
/>,
]}
/>
Expand All @@ -395,7 +395,7 @@ const getMessage = ({
<span
key={0}
className='link link--orange'
onClick={() => window.LC_API.open_chat_window()}
onClick={() => window.LiveChatWidget.call('maximize')}
/>,
]}
/>
Expand Down Expand Up @@ -471,7 +471,7 @@ const getMessage = ({
<span
key={0}
className='link link--orange'
onClick={() => window.LC_API.open_chat_window()}
onClick={() => window.LiveChatWidget.call('maximize')}
/>,
]}
/>
Expand All @@ -488,7 +488,7 @@ const getMessage = ({
<span
key={0}
className='link link--orange'
onClick={() => window.LC_API.open_chat_window()}
onClick={() => window.LiveChatWidget.call('maximize')}
/>,
]}
/>
Expand All @@ -505,7 +505,7 @@ const getMessage = ({
<span
key={0}
className='link link--orange'
onClick={() => window.LC_API.open_chat_window()}
onClick={() => window.LiveChatWidget.call('maximize')}
/>,
]}
/>
Expand All @@ -528,7 +528,11 @@ const getMessage = ({
<Localize
i18n_default_text='Your cashier is currently locked. Please contact us via <0>live chat</0> to find out how to unlock it.'
components={[
<span key={0} className='link link--orange' onClick={() => window.LC_API.open_chat_window()} />,
<span
key={0}
className='link link--orange'
onClick={() => window.LiveChatWidget.call('maximize')}
/>,
]}
/>
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const SideNoteFAQ = ({ transaction_type }: TSideNoteFAQProps) => {
const { isMobile } = useDevice();
const { is_eu } = client;

const onClickHandler = () => window.LC_API?.open_chat_window?.();
const onClickHandler = () => window.LiveChatWidget.call('maximize');

const deposit_faq_list = useMemo(() => {
return [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ const CashierOnboardingSideNoteFiat: React.FC = observer(() => {
is_from_derivgo ? (
<span />
) : (
<a key={0} className='link link--orange' onClick={() => window.LC_API.open_chat_window()} />
<a
key={0}
className='link link--orange'
onClick={() => window.LiveChatWidget.call('maximize')}
/>
),
]}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const DepositFiat: React.FC = observer(() => {
const { common, traders_hub } = useStore();
const { is_from_derivgo } = common;
const { is_low_risk_cr_eu_real } = traders_hub;
const onClickHandler = () => window.LC_API?.open_chat_window?.();
const onClickHandler = () => window.LiveChatWidget.call('maximize');

return (
<PageContainer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ jest.mock('@deriv/shared', () => ({
isMobile: jest.fn(),
}));

global.window.LC_API = {
open_chat_window: jest.fn(),
window.LiveChatWidget = {
call: jest.fn(),
get: jest.fn(),
init: jest.fn(),
on: jest.fn(),
};

describe('<CFDPersonalDetailsForm />', () => {
Expand Down Expand Up @@ -358,6 +361,6 @@ describe('<CFDPersonalDetailsForm />', () => {
const linkElement = screen.getByText(/live chat/i);
expect(linkElement).toBeInTheDocument();
fireEvent.click(linkElement);
expect(window.LC_API.open_chat_window).toHaveBeenCalled();
expect(window.LiveChatWidget.call).toHaveBeenCalledWith('maximize');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ const CFDPersonalDetailsForm = ({
<span
key={0}
className='link link--orange'
onClick={() => window.LC_API.open_chat_window()}
onClick={() => window.LiveChatWidget.call('maximize')}
/>,
]}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ type TOpenLiveChatLink = {
};

const OpenLiveChatLink = ({ children, text_size }: React.PropsWithChildren<TOpenLiveChatLink>) => (
<button type='button' className='open-livechat__link' onClick={() => window.LC_API.open_chat_window()}>
<button type='button' className='open-livechat__link' onClick={() => window.LiveChatWidget.call('maximize')}>
<Text size={text_size || 'xs'} weight='bold' color='brand-red-coral'>
{children || <Localize i18n_default_text='live chat' />}
</Text>
Expand Down
1 change: 0 additions & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@
"@deriv/translations": "^1.0.0",
"@deriv/utils": "^1.0.0",
"@deriv/wallets": "^1.0.0",
"@livechat/customer-sdk": "^2.0.4",
"acorn": "^6.1.1",
"babel-polyfill": "^6.26.0",
"canvas-toBlob": "^1.0.0",
Expand Down
57 changes: 46 additions & 11 deletions packages/core/src/App/AppContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,27 @@ import Devtools from './Devtools';
import LandscapeBlocker from './Components/Elements/LandscapeBlocker';
import initDatadog from '../Utils/Datadog';
import { ThemeProvider } from '@deriv-com/quill-ui';
import { useGrowthbookIsOn } from '@deriv/hooks';
import { useGrowthbookIsOn, useLiveChat } from '@deriv/hooks';
import { useTranslations } from '@deriv-com/translations';

const AppContent: React.FC<{ passthrough: unknown }> = observer(({ passthrough }) => {
const store = useStore();
const { has_wallet } = store.client;
const { current_language } = store.common;
const {
has_wallet,
is_logged_in,
loginid,
is_client_initialized,
landing_company_shortcode,
currency,
residence,
email,
setIsPasskeySupported,
account_settings,
} = store.client;
const { first_name, last_name } = account_settings;
const { current_language, changeSelectedLanguage } = store.common;
const { is_dark_mode_on, setDarkMode } = store.ui;

const { isMobile } = useDevice();
const { switchLanguage } = useTranslations();

Expand All @@ -38,17 +52,38 @@ const AppContent: React.FC<{ passthrough: unknown }> = observer(({ passthrough }
const { tracking_datadog } = data;
const is_passkeys_supported = browserSupportsWebAuthn();

const livechat_client_information: Parameters<typeof useLiveChat>[0] = {
is_client_initialized,
is_logged_in,
loginid,
landing_company_shortcode,
currency,
residence,
email,
first_name,
last_name,
};

useLiveChat(livechat_client_information);

React.useEffect(() => {
switchLanguage(current_language);
}, [current_language, switchLanguage]);

React.useEffect(() => {
if (isGBLoaded && isWebPasskeysFFEnabled && isServicePasskeysFFEnabled) {
store.client.setIsPasskeySupported(
setIsPasskeySupported(
is_passkeys_supported && isServicePasskeysFFEnabled && isWebPasskeysFFEnabled && isMobile
);
}
}, [isServicePasskeysFFEnabled, isGBLoaded, isWebPasskeysFFEnabled, is_passkeys_supported, isMobile, store.client]);
}, [
isServicePasskeysFFEnabled,
isGBLoaded,
isWebPasskeysFFEnabled,
is_passkeys_supported,
isMobile,
setIsPasskeySupported,
]);

React.useEffect(() => {
initDatadog(tracking_datadog);
Expand All @@ -57,17 +92,17 @@ const AppContent: React.FC<{ passthrough: unknown }> = observer(({ passthrough }
// intentionally switch the user with wallets to light mode and EN language
React.useLayoutEffect(() => {
if (has_wallet) {
if (store.ui.is_dark_mode_on) {
store.ui.setDarkMode(false);
if (is_dark_mode_on) {
setDarkMode(false);
}
if (store.common.current_language !== 'EN') {
store.common.changeSelectedLanguage('EN');
if (current_language !== 'EN') {
changeSelectedLanguage('EN');
}
}
}, [has_wallet, store.common, store.ui]);
}, [has_wallet, current_language, changeSelectedLanguage, is_dark_mode_on, setDarkMode]);

return (
<ThemeProvider theme={store.ui.is_dark_mode_on ? 'dark' : 'light'}>
<ThemeProvider theme={is_dark_mode_on ? 'dark' : 'light'}>
<LandscapeBlocker />
<Header />
<ErrorBoundary root_store={store}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
import React from 'react';
import { Popover, Icon, Text } from '@deriv/components';
import { observer, useStore } from '@deriv/stores';
import { Localize } from '@deriv/translations';
import useLiveChat from 'App/Components/Elements/LiveChat/use-livechat';
import { useDevice } from '@deriv-com/ui';
import { useIsLiveChatWidgetAvailable } from '@deriv/hooks';

const LiveChat = observer(({ showPopover }: { showPopover?: boolean }) => {
const { client, ui } = useStore();
const { has_cookie_account, loginid } = client;
const { is_mobile } = ui;
const liveChat = useLiveChat(has_cookie_account, loginid);
const LiveChat = ({ showPopover }: { showPopover?: boolean }) => {
const { isDesktop } = useDevice();
const { is_livechat_available } = useIsLiveChatWidgetAvailable();
const liveChatClickHandler = () => window.LiveChatWidget.call('maximize');

if (!liveChat.isReady) return null;
if (!is_livechat_available) return null;

const liveChatClickHandler = () => liveChat.widget?.call('maximize');

if (is_mobile)
if (!isDesktop)
return (
<div
className='livechat gtm-deriv-livechat'
Expand Down Expand Up @@ -49,6 +45,6 @@ const LiveChat = observer(({ showPopover }: { showPopover?: boolean }) => {
)}
</div>
);
});
};

export default LiveChat;
Loading
Loading