diff --git a/src/components/layouts/AppLayout.spec.tsx b/src/components/layouts/AppLayout.spec.tsx
index 42e7534..f3507eb 100644
--- a/src/components/layouts/AppLayout.spec.tsx
+++ b/src/components/layouts/AppLayout.spec.tsx
@@ -46,9 +46,9 @@ describe('AppLayout component', () => {
expect(getByText("Let's get started!")).toBeInTheDocument();
fireEvent.mouseEnter(getByText('English'));
fireEvent.click(await findByText('Español (es-ES)'));
- expect(getByText('¡Empecemos!')).toBeInTheDocument();
+ expect(await findByText('¡Empecemos!')).toBeInTheDocument();
fireEvent.click(getByText('English (en-US)'));
- expect(getByText("Let's get started!")).toBeInTheDocument();
+ expect(await findByText("Let's get started!")).toBeInTheDocument();
});
it('should set language to Spanish', async () => {
@@ -56,7 +56,7 @@ describe('AppLayout component', () => {
expect(getByText("Let's get started!")).toBeInTheDocument();
fireEvent.mouseEnter(getByText('English'));
fireEvent.click(await findByText('Español (es-ES)'));
- expect(getByText('¡Empecemos!')).toBeInTheDocument();
+ expect(await findByText('¡Empecemos!')).toBeInTheDocument();
});
});
});
diff --git a/src/components/layouts/LocaleSwitch.tsx b/src/components/layouts/LocaleSwitch.tsx
index 9a3ebcb..3be57ed 100644
--- a/src/components/layouts/LocaleSwitch.tsx
+++ b/src/components/layouts/LocaleSwitch.tsx
@@ -1,9 +1,10 @@
import React from 'react';
-import { useTranslation } from 'react-i18next';
import styled from '@emotion/styled';
import { Button, Dropdown, Icon, Menu } from 'antd';
import { ClickParam } from 'antd/lib/menu';
+import { useStoreState } from 'easy-peasy';
import { localeConfig } from 'i18n';
+import { useStoreActions } from 'store';
const Styled = {
Button: styled(Button)`
@@ -12,13 +13,14 @@ const Styled = {
};
const LocaleSwitch: React.FC = () => {
- const { i18n } = useTranslation();
+ const { settings } = useStoreState(s => s.app);
+ const { updateSettings } = useStoreActions(s => s.app);
const changeLanguage = (e: ClickParam) => {
- i18n.changeLanguage(e.key);
+ updateSettings({ lang: e.key });
};
const menu = (
-