Skip to content

Commit

Permalink
Merge pull request #640 from idurar/dev
Browse files Browse the repository at this point in the history
3.0.0-beta.1
  • Loading branch information
salahlalami authored Nov 2, 2023
2 parents c7f1429 + e26f478 commit 928b769
Show file tree
Hide file tree
Showing 13 changed files with 362 additions and 92 deletions.
1 change: 1 addition & 0 deletions frontend/src/components/AutoCompleteAsync/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export default function AutoCompleteAsync({
onClear={() => {
setOptions([]);
setCurrentValue(undefined);
setSearching(false);
}}
>
{selectOptions.map((optionField) => (
Expand Down
9 changes: 0 additions & 9 deletions frontend/src/layout/ErpContextLayout/index.jsx

This file was deleted.

34 changes: 15 additions & 19 deletions frontend/src/layout/ErpLayout/index.jsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
import React from 'react';

import ErpContextLayout from '../ErpContextLayout';
import { ErpContextProvider } from '@/context/erp';

import { Layout } from 'antd';

const { Content } = Layout;

export default function ErpLayout({ children, config }) {
export default function ErpLayout({ children }) {
return (
<ErpContextLayout>
<Layout className="site-layout">
<Content
className="whiteBox shadow layoutPadding"
style={{
margin: '30px auto',
width: '100%',
maxWidth: '1100px',
minHeight: '600px',
}}
>
{children}
</Content>
</Layout>
</ErpContextLayout>
<ErpContextProvider>
<Content
className="whiteBox shadow layoutPadding"
style={{
margin: '30px auto',
width: '100%',
maxWidth: '1100px',
minHeight: '600px',
}}
>
{children}
</Content>
</ErpContextProvider>
);
}
42 changes: 12 additions & 30 deletions frontend/src/locale/Localization.jsx
Original file line number Diff line number Diff line change
@@ -1,44 +1,26 @@
import { useState, useEffect } from 'react';

import enUS from 'antd/es/locale/en_US';
import zhCN from 'antd/es/locale/zh_CN';
import frFR from 'antd/es/locale/fr_FR';
import arEG from 'antd/es/locale/ar_EG';
import roRO from 'antd/es/locale/ro_RO';

import { ConfigProvider } from 'antd';

import { useSelector } from 'react-redux';

import { selectLangCode } from '@/redux/translate/selectors';
import { selectLangState } from '@/redux/translate/selectors';

const importLangFile = async () => {
return await import('./antdLocale');
};

export default function Localization({ children }) {
const langCode = useSelector(selectLangCode);
const { langCode, langDirection } = useSelector(selectLangState);

const [locale, setLocal] = useState(enUS);
const [direction, setDirection] = useState('ltr');
const [locale, setLocal] = useState();
const [direction, setDirection] = useState();

useEffect(() => {
if (langCode === 'fr_fr') {
setDirection('ltr');
setLocal(frFR);
} else if (langCode === 'zh_cn') {
setDirection('ltr');
setLocal(zhCN);
} else if (langCode === 'ro_ro') {
setDirection('ltr');
setLocal(roRO);
} else if (langCode === 'ar_eg') {
setDirection('rtl');
setLocal(arEG);
} else {
setDirection('ltr');
setLocal(enUS);
}

return () => {
return false;
};
const antdLocale = importLangFile();
const lang = antdLocale[langCode];
setDirection(langDirection);
setLocal(lang);
}, [langCode]);

return (
Expand Down
15 changes: 15 additions & 0 deletions frontend/src/locale/antdLocale.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import frFR from 'antd/es/locale/fr_FR';
import arEG from 'antd/es/locale/ar_EG';
import zhCN from 'antd/es/locale/zh_CN';
import roRO from 'antd/es/locale/ro_RO';
import itIT from 'antd/es/locale/it_IT';

const antdLocale = {
zh_cn: zhCN,
fr_fr: frFR,
ar_eg: arEG,
ro_ro: roRO,
it_it: itIT,
};

export default antdLocale;
2 changes: 1 addition & 1 deletion frontend/src/locale/languages.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const languages = [
{ icon: '🇨🇳 ', label: 'Chinese', value: 'zh_cn' },
{ icon: '🇺🇸 ', label: 'English', value: 'en_us' },
{ icon: '🇫🇷 ', label: 'French', value: 'fr_fr' },
{ icon: '🇮🇹 ', label: 'Italian', value: 'it_it' },
{ icon: '🇷🇴 ', label: 'Romanian', value: 'ro_ro' },
{ icon: '🇦🇱 ', label: 'Albanian (coming soon)', value: 'sq_al', disabled: true },
{ icon: '🇧🇩 ', label: 'Bengali (coming soon)', value: 'bn_bd', disabled: true },
Expand All @@ -20,7 +21,6 @@ const languages = [
{ icon: '🇮🇳 ', label: 'Hindi (coming soon)', value: 'hi_in', disabled: true },
{ icon: '🇭🇺 ', label: 'Hungarian (coming soon)', value: 'hu_hu', disabled: true },
{ icon: '🇮🇩 ', label: 'Indonesian (coming soon)', value: 'id_id', disabled: true },
{ icon: '🇮🇹 ', label: 'Italian (coming soon)', value: 'it_it', disabled: true },
{ icon: '🇯🇵 ', label: 'Japanese (coming soon)', value: 'ja_jp', disabled: true },
{ icon: '🇰🇷 ', label: 'Korean (coming soon)', value: 'ko_kr', disabled: true },
{ icon: '🇱🇻 ', label: 'Latvian (coming soon)', value: 'lv_lv', disabled: true },
Expand Down
17 changes: 17 additions & 0 deletions frontend/src/locale/translation/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import en_us from './en_us';
import fr_fr from './fr_fr';
import zh_cn from './zh_cn';
import ar_eg from './ar_eg';
import it_it from './it_it';
import ro_ro from './ro_ro';

const languages = {
ar_eg,
en_us,
fr_fr,
zh_cn,
it_it,
ro_ro,
};

export default languages;
Loading

0 comments on commit 928b769

Please sign in to comment.