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

refactor: evgeniy/92724/language settings improvements #8176

Merged
Show file tree
Hide file tree
Changes from 106 commits
Commits
Show all changes
145 commits
Select commit Hold shift + click to select a range
5242db6
refactor: evgeniy/92724/language settings improvements
Apr 6, 2023
ffeeb19
fix: cursor button fix
Apr 6, 2023
ff4b10c
Merge branch 'master' of github.com:binary-com/deriv-app into evgeniy…
Apr 11, 2023
4ae4d10
feat: same language menu usage for responsive
Apr 13, 2023
df0c7fc
Merge branch 'master' of github.com:binary-com/deriv-app into evgeniy…
Apr 13, 2023
228311e
fix: hide language icon while opening language menu
Apr 13, 2023
16604ee
refactor: review change, adding types and dependencies
Apr 14, 2023
b0da01a
fix: resolve conflicts, update from master
Apr 19, 2023
f1a6457
fix: changes from master missed
Apr 19, 2023
43769d9
fix: conflicts, update from master
May 14, 2023
f9cc1ef
fix: reading undefined error
May 14, 2023
d7ccb1d
fix: resolve conflicts, update from master
May 21, 2023
1dd5a15
fix: duplicated properties
May 21, 2023
3fc2275
fix: types duplicate
May 21, 2023
599947d
Merge branch 'master' into evgeniy/92724/language_settings_improvements
yauheni-deriv May 22, 2023
eece872
Merge branch 'master' into evgeniy/92724/language_settings_improvements
yauheni-deriv May 25, 2023
47248a5
Merge branch 'master' into evgeniy/92724/language_settings_improvements
yauheni-deriv May 26, 2023
fda654b
Merge branch 'master' into evgeniy/92724/language_settings_improvements
yauheni-deriv May 26, 2023
f24ddf0
Merge branch 'master' into evgeniy/92724/language_settings_improvements
yauheni-deriv May 29, 2023
c85f08a
Merge branch 'master' into evgeniy/92724/language_settings_improvements
yauheni-deriv May 29, 2023
17a2eea
Merge branch 'master' into evgeniy/92724/language_settings_improvements
yauheni-deriv May 29, 2023
78f44aa
Merge branch 'master' into evgeniy/92724/language_settings_improvements
yauheni-deriv May 29, 2023
a1fffd5
Merge branch 'master' into evgeniy/92724/language_settings_improvements
yauheni-deriv May 30, 2023
c3c60e9
Merge branch 'master' into evgeniy/92724/language_settings_improvements
yauheni-deriv May 30, 2023
bc05d93
Merge branch 'master' into evgeniy/92724/language_settings_improvements
yauheni-deriv May 31, 2023
0e8f1ac
Merge branch 'master' into evgeniy/92724/language_settings_improvements
likhith-deriv Jun 1, 2023
3f35548
Merge branch 'master' into evgeniy/92724/language_settings_improvements
yauheni-deriv Jun 1, 2023
f776de6
Merge branch 'master' into evgeniy/92724/language_settings_improvements
yauheni-deriv Jun 2, 2023
3ffbc18
Merge branch 'master' into evgeniy/92724/language_settings_improvements
yauheni-deriv Jun 2, 2023
b82865f
Merge branch 'master' into evgeniy/92724/language_settings_improvements
yauheni-deriv Jun 6, 2023
9224b24
Merge branch 'master' into evgeniy/92724/improve-language-settings
yauheni-deriv Jun 8, 2023
34697ac
Merge branch 'master' into evgeniy/92724/improve-language-settings
yauheni-deriv Jun 11, 2023
02ab4c2
fix: resolve conflicts, update from master
Jun 12, 2023
9e5b301
fix: resolve conflicts, update from master
Jun 12, 2023
44278eb
fix: resolve conflicts, update from master
Jun 12, 2023
12b40a6
Merge branch 'master' into evgeniy/92724/language_settings_improvements
yauheni-deriv Jun 14, 2023
fc1fb05
Merge branch 'master' into evgeniy/92724/improve-language-settings
yauheni-deriv Jun 14, 2023
135609b
Merge branch 'master' into evgeniy/92724/language_settings_improvements
yauheni-deriv Jun 15, 2023
05d4ec0
chore: language-settings test
Jun 16, 2023
55e3cdf
refactor: menu-link store separately
Jun 16, 2023
c5e5891
Merge branch 'master' into evgeniy/92724/language_settings_improvements
yauheni-deriv Jun 16, 2023
9a201a4
Merge branch 'master' into evgeniy/92724/improve-language-settings
yauheni-deriv Jun 16, 2023
baabdf7
Merge branch 'evgeniy/92724/language_settings_improvements' of github…
Jun 16, 2023
e89eb92
Merge branch 'master' into evgeniy/92724/language_settings_improvements
yauheni-deriv Jun 19, 2023
e6f5a62
Merge branch 'master' into evgeniy/92724/language_settings_improvements
yauheni-deriv Jun 19, 2023
e5ffced
Merge branch 'master' into evgeniy/92724/language_settings_improvements
yauheni-deriv Jun 19, 2023
51a8b62
Merge branch 'master' into evgeniy/92724/language_settings_improvements
yauheni-deriv Jun 19, 2023
b6601b8
Merge branch 'master' into evgeniy/92724/language_settings_improvements
yauheni-deriv Jun 19, 2023
104b761
Merge branch 'master' into evgeniy/92724/language_settings_improvements
yauheni-deriv Jun 19, 2023
736c9a7
Merge branch 'master' into evgeniy/92724/language_settings_improvements
yauheni-deriv Jun 19, 2023
a87b127
chore: menu-link test coverage
Jun 19, 2023
ddb6fcf
Merge branch 'evgeniy/92724/language_settings_improvements' of github…
Jun 19, 2023
2622b42
Merge branch 'master' into evgeniy/92724/improve-language-settings
yauheni-deriv Jun 20, 2023
d42f376
Merge branch 'master' into evgeniy/92724/language_settings_improvements
yauheni-deriv Jun 20, 2023
f85a888
refactor: test code structure
Jun 20, 2023
1a8fc83
Merge branch 'evgeniy/92724/language_settings_improvements' of github…
Jun 20, 2023
201ee04
refactor: link code
Jun 20, 2023
0d2b954
Merge branch 'master' into evgeniy/92724/improve-language-settings
yauheni-deriv Jun 20, 2023
794a1de
refactor: remove unused code
Jun 20, 2023
44218ec
refactor: code readability
Jun 20, 2023
d82d363
refactor: variable usage
Jun 20, 2023
4c6515d
refactor: variable usage
Jun 20, 2023
1f77c90
Merge branch 'master' into evgeniy/92724/language_settings_improvements
matin-deriv Jun 21, 2023
7de08a6
Merge branch 'master' into evgeniy/92724/language_settings_improvements
yauheni-deriv Jun 21, 2023
3a90d8f
refactor: review comments incorporating
Jun 21, 2023
ebeb1fd
Merge branch 'master' into evgeniy/92724/language_settings_improvements
yauheni-deriv Jun 21, 2023
b3a8916
fix: resolve conflicts, update from master
Jun 22, 2023
39010d3
fix: resolve conflicts
Jun 22, 2023
52e0f85
fix: test refactor with mockstore
Jun 22, 2023
a7e3a39
fix: missing mock
Jun 22, 2023
70ce7dc
fix: :art: incorporated deriv/util package
likhith-deriv Jun 23, 2023
3b22b1d
Merge branch 'master' into evgeniy/92724/language_settings_improvements
likhith-deriv Jun 23, 2023
89c1102
fix: :zap: refactored code
likhith-deriv Jun 23, 2023
a7dbe08
feat: resolved code smells
likhith-deriv Jun 23, 2023
8dee5c9
Merge branch 'master' into evgeniy/92724/language_settings_improvements
likhith-deriv Jun 23, 2023
a5d332b
feat: resolved review comments
likhith-deriv Jun 23, 2023
e040848
Merge branch 'master' into evgeniy/92724/language_settings_improvements
likhith-deriv Jun 23, 2023
04d0364
feat: resolved review comments
likhith-deriv Jun 23, 2023
af89cf9
feat: resolved review comments
likhith-deriv Jun 23, 2023
2757de7
chore: Merge branch 'master' into evgeniy/92724/language_settings_imp…
likhith-deriv Jul 10, 2023
192513d
Merge branch 'master' into evgeniy/92724/language_settings_improvements
likhith-deriv Jul 11, 2023
df3c3aa
fix: failing testcase
likhith-deriv Jul 11, 2023
15df534
Merge branch 'master' into evgeniy/92724/language_settings_improvements
likhith-deriv Jul 11, 2023
9be963e
Merge branch 'master' into evgeniy/92724/language_settings_improvements
likhith-deriv Jul 11, 2023
08d49d5
Merge branch 'master' into evgeniy/92724/language_settings_improvements
likhith-deriv Jul 12, 2023
7bd78a7
Merge branch 'master' into evgeniy/92724/language_settings_improvements
likhith-deriv Jul 14, 2023
01557c7
Merge branch 'master' into evgeniy/92724/language_settings_improvements
matin-deriv Jul 14, 2023
58d9947
Merge branch 'master' into evgeniy/92724/language_settings_improvements
likhith-deriv Jul 17, 2023
02f34f1
fix: :bug: missing import
likhith-deriv Jul 17, 2023
28e6b24
Merge branch 'master' into evgeniy/92724/language_settings_improvements
yauheni-deriv Jul 17, 2023
d27b49c
Merge branch 'master' into evgeniy/92724/language_settings_improvements
yauheni-deriv Jul 18, 2023
2edc963
Merge branch 'master' into evgeniy/92724/language_settings_improvements
yauheni-deriv Jul 19, 2023
fd69ce7
Merge branch 'master' into evgeniy/92724/language_settings_improvements
yauheni-deriv Jul 20, 2023
7b3950a
Merge branch 'master' into evgeniy/92724/language_settings_improvements
yauheni-deriv Jul 20, 2023
305998b
Merge branch 'master' into evgeniy/92724/language_settings_improvements
yauheni-deriv Jul 21, 2023
a5ac6aa
Trigger build
Jul 21, 2023
d0c1ce1
Merge branch 'master' of github.com:binary-com/deriv-app into evgeniy…
Jul 27, 2023
901e88f
chore: trigger build
Jul 27, 2023
be34e3a
Merge branch 'master' into evgeniy/92724/language_settings_improvements
likhith-deriv Aug 9, 2023
d3d8ed2
Merge branch 'master' into evgeniy/92724/language_settings_improvements
likhith-deriv Aug 9, 2023
f3a175c
Merge branch 'master' into evgeniy/92724/language_settings_improvements
likhith-deriv Aug 9, 2023
080505c
chore: Merge branch 'master' into evgeniy/92724/language_settings_imp…
likhith-deriv Aug 9, 2023
e88e1a1
chore: review comments incorporate
Aug 10, 2023
4eb91b4
fix: resolve conflicts
Aug 10, 2023
8f8d5e4
refactor: types store alphabetically order
Aug 10, 2023
2e48362
refactor: types store alphabetically order
Aug 10, 2023
4ddceac
refactor: menulink export fix
Aug 11, 2023
2625ce4
fix: resolve conflicts
Aug 15, 2023
bbcd91c
chore: remove unused variable
Aug 15, 2023
72d8dde
refactor: remove unused variable
Aug 16, 2023
d1d9444
Merge branch 'master' of github.com:binary-com/deriv-app into evgeniy…
Aug 22, 2023
543d5dd
chore: trigger build
Aug 22, 2023
ba6d487
fix: resolve conflict, update from master
Aug 24, 2023
2c2c51f
fix: resolve conflict, update from master
Aug 28, 2023
9903ad0
Merge branch 'master' of github.com:binary-com/deriv-app into evgeniy…
Aug 30, 2023
60819f4
Merge branch 'master' of github.com:binary-com/deriv-app into evgeniy…
Sep 1, 2023
8ecc541
fix: resolve conflicts, update from master
Sep 4, 2023
df80ad5
Merge branch 'master' of github.com:binary-com/deriv-app into evgeniy…
Sep 6, 2023
625f38f
fix: resolve conflict, update from master
Sep 11, 2023
16ca4d6
fix: resolve conflicts
Sep 11, 2023
a480137
fix: resolve conflicts
Sep 12, 2023
d355840
Merge branch 'master' of github.com:binary-com/deriv-app into evgeniy…
Sep 13, 2023
f31859a
Merge branch 'evgeniy/92724/language_settings_improvements' of github…
Sep 13, 2023
9c1070b
Merge branch 'master' of github.com:binary-com/deriv-app into evgeniy…
Sep 15, 2023
cd9c87c
fix: resolve conflicts
Sep 15, 2023
e8c2898
Merge branch 'master' of github.com:binary-com/deriv-app into evgeniy…
Sep 15, 2023
343b91c
Merge branch 'master' of github.com:binary-com/deriv-app into evgeniy…
Sep 18, 2023
5e2beb8
fix: resolve conflicts
Sep 18, 2023
d1e1889
Merge branch 'master' of github.com:binary-com/deriv-app into evgeniy…
Sep 19, 2023
e9ea5f9
Merge branch 'master' of github.com:binary-com/deriv-app into evgeniy…
Sep 19, 2023
6518515
Merge branch 'master' of github.com:binary-com/deriv-app into evgeniy…
Sep 20, 2023
2e5c710
fix: resolve conflicts
Sep 21, 2023
911c54a
Merge branch 'master' of github.com:binary-com/deriv-app into evgeniy…
Sep 21, 2023
d6decc2
Merge branch 'master' of github.com:binary-com/deriv-app into evgeniy…
Sep 21, 2023
5d95d8f
fix: resolve conflicts
Sep 25, 2023
f798c1c
fix: repeated fields
Sep 25, 2023
70b74c5
fix: resolve conflicts
Sep 26, 2023
266361a
fix: resolve conflict
Sep 29, 2023
d498ee1
chore: isExternalLink description
Sep 29, 2023
32188d5
fix: resolve conflict
Oct 2, 2023
02b56be
Merge branch 'master' of github.com:binary-com/deriv-app into evgeniy…
Oct 2, 2023
aa7bf7f
Merge branch 'master' of github.com:binary-com/deriv-app into evgeniy…
Oct 2, 2023
02b1e32
Merge branch 'master' of github.com:binary-com/deriv-app into evgeniy…
Oct 2, 2023
b247774
Merge branch 'master' of github.com:binary-com/deriv-app into evgeniy…
Oct 3, 2023
127a787
chore: bootstrap
Oct 3, 2023
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import React from 'react';
import { screen, render } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { isMobile, routes } from '@deriv/shared';
import LanguageSettings from '../language-settings';
import { mockStore, StoreProvider } from '@deriv/stores';

jest.mock('@deriv/shared', () => ({
...jest.requireActual('@deriv/shared'),
isMobile: jest.fn(() => false),
}));

jest.mock('@deriv/translations', () => ({
...jest.requireActual('@deriv/translations'),
getAllowedLanguages: jest.fn(() => ({ lang_1: 'Test Lang 1', lang_2: 'Test Lang 2' })),
}));

jest.mock('@deriv/components', () => ({
...jest.requireActual('@deriv/components'),
Icon: jest.fn(() => <div>Flag Icon</div>),
}));

jest.mock('react-i18next', () => ({
...jest.requireActual('react-i18next'),
useTranslation: jest.fn(() => ({ i18n: { changeLanguage: jest.fn() } })),
}));

jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
Redirect: jest.fn(() => <div>Redirect</div>),
}));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mock hell 😂


describe('LanguageSettings', () => {
const mockRootStore = mockStore({
common: {
current_language: 'lang_1',
},
});

const renderLanguageSettings = () => {
render(<LanguageSettings />, {
wrapper: ({ children }) => <StoreProvider store={mockRootStore}>{children}</StoreProvider>,
});
};

it('should render LanguageSettings', () => {
renderLanguageSettings();

expect(screen.getByText('Select Language')).toBeInTheDocument();

const flags_icons = screen.getAllByText('Flag Icon');
const lang_1 = screen.getByText('Test Lang 1');
const lang_2 = screen.getByText('Test Lang 2');

expect(flags_icons.length).toBe(2);
expect(lang_1).toBeInTheDocument();
expect(/(active)/i.test(lang_1.className)).toBeTruthy();
expect(lang_2).toBeInTheDocument();
expect(/(active)/i.test(lang_2.className)).toBeFalsy();
});

it('should trigger language change', () => {
renderLanguageSettings();

const lang_2 = screen.getByText('Test Lang 2');
userEvent.click(lang_2);

expect(mockRootStore.common.changeSelectedLanguage).toHaveBeenCalled();
});

it('should redirect for mobile', () => {
(isMobile as jest.Mock).mockReturnValue(true);
Object.defineProperty(window, 'location', {
configurable: true,
value: { pathname: routes.languages },
});

renderLanguageSettings();

expect(screen.queryByText('Select Language')).not.toBeInTheDocument();
expect(screen.getByText('Redirect')).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
@@ -1,68 +1,42 @@
import React from 'react';
import { Redirect } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import { Button, DesktopWrapper } from '@deriv/components';
import { localize, getAllowedLanguages } from '@deriv/translations';
import { isMobile, routes } from '@deriv/shared';
import { observer, useStore } from '@deriv/stores';
import FormSubHeader from 'Components/form-sub-header';
import { Formik, FormikHandlers, FormikHelpers, FormikValues } from 'formik';
import FormFooter from 'Components/form-footer';
import LanguageRadioButton from 'Components/language-settings';
import { observer, useStore } from '@deriv/stores';

const LanguageSettings = observer(() => {
const { common } = useStore();
const { changeSelectedLanguage, current_language, isCurrentLanguage } = common;
const { i18n } = useTranslation();
const { common } = useStore();
const { changeSelectedLanguage, current_language } = common;

if (window.location.pathname === routes.languages && isMobile()) {
yauheni-deriv marked this conversation as resolved.
Show resolved Hide resolved
return <Redirect to={routes.traders_hub} />;
}

const allowed_language_keys: string[] = Object.keys(getAllowedLanguages());
const initial_values = { language_code: current_language };
return (
<Formik
initialValues={initial_values}
onSubmit={async values => {
const { language_code } = values;
await changeSelectedLanguage(language_code);
await i18n.changeLanguage?.(language_code);
}}
>
{({ handleSubmit, setFieldValue, values }: FormikHandlers & FormikHelpers<FormikValues> & FormikValues) => {
return (
<form onSubmit={handleSubmit} className='account-form account-form--language-settings'>
<div className='settings-language'>
<DesktopWrapper>
<FormSubHeader title={localize('Select Language')} />
</DesktopWrapper>
<div className='settings-language__language-container'>
{allowed_language_keys.map(language_key => {
return (
<LanguageRadioButton
key={language_key}
id={language_key}
language_code={language_key}
is_current_language={values.language_code === language_key}
name='language-radio-group'
onChange={(event: React.ChangeEvent<HTMLInputElement>) =>
setFieldValue('language_code', event.target.value)
}
/>
);
})}
</div>
</div>
<FormFooter>
<Button
className='account-form__footer-btn'
type='submit'
data-testid={'submit-button'}
has_effect
text={localize('Submit')}
large
primary
is_disabled={isCurrentLanguage(values.language_code)}
/>
</FormFooter>
</form>
);
}}
</Formik>
<div className='settings-language'>
<FormSubHeader title={localize('Select Language')} />
<div className='settings-language__language-container'>
{allowed_language_keys.map(language_key => {
return (
<LanguageRadioButton
key={language_key}
id={language_key}
language_code={language_key}
is_current_language={current_language === language_key}
name='language-radio-group'
onChange={() => {
changeSelectedLanguage(language_key);
}}
/>
);
})}
</div>
</div>
yauheni-deriv marked this conversation as resolved.
Show resolved Hide resolved
);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type TMobileDrawerSubmenu = {
submenu_icon?: string;
submenu_title?: string | React.ReactElement;
submenu_suffix_icon?: string;
route_config_path: string;
route_config_path?: string;
};

const SubMenu = ({
Expand Down Expand Up @@ -43,7 +43,9 @@ const SubMenu = ({
<Text
as='h3'
size='xs'
weight={window.location.pathname.startsWith(route_config_path) ? 'bold' : ''}
weight={
route_config_path && window.location.pathname.startsWith(route_config_path) ? 'bold' : ''
}
>
{submenu_title}
</Text>
Expand Down
1 change: 1 addition & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
"@deriv/shared": "^1.0.0",
"@deriv/trader": "^3.8.0",
"@deriv/translations": "^1.0.0",
"@deriv/utils": "^1.0.0",
"@livechat/customer-sdk": "^2.0.4",
"acorn": "^6.1.1",
"babel-polyfill": "^6.26.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import MenuTitle from './menu-title';
import MobileLanguageMenu from './mobile-language-menu';

export { MenuTitle, MobileLanguageMenu };
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import React from 'react';
import { observer, useStore } from '@deriv/stores';
import { Icon, Text } from '@deriv/components';
import { localize, Localize } from '@deriv/translations';

const MenuTitle = observer(() => {
const { common, ui } = useStore();
const { current_language } = common;
const { is_mobile_language_menu_open, setMobileLanguageMenuOpen } = ui;
return (
<React.Fragment>
<div>{localize('Menu')}</div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use Localize component instead of localize function inside your component! ( this is really important, our components need to be attached to react life cycle, so basically using localize in most of places are not quite ok.

Suggested change
<div>{localize('Menu')}</div>
<div>
<Localize i18n_default_text='Menu' />
</div>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@niloofar-deriv What's the reason behind it? 🤔 Do they behave differently? 🤔

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Michio suggested this when we were refactoring the deriv.com's translations

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@niloofar-deriv The script for extracting strings in deriv-com is different 👀

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the rules of React are the same 👀

Anyways we can ignore this comment 🙏

<div
className='settings-language__language-button_wrapper'
onClick={() => {
if (!is_mobile_language_menu_open) {
setMobileLanguageMenuOpen(true);
}
}}
>
{!is_mobile_language_menu_open && (
<React.Fragment>
<Icon
icon={`IcFlag${current_language.replace('_', '-')}`}
data_testid='dt_icon'
className='ic-settings-language__icon'
size={22}
/>
<Text weight='bold' size='xxs'>
<Localize i18n_default_text={current_language} />
</Text>
</React.Fragment>
)}
</div>
</React.Fragment>
);
});

export default MenuTitle;
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import classNames from 'classnames';
import React from 'react';
import { MobileDrawer } from '@deriv/components';
import { observer, useStore } from '@deriv/stores';
import { getAllowedLanguages, localize } from '@deriv/translations';
import { LanguageLink } from 'App/Components/Routes';

type TMobileLanguageMenu = {
expandSubMenu: (prop: boolean) => void;
toggleDrawer: () => void;
};

const MobileLanguageMenu = observer(({ expandSubMenu, toggleDrawer }: TMobileLanguageMenu) => {
const { common, ui } = useStore();
const { is_language_changing } = common;
const { is_mobile_language_menu_open, setMobileLanguageMenuOpen } = ui;
return (
<MobileDrawer.SubMenu
is_expanded={is_mobile_language_menu_open}
has_subheader
submenu_title={localize('Language')}
onToggle={is_expanded => {
expandSubMenu(is_expanded);
setMobileLanguageMenuOpen(false);
}}
submenu_toggle_class='dc-mobile-drawer__submenu-toggle--hidden'
>
<div
className={classNames('settings-language__language-container', {
'settings-language__language-container--disabled': is_language_changing,
})}
>
{Object.keys(getAllowedLanguages()).map(lang => (
<LanguageLink
key={lang}
icon_classname='settings-language__language-flag'
is_clickable
lang={lang}
toggleModal={() => {
toggleDrawer();
setMobileLanguageMenuOpen(false);
}}
/>
))}
</div>
</MobileDrawer.SubMenu>
);
});

export default MobileLanguageMenu;
Loading