WIP: Arabic localization.|

This commit is contained in:
a.bouhuolia
2021-06-10 12:51:00 +02:00
parent 4fc7c37260
commit 1ea32884c2
465 changed files with 3299 additions and 2109 deletions

View File

@@ -27,6 +27,8 @@ const typescriptFormatter = require('react-dev-utils/typescriptFormatter');
const CompressionPlugin = require("compression-webpack-plugin"); const CompressionPlugin = require("compression-webpack-plugin");
const postcssNormalize = require('postcss-normalize'); const postcssNormalize = require('postcss-normalize');
const { postcssRTLCSS} = require('postcss-rtlcss');
const appPackageJson = require(paths.appPackageJson); const appPackageJson = require(paths.appPackageJson);
@@ -92,6 +94,14 @@ module.exports = function(webpackEnv) {
// https://github.com/facebook/create-react-app/issues/2677 // https://github.com/facebook/create-react-app/issues/2677
ident: 'postcss', ident: 'postcss',
plugins: () => [ plugins: () => [
// Postcss rtlcss plugin.
// require( 'postcss-rtl' )({
// // options here.
// removeComments: false,
// }),
postcssRTLCSS({
}),
require('postcss-flexbugs-fixes'), require('postcss-flexbugs-fixes'),
require('postcss-preset-env')({ require('postcss-preset-env')({
autoprefixer: { autoprefixer: {
@@ -103,11 +113,6 @@ module.exports = function(webpackEnv) {
// so that it honors browserslist config in package.json // so that it honors browserslist config in package.json
// which in turn let's users customize the target behavior as per their needs. // which in turn let's users customize the target behavior as per their needs.
postcssNormalize(), postcssNormalize(),
// Postcss rtlcss plugin.
require( 'postcss-rtl' )({
// options here.
}),
], ],
sourceMap: isEnvProduction && shouldUseSourceMap, sourceMap: isEnvProduction && shouldUseSourceMap,
}, },
@@ -125,6 +130,10 @@ module.exports = function(webpackEnv) {
loader: require.resolve(preProcessor), loader: require.resolve(preProcessor),
options: { options: {
sourceMap: true, sourceMap: true,
sassOptions: {
sourceComments: true,
outputStyle: 'expanded'
}
}, },
} }
); );

View File

@@ -74,6 +74,7 @@
"react-error-boundary": "^3.0.2", "react-error-boundary": "^3.0.2",
"react-hotkeys-hook": "^3.0.3", "react-hotkeys-hook": "^3.0.3",
"react-intl": "^3.12.0", "react-intl": "^3.12.0",
"react-intl-universal": "^2.4.7",
"react-loadable": "^5.5.0", "react-loadable": "^5.5.0",
"react-query": "^3.6.0", "react-query": "^3.6.0",
"react-redux": "^7.1.3", "react-redux": "^7.1.3",
@@ -94,6 +95,7 @@
"redux-thunk": "^2.3.0", "redux-thunk": "^2.3.0",
"resolve": "1.15.0", "resolve": "1.15.0",
"resolve-url-loader": "3.1.1", "resolve-url-loader": "3.1.1",
"rtl-detect": "^1.0.3",
"sass-loader": "8.0.2", "sass-loader": "8.0.2",
"semver": "6.3.0", "semver": "6.3.0",
"style-loader": "0.23.1", "style-loader": "0.23.1",
@@ -137,6 +139,7 @@
"@welldone-software/why-did-you-render": "^6.0.0-rc.1", "@welldone-software/why-did-you-render": "^6.0.0-rc.1",
"compression-webpack-plugin": "^6.1.0", "compression-webpack-plugin": "^6.1.0",
"http-proxy-middleware": "^1.0.0", "http-proxy-middleware": "^1.0.0",
"postcss-rtlcss": "^1.7.2",
"react-query-devtools": "^2.1.1", "react-query-devtools": "^2.1.1",
"redux-devtools": "^3.5.0", "redux-devtools": "^3.5.0",
"typescript": "^4.1.2" "typescript": "^4.1.2"

View File

@@ -1,7 +1,7 @@
import React from 'react'; import React from 'react';
import { formatMessage } from 'services/intl'; import intl from 'react-intl-universal';
export default [ export default [
{ name: formatMessage({ id: 'customer' }), path: 'customers' }, { name: intl.get('customer'), path: 'customers' },
{ name: formatMessage({ id: 'vendor' }), path: 'vendors' }, { name: intl.get('vendor'), path: 'vendors' },
]; ];

View File

@@ -1,88 +1,64 @@
import { formatMessage } from 'services/intl'; import intl from 'react-intl-universal';
export default [ export const getFiscalYearOptions = () => [
{ {
id: 0, id: 0,
name: `${formatMessage({ id: 'january' })} - ${formatMessage({ name: `${intl.get('january')} - ${intl.get('december')}`,
id: 'december',
})}`,
value: 'january', value: 'january',
}, },
{ {
id: 1, id: 1,
name: `${formatMessage({ id: 'february' })} - ${formatMessage({ name: `${intl.get('february')} - ${intl.get('january')}`,
id: 'january',
})}`,
value: 'february', value: 'february',
}, },
{ {
id: 2, id: 2,
name: `${formatMessage({ id: 'march' })} - ${formatMessage({ name: `${intl.get('march')} - ${intl.get('february')}`,
id: 'february',
})}`,
value: 'March', value: 'March',
}, },
{ {
id: 3, id: 3,
name: `${formatMessage({ id: 'april' })} - ${formatMessage({ name: `${intl.get('april')} - ${intl.get('march')}`,
id: 'march',
})}`,
value: 'april', value: 'april',
}, },
{ {
id: 4, id: 4,
name: `${formatMessage({ id: 'may' })} - ${formatMessage({ name: `${intl.get('may')} - ${intl.get('april')}`,
id: 'april',
})}`,
value: 'may', value: 'may',
}, },
{ {
id: 5, id: 5,
name: `${formatMessage({ id: 'june' })} - ${formatMessage({ name: `${intl.get('june')} - ${intl.get('may')}`,
id: 'may',
})}`,
value: 'june', value: 'june',
}, },
{ {
id: 6, id: 6,
name: `${formatMessage({ id: 'july' })} - ${formatMessage({ name: `${intl.get('july')} - ${intl.get('june')}`,
id: 'june',
})}`,
value: 'july', value: 'july',
}, },
{ {
id: 7, id: 7,
name: `${formatMessage({ id: 'august' })} - ${formatMessage({ name: `${intl.get('august')} - ${intl.get('july')}`,
id: 'july',
})}`,
value: 'August', value: 'August',
}, },
{ {
id: 8, id: 8,
name: `${formatMessage({ id: 'september' })} - ${formatMessage({ name: `${intl.get('september')} - ${intl.get('august')}`,
id: 'august',
})}`,
value: 'september', value: 'september',
}, },
{ {
id: 9, id: 9,
name: `${formatMessage({ id: 'october' })} - ${formatMessage({ name: `${intl.get('october')} - ${intl.get('november')}`,
id: 'november',
})}`,
value: 'october', value: 'october',
}, },
{ {
id: 10, id: 10,
name: `${formatMessage({ id: 'november' })} - ${formatMessage({ name: `${intl.get('november')} - ${intl.get('october')}`,
id: 'october',
})}`,
value: 'november', value: 'november',
}, },
{ {
id: 11, id: 11,
name: `${formatMessage({ id: 'december' })} - ${formatMessage({ name: `${intl.get('december')} - ${intl.get('november')}`,
id: 'november',
})}`,
value: 'december', value: 'december',
}, },
] ]

View File

@@ -1,5 +1,5 @@
import React from 'react'; import React from 'react';
import { FormattedMessage as T } from 'react-intl'; import { FormattedMessage as T } from 'components';
export const accountsReceivable = [ export const accountsReceivable = [
{ {
@@ -21,12 +21,12 @@ export const accountsReceivable = [
link: '/receipts', link: '/receipts',
}, },
{ {
title: <T id={'Customers'} />, title: <T id={'customers'} />,
description: <T id={'manage_the_customers_relations_with_customer'} />, description: <T id={'manage_the_customers_relations_with_customer'} />,
link: '/customers', link: '/customers',
}, },
{ {
title: <T id={'customers_payment'} />, title: <T id={'customers_payments'} />,
description: ( description: (
<T id={'manage_payment_transactions_from_your_customers'} /> <T id={'manage_payment_transactions_from_your_customers'} />
), ),

View File

@@ -1,105 +1,105 @@
import React from 'react'; import React from 'react';
import { formatMessage } from 'services/intl'; import intl from 'react-intl-universal';
export default [ export default [
{ {
shortcut_key: 'Shift + I', shortcut_key: 'Shift + I',
description: formatMessage({ id: 'jump_to_the_invoices' }), description: intl.get('jump_to_the_invoices'),
}, },
{ {
shortcut_key: 'Shift + E', shortcut_key: 'Shift + E',
description: formatMessage({ id: 'jump_to_the_estimates' }), description: intl.get('jump_to_the_estimates'),
}, },
{ {
shortcut_key: 'Shift + R', shortcut_key: 'Shift + R',
description: formatMessage({ id: 'jump_to_the_receipts' }), description: intl.get('jump_to_the_receipts'),
}, },
{ {
shortcut_key: 'Shift + X', shortcut_key: 'Shift + X',
description: formatMessage({ id: 'jump_to_the_expenses' }), description: intl.get('jump_to_the_expenses'),
}, },
{ {
shortcut_key: 'Shift + C', shortcut_key: 'Shift + C',
description: formatMessage({ id: 'jump_to_the_customers' }), description: intl.get('jump_to_the_customers'),
}, },
{ {
shortcut_key: 'Shift + V', shortcut_key: 'Shift + V',
description: formatMessage({ id: 'jump_to_the_vendors' }), description: intl.get('jump_to_the_vendors'),
}, },
{ {
shortcut_key: 'Shift + A', shortcut_key: 'Shift + A',
description: formatMessage({ id: 'jump_to_the_chart_of_accounts' }), description: intl.get('jump_to_the_chart_of_accounts'),
}, },
{ {
shortcut_key: 'Shift + B', shortcut_key: 'Shift + B',
description: formatMessage({ id: 'jump_to_the_bills' }), description: intl.get('jump_to_the_bills'),
}, },
{ {
shortcut_key: 'Shift + M', shortcut_key: 'Shift + M',
description: formatMessage({ id: 'jump_to_the_manual_journals' }), description: intl.get('jump_to_the_manual_journals'),
}, },
{ {
shortcut_key: 'Shift + W', shortcut_key: 'Shift + W',
description: formatMessage({ id: 'jump_to_the_items' }), description: intl.get('jump_to_the_items'),
}, },
{ {
shortcut_key: 'Shift + 1', shortcut_key: 'Shift + 1',
description: formatMessage({ id: 'jump_to_the_balance_sheet' }), description: intl.get('jump_to_the_balance_sheet'),
}, },
{ {
shortcut_key: 'Shift + 2', shortcut_key: 'Shift + 2',
description: formatMessage({ id: 'jump_to_the_profit_loss_sheet' }), description: intl.get('jump_to_the_profit_loss_sheet'),
}, },
{ {
shortcut_key: 'Shift + 3', shortcut_key: 'Shift + 3',
description: formatMessage({ id: 'jump_to_the_journal_sheet' }), description: intl.get('jump_to_the_journal_sheet'),
}, },
{ {
shortcut_key: 'Shift + 4', shortcut_key: 'Shift + 4',
description: formatMessage({ id: 'jump_to_the_general_ledger_sheet' }), description: intl.get('jump_to_the_general_ledger_sheet'),
}, },
{ {
shortcut_key: 'Shift + 5', shortcut_key: 'Shift + 5',
description: formatMessage({ id: 'jump_to_the_trial_balance_sheet' }), description: intl.get('jump_to_the_trial_balance_sheet'),
}, },
{ {
shortcut_key: 'Ctrl + Shift + I ', shortcut_key: 'Ctrl + Shift + I ',
description: formatMessage({ id: 'create_a_new_invoice' }), description: intl.get('create_a_new_invoice'),
}, },
{ {
shortcut_key: 'Ctrl + Shift + E ', shortcut_key: 'Ctrl + Shift + E ',
description: formatMessage({ id: 'create_a_new_estimate' }), description: intl.get('create_a_new_estimate'),
}, },
{ {
shortcut_key: 'Ctrl + Shift + R ', shortcut_key: 'Ctrl + Shift + R ',
description: formatMessage({ id: 'create_a_new_receipt' }), description: intl.get('create_a_new_receipt'),
}, },
{ {
shortcut_key: 'Ctrl + Shift + X ', shortcut_key: 'Ctrl + Shift + X ',
description: formatMessage({ id: 'create_a_new_expense' }), description: intl.get('create_a_new_expense'),
}, },
{ {
shortcut_key: 'Ctrl + Shift + C ', shortcut_key: 'Ctrl + Shift + C ',
description: formatMessage({ id: 'create_a_new_customer' }), description: intl.get('create_a_new_customer'),
}, },
{ {
shortcut_key: 'Ctrl + Shift + V ', shortcut_key: 'Ctrl + Shift + V ',
description: formatMessage({ id: 'create_a_new_vendor' }), description: intl.get('create_a_new_vendor'),
}, },
{ {
shortcut_key: 'Ctrl + Shift + B ', shortcut_key: 'Ctrl + Shift + B ',
description: formatMessage({ id: 'create_a_new_bill' }), description: intl.get('create_a_new_bill'),
}, },
{ {
shortcut_key: 'Ctrl + Shift + M ', shortcut_key: 'Ctrl + Shift + M ',
description: formatMessage({ id: 'create_a_new_make_journal' }), description: intl.get('create_a_new_make_journal'),
}, },
{ {
shortcut_key: 'Ctrl + Shift + W ', shortcut_key: 'Ctrl + Shift + W ',
description: formatMessage({ id: 'create_a_new_item' }), description: intl.get('create_a_new_item'),
}, },
{ {
shortcut_key: 'Ctrl + / ', shortcut_key: 'Ctrl + / ',
description: formatMessage({ id: 'close_and_open_sidebar' }), description: intl.get('close_and_open_sidebar'),
}, },
]; ];

View File

@@ -1,11 +1,10 @@
import React from 'react'; import intl from 'react-intl-universal';
import { formatMessage } from 'services/intl';
export default [ export const getQuickNewActions = () => [
{ path: 'invoices/new', name: formatMessage({ id: 'sale_invoice' }) }, { path: 'invoices/new', name: intl.get('sale_invoice') },
{ path: 'bills//new', name: formatMessage({ id: 'purchase_invoice' }) }, { path: 'bills//new', name: intl.get('purchase_invoice') },
{ path: 'make-journal-entry', name: formatMessage({ id: 'manual_journal' }) }, { path: 'make-journal-entry', name: intl.get('manual_journal') },
{ path: 'expenses/new', name: formatMessage({ id: 'expense' }) }, { path: 'expenses/new', name: intl.get('expense') },
{ path: 'customers/new', name: formatMessage({ id: 'customer' }) }, { path: 'customers/new', name: intl.get('customer') },
{ path: 'vendors/new', name: formatMessage({ id: 'vendor' }) }, { path: 'vendors/new', name: intl.get('vendor') },
]; ];

View File

@@ -2,7 +2,7 @@ import React, { useMemo, useCallback, useState } from 'react';
import { omit } from 'lodash'; import { omit } from 'lodash';
import { MenuItem, Button } from '@blueprintjs/core'; import { MenuItem, Button } from '@blueprintjs/core';
import MultiSelect from 'components/MultiSelect'; import MultiSelect from 'components/MultiSelect';
import { FormattedMessage as T } from 'react-intl'; import { FormattedMessage as T } from 'components';
export default function AccountsMultiSelect({ accounts, onAccountSelected }) { export default function AccountsMultiSelect({ accounts, onAccountSelected }) {
const [selectedAccounts, setSelectedAccounts] = useState({}); const [selectedAccounts, setSelectedAccounts] = useState({});

View File

@@ -1,7 +1,7 @@
import React, { useCallback, useState, useEffect, useMemo } from 'react'; import React, { useCallback, useState, useEffect, useMemo } from 'react';
import { MenuItem, Button } from '@blueprintjs/core'; import { MenuItem, Button } from '@blueprintjs/core';
import { Select } from '@blueprintjs/select'; import { Select } from '@blueprintjs/select';
import { FormattedMessage as T } from 'react-intl'; import { FormattedMessage as T } from 'components';
import classNames from 'classnames'; import classNames from 'classnames';
import { filterAccountsByQuery } from './utils'; import { filterAccountsByQuery } from './utils';
import { CLASSES } from 'common/classes'; import { CLASSES } from 'common/classes';

View File

@@ -5,7 +5,7 @@ import { Suggest } from '@blueprintjs/select';
import classNames from 'classnames'; import classNames from 'classnames';
import { CLASSES } from 'common/classes'; import { CLASSES } from 'common/classes';
import { FormattedMessage as T } from 'react-intl'; import { FormattedMessage as T } from 'components';
import { filterAccountsByQuery } from './utils'; import { filterAccountsByQuery } from './utils';
/** /**

View File

@@ -1,5 +1,4 @@
import React from 'react'; import React from 'react';
import { RawIntlProvider } from 'react-intl';
import { Router, Switch, Route } from 'react-router'; import { Router, Switch, Route } from 'react-router';
import { createBrowserHistory } from 'history'; import { createBrowserHistory } from 'history';
import { QueryClientProvider, QueryClient } from 'react-query'; import { QueryClientProvider, QueryClient } from 'react-query';
@@ -7,47 +6,60 @@ import { ReactQueryDevtools } from 'react-query/devtools';
import 'style/App.scss'; import 'style/App.scss';
import AppIntlLoader from './AppIntlLoader';
import PrivateRoute from 'components/Guards/PrivateRoute'; import PrivateRoute from 'components/Guards/PrivateRoute';
import Authentication from 'components/Authentication';
import DashboardPrivatePages from 'components/Dashboard/PrivatePages';
import GlobalErrors from 'containers/GlobalErrors/GlobalErrors'; import GlobalErrors from 'containers/GlobalErrors/GlobalErrors';
import intl from 'services/intl'; import DashboardPrivatePages from 'components/Dashboard/PrivatePages';
import Authentication from 'components/Authentication';
// Query client config.
const queryConfig = {
defaultOptions: {
queries: {
refetchOnWindowFocus: true,
staleTime: 30000,
},
},
};
// Global fetch query.
function GlobalFetchQuery({
children
}) {
window.localStorage.setItem('lang', 'en');
return children
}
/**
* Core application.
*/
function App({ locale }) { function App({ locale }) {
const history = createBrowserHistory(); const history = createBrowserHistory();
const queryConfig = { // Query client.
defaultOptions: {
queries: {
refetchOnWindowFocus: true,
staleTime: 30000,
},
},
};
const queryClient = new QueryClient(queryConfig); const queryClient = new QueryClient(queryConfig);
return ( return (
<RawIntlProvider value={intl}> <QueryClientProvider client={queryClient}>
<QueryClientProvider client={queryClient}> <GlobalFetchQuery>
<div className="App"> <AppIntlLoader>
<Router history={history}> <div className="App">
<Switch> <Router history={history}>
<Route path={'/auth'}> <Switch>
<Authentication /> <Route path={'/auth'} component={Authentication} />
</Route> <Route path={'/'}>
<PrivateRoute component={DashboardPrivatePages} />
</Route>
</Switch>
</Router>
<Route path={'/'}> <GlobalErrors />
<PrivateRoute component={DashboardPrivatePages} /> </div>
</Route> </AppIntlLoader>
</Switch> </GlobalFetchQuery>
</Router>
<GlobalErrors /> <ReactQueryDevtools initialIsOpen />
</div> </QueryClientProvider>
<ReactQueryDevtools initialIsOpen />
</QueryClientProvider>
</RawIntlProvider>
); );
} }

View File

@@ -0,0 +1,80 @@
import React from 'react';
import intl from 'react-intl-universal';
import { find } from 'lodash';
import rtlDetect from 'rtl-detect';
import DashboardLoadingIndicator from 'components/Dashboard/DashboardLoadingIndicator';
const SUPPORTED_LOCALES = [
{ name: "English", value: "en" },
{ name: 'العربية', value: 'ar' }
];
/**
* Retrieve the current local.
*/
function getCurrentLocal() {
let currentLocale = intl.determineLocale({
urlLocaleKey: "lang",
cookieLocaleKey: "lang",
localStorageLocaleKey: "lang",
});
if (!find(SUPPORTED_LOCALES, { value: currentLocale })) {
currentLocale = "en";
}
return currentLocale;
}
/**
* Loads the localization data of the given locale.
*/
function loadLocales(currentLocale) {
return import(`../lang/${currentLocale}/index.json`);
}
/**
* Modifies the html document direction to RTl if it was rtl-language.
*/
function useDocumentDirectionModifier(locale) {
React.useEffect(() => {
const isRTL = rtlDetect.isRtlLang(locale);
if (isRTL) {
const htmlDocument = document.querySelector('html');
htmlDocument.setAttribute('dir', 'rtl');
htmlDocument.setAttribute('lang', locale);
}
}, []);
}
/**
* Application Intl loader.
*/
export default function AppIntlLoader({
children
}) {
const [isLoading, setIsLoading] = React.useState(true);
const currentLocale = getCurrentLocal();
// Modifies the html document direction
useDocumentDirectionModifier(currentLocale);
React.useEffect(() => {
// Lodas the locales data file.
loadLocales(currentLocale).then((results) => {
return intl.init({
currentLocale,
locales: {
[currentLocale]: results,
},
});
}).then(() => {
setIsLoading(false);
});
}, [currentLocale, setIsLoading]);
return (
<DashboardLoadingIndicator isLoading={isLoading}>
{children}
</DashboardLoadingIndicator>
);
}

View File

@@ -3,7 +3,7 @@ import { Redirect, Route, Switch, Link, useLocation } from 'react-router-dom';
import BodyClassName from 'react-body-classname'; import BodyClassName from 'react-body-classname';
import { TransitionGroup, CSSTransition } from 'react-transition-group'; import { TransitionGroup, CSSTransition } from 'react-transition-group';
import authenticationRoutes from 'routes/authentication'; import authenticationRoutes from 'routes/authentication';
import { FormattedMessage as T } from 'react-intl'; import { FormattedMessage as T } from 'components';
import Icon from 'components/Icon'; import Icon from 'components/Icon';
import { useIsAuthenticated } from 'hooks/state'; import { useIsAuthenticated } from 'hooks/state';
@@ -32,6 +32,7 @@ export default function AuthenticationWrapper({ ...rest }) {
> >
<T id={'go_to_bigcapital_com'} /> <T id={'go_to_bigcapital_com'} />
</a> </a>
<div class="authentication-page__form-wrapper"> <div class="authentication-page__form-wrapper">
<div class="authentication-insider"> <div class="authentication-insider">
<div className={'authentication-insider__logo-section'}> <div className={'authentication-insider__logo-section'}>

View File

@@ -1,5 +1,5 @@
import React, { useCallback } from 'react'; import React, { useCallback } from 'react';
import { FormattedMessage as T } from 'react-intl'; import { FormattedMessage as T } from 'components';
import { ListSelect } from 'components'; import { ListSelect } from 'components';
import { MenuItem } from '@blueprintjs/core'; import { MenuItem } from '@blueprintjs/core';
import { saveInvoke } from 'utils'; import { saveInvoke } from 'utils';

View File

@@ -1,5 +1,5 @@
import React, { useCallback, useState, useEffect, useMemo } from 'react'; import React, { useCallback, useState, useEffect, useMemo } from 'react';
import { FormattedMessage as T } from 'react-intl'; import { FormattedMessage as T } from 'components';
import { MenuItem, Button } from '@blueprintjs/core'; import { MenuItem, Button } from '@blueprintjs/core';
import { Select } from '@blueprintjs/select'; import { Select } from '@blueprintjs/select';
import classNames from 'classnames'; import classNames from 'classnames';

View File

@@ -2,7 +2,7 @@ import React, { useMemo, useCallback, useState } from 'react';
import { MenuItem, Button } from '@blueprintjs/core'; import { MenuItem, Button } from '@blueprintjs/core';
import { omit } from 'lodash'; import { omit } from 'lodash';
import MultiSelect from 'components/MultiSelect'; import MultiSelect from 'components/MultiSelect';
import { FormattedMessage as T } from 'react-intl'; import { FormattedMessage as T } from 'components';
export default function ContactsMultiSelect({ export default function ContactsMultiSelect({
contacts, contacts,

View File

@@ -2,16 +2,16 @@ import React, { useCallback, useState, useEffect, useMemo } from 'react';
import { MenuItem } from '@blueprintjs/core'; import { MenuItem } from '@blueprintjs/core';
import { Suggest } from '@blueprintjs/select'; import { Suggest } from '@blueprintjs/select';
import { FormattedMessage as T } from 'react-intl'; import { FormattedMessage as T } from 'components';
import classNames from 'classnames'; import classNames from 'classnames';
import { CLASSES } from 'common/classes'; import { CLASSES } from 'common/classes';
import { formatMessage } from 'services/intl'; import intl from 'react-intl-universal';
export default function ContactsSuggestField({ export default function ContactsSuggestField({
contactsList, contactsList,
initialContactId, initialContactId,
selectedContactId, selectedContactId,
defaultTextSelect = formatMessage({id:'select_contact'}), defaultTextSelect = intl.get('select_contact'),
onContactSelected, onContactSelected,
selectedContactType = [], selectedContactType = [],

View File

@@ -1,5 +1,5 @@
import React, { useCallback, useEffect, useState } from 'react'; import React, { useCallback, useEffect, useState } from 'react';
import { FormattedMessage as T } from 'react-intl'; import { FormattedMessage as T } from 'components';
import { CLASSES } from 'common/classes'; import { CLASSES } from 'common/classes';
import classNames from 'classnames'; import classNames from 'classnames';
import { MenuItem, Button } from '@blueprintjs/core'; import { MenuItem, Button } from '@blueprintjs/core';

View File

@@ -30,7 +30,7 @@ export default function Dashboard() {
<Route path="/"> <Route path="/">
<DashboardSplitPane> <DashboardSplitPane>
<Sidebar /> <Sidebar />
<DashboardContent /> <DashboardContent />
</DashboardSplitPane> </DashboardSplitPane>
</Route> </Route>
</Switch> </Switch>

View File

@@ -9,7 +9,7 @@ import {
PopoverInteractionKind, PopoverInteractionKind,
Position, Position,
} from '@blueprintjs/core'; } from '@blueprintjs/core';
import { FormattedMessage as T } from 'react-intl'; import { FormattedMessage as T } from 'components';
import { Icon } from 'components'; import { Icon } from 'components';
/** /**

View File

@@ -1,9 +1,9 @@
import React from 'react'; import React from 'react';
import withBreadcrumbs from 'react-router-breadcrumbs-hoc'; import withBreadcrumbs from 'react-router-breadcrumbs-hoc';
import { useHistory } from 'react-router-dom'; import { useHistory } from 'react-router-dom';
import routes from 'routes/dashboard'; import { getDashboardRoutes } from 'routes/dashboard';
import { If, Icon } from 'components'; import { If, Icon } from 'components';
import { FormattedMessage as T } from 'react-intl'; import { FormattedMessage as T } from 'components';
import withDashboard from 'containers/Dashboard/withDashboard'; import withDashboard from 'containers/Dashboard/withDashboard';
import { compose } from 'utils'; import { compose } from 'utils';
@@ -32,7 +32,7 @@ function DashboardBackLink({ dashboardBackLink, breadcrumbs }) {
} }
export default compose( export default compose(
withBreadcrumbs(routes), withBreadcrumbs([]),
withDashboard(({ dashboardBackLink }) => ({ withDashboard(({ dashboardBackLink }) => ({
dashboardBackLink, dashboardBackLink,
})), })),

View File

@@ -6,7 +6,7 @@ import {
Boundary, Boundary,
} from '@blueprintjs/core'; } from '@blueprintjs/core';
import withBreadcrumbs from 'react-router-breadcrumbs-hoc'; import withBreadcrumbs from 'react-router-breadcrumbs-hoc';
import routes from 'routes/dashboard'; import { getDashboardRoutes } from 'routes/dashboard';
import { useHistory } from 'react-router-dom'; import { useHistory } from 'react-router-dom';
function DashboardBreadcrumbs({ breadcrumbs }){ function DashboardBreadcrumbs({ breadcrumbs }){
@@ -31,4 +31,4 @@ function DashboardBreadcrumbs({ breadcrumbs }){
) )
} }
export default withBreadcrumbs(routes)(DashboardBreadcrumbs) export default withBreadcrumbs([])(DashboardBreadcrumbs)

View File

@@ -1,12 +1,15 @@
import React from 'react'; import React from 'react';
import { Route, Switch } from 'react-router-dom'; import { Route, Switch } from 'react-router-dom';
import routes from 'routes/dashboard';
import { getDashboardRoutes } from 'routes/dashboard';
import DashboardPage from './DashboardPage'; import DashboardPage from './DashboardPage';
/** /**
* Dashboard content route. * Dashboard content route.
*/ */
export default function DashboardContentRoute() { export default function DashboardContentRoute() {
const routes = getDashboardRoutes();
return ( return (
<Route pathname="/"> <Route pathname="/">
<Switch> <Switch>

View File

@@ -9,7 +9,7 @@ import {
Tooltip, Tooltip,
Position, Position,
} from '@blueprintjs/core'; } from '@blueprintjs/core';
import { FormattedMessage as T } from 'react-intl'; import { FormattedMessage as T } from 'components';
import DashboardTopbarUser from 'components/Dashboard/TopbarUser'; import DashboardTopbarUser from 'components/Dashboard/TopbarUser';
import DashboardBreadcrumbs from 'components/Dashboard/DashboardBreadcrumbs'; import DashboardBreadcrumbs from 'components/Dashboard/DashboardBreadcrumbs';

View File

@@ -1,5 +1,5 @@
import React, { useRef, useState, useEffect } from 'react'; import React, { useRef, useState, useEffect } from 'react';
import { FormattedMessage as T } from 'react-intl'; import { FormattedMessage as T } from 'components';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { Button, Tabs, Tab, Tooltip, Position } from '@blueprintjs/core'; import { Button, Tabs, Tab, Tooltip, Position } from '@blueprintjs/core';
import { useHistory } from 'react-router'; import { useHistory } from 'react-router';

View File

@@ -1,7 +1,7 @@
import React from 'react'; import React from 'react';
import { useHotkeys } from 'react-hotkeys-hook'; import { useHotkeys } from 'react-hotkeys-hook';
import { useHistory } from 'react-router-dom'; import { useHistory } from 'react-router-dom';
import routes from 'routes/dashboard'; import { getDashboardRoutes } from 'routes/dashboard';
import withDashboardActions from 'containers/Dashboard/withDashboardActions'; import withDashboardActions from 'containers/Dashboard/withDashboardActions';
import { compose } from 'utils'; import { compose } from 'utils';
@@ -10,6 +10,7 @@ function GlobalHotkeys({
toggleSidebarExpend, toggleSidebarExpend,
}) { }) {
const history = useHistory(); const history = useHistory();
const routes = getDashboardRoutes();
const globalHotkeys = routes const globalHotkeys = routes
.filter(({ hotkey }) => hotkey) .filter(({ hotkey }) => hotkey)

View File

@@ -8,7 +8,7 @@ import {
Popover, Popover,
Position, Position,
} from '@blueprintjs/core'; } from '@blueprintjs/core';
import { FormattedMessage as T } from 'react-intl'; import { FormattedMessage as T } from 'components';
import { firstLettersArgs } from 'utils'; import { firstLettersArgs } from 'utils';
import { useAuthActions, useAuthUser } from 'hooks/state'; import { useAuthActions, useAuthUser } from 'hooks/state';

View File

@@ -10,7 +10,7 @@ import {
useAsyncDebounce, useAsyncDebounce,
} from 'react-table'; } from 'react-table';
import { useSticky } from 'react-table-sticky'; import { useSticky } from 'react-table-sticky';
import { formatMessage } from 'services/intl'; import intl from 'react-intl-universal';
import { useUpdateEffect } from 'hooks'; import { useUpdateEffect } from 'hooks';
import { saveInvoke } from 'utils'; import { saveInvoke } from 'utils';
@@ -209,6 +209,6 @@ DataTable.defaultProps = {
TablePaginationRenderer: TablePagination, TablePaginationRenderer: TablePagination,
TableNoResultsRowRenderer: TableNoResultsRow, TableNoResultsRowRenderer: TableNoResultsRow,
noResults: formatMessage({ id: 'there_is_no_results_in_the_table' }), noResults: '',
payload: {}, payload: {},
}; };

View File

@@ -4,7 +4,7 @@ import ItemsSuggestField from 'components/ItemsSuggestField';
import classNames from 'classnames'; import classNames from 'classnames';
import { FormGroup, Classes, Intent } from '@blueprintjs/core'; import { FormGroup, Classes, Intent } from '@blueprintjs/core';
import { formatMessage } from 'services/intl'; import intl from 'react-intl-universal';
import { useCellAutoFocus } from 'hooks'; import { useCellAutoFocus } from 'hooks';
@@ -41,7 +41,7 @@ export default function ItemsListCell({
purchasable={filterPurchasable} purchasable={filterPurchasable}
inputProps={{ inputProps={{
inputRef: (ref) => (fieldRef.current = ref), inputRef: (ref) => (fieldRef.current = ref),
placeholder: formatMessage({ id: 'enter_an_item' }), placeholder: intl.get('enter_an_item'),
}} }}
openOnKeyDown={true} openOnKeyDown={true}
blurOnSelectClose={false} blurOnSelectClose={false}

View File

@@ -46,6 +46,8 @@ export default function TableCell({
); );
} }
const isRTL = true;
return ( return (
<div <div
{...cell.getCellProps({ {...cell.getCellProps({
@@ -62,7 +64,7 @@ export default function TableCell({
'cell-inner', 'cell-inner',
)} )}
style={{ style={{
paddingLeft: [isRTL ? 'paddingRight' : 'paddingLeft']:
isExpandColumn && expandable isExpandColumn && expandable
? `${depth * expandColumnSpace}rem` ? `${depth * expandColumnSpace}rem`
: '', : '',

View File

@@ -1,4 +1,5 @@
import React, { useContext } from 'react'; import React, { useContext } from 'react';
import intl from 'react-intl-universal';
import TableContext from './TableContext'; import TableContext from './TableContext';
/** /**
@@ -6,12 +7,15 @@ import TableContext from './TableContext';
*/ */
export default function TableNoResultsRow() { export default function TableNoResultsRow() {
const { const {
props: { noResults } props: { noResults },
} = useContext(TableContext); } = useContext(TableContext);
const noResultText =
noResults || intl.get('there_is_no_results_in_the_table');
return ( return (
<div className={'tr no-results'}> <div className={'tr no-results'}>
<div class="td">{ noResults }</div> <div class="td">{noResultText}</div>
</div> </div>
); );
} }

View File

@@ -2,7 +2,7 @@ import React, { useState, useCallback, useEffect } from 'react';
import { useDropzone } from 'react-dropzone'; import { useDropzone } from 'react-dropzone';
import classNames from 'classnames'; import classNames from 'classnames';
import Icon from 'components/Icon'; import Icon from 'components/Icon';
import { formatMessage } from 'services/intl'; import intl from 'react-intl-universal';
// const initialFile: { // const initialFile: {
// file: ?File, // file: ?File,
@@ -12,7 +12,7 @@ import { formatMessage } from 'services/intl';
// }; // };
export default function Dropzone({ export default function Dropzone({
text = formatMessage({ id: 'drag_drop_files_here_or_click_here' }), text = intl.get('drag_drop_files_here_or_click_here'),
onDrop, onDrop,
initialFiles = [], initialFiles = [],
onDeleteFile, onDeleteFile,

View File

@@ -1,5 +1,5 @@
import React from 'react'; import React from 'react';
import { FormattedMessage as T } from 'react-intl'; import { FormattedMessage as T } from 'components';
import { Classes, Icon, H4, Button } from '@blueprintjs/core'; import { Classes, Icon, H4, Button } from '@blueprintjs/core';
import withDrawerActions from 'containers/Drawer/withDrawerActions'; import withDrawerActions from 'containers/Drawer/withDrawerActions';

View File

@@ -1,17 +1,15 @@
import React, { useMemo } from 'react'; import React, { useMemo } from 'react';
import { HTMLSelect, Classes } from '@blueprintjs/core'; import { HTMLSelect, Classes } from '@blueprintjs/core';
import { useIntl } from 'react-intl'; import intl from 'react-intl-universal';
import { getConditionTypeCompatators } from './DynamicFilterCompatators'; import { getConditionTypeCompatators } from './DynamicFilterCompatators';
export default function DynamicFilterCompatatorField({ export default function DynamicFilterCompatatorField({
dataType, dataType,
...restProps ...restProps
}) { }) {
const { formatMessage } = useIntl();
const options = useMemo( const options = useMemo(
() => getConditionTypeCompatators(dataType).map(comp => ({ () => getConditionTypeCompatators(dataType).map(comp => ({
value: comp.value, label: formatMessage({ id: comp.label_id }), value: comp.value, label: intl.get(comp.label_id),
})), })),
[dataType] [dataType]
); );

View File

@@ -10,7 +10,8 @@ import { connect } from 'react-redux';
import { useQuery } from 'react-query'; import { useQuery } from 'react-query';
import { DateInput } from '@blueprintjs/datetime'; import { DateInput } from '@blueprintjs/datetime';
import classNames from 'classnames'; import classNames from 'classnames';
import { FormattedMessage as T, useIntl } from 'react-intl'; import { FormattedMessage as T } from 'components';
import intl from 'react-intl-universal';
import { debounce } from 'lodash'; import { debounce } from 'lodash';
import moment from 'moment'; import moment from 'moment';
@@ -45,7 +46,7 @@ function DynamicFilterValueField({
onChange, onChange,
inputDebounceWait = 250, inputDebounceWait = 250,
}) { }) {
const { formatMessage } = useIntl();
const [localValue, setLocalValue] = useState(); const [localValue, setLocalValue] = useState();
// Makes `localValue` controlled mode from `value`. // Makes `localValue` controlled mode from `value`.
@@ -185,7 +186,7 @@ function DynamicFilterValueField({
<Choose.Otherwise> <Choose.Otherwise>
<InputGroup <InputGroup
placeholder={formatMessage({ id: 'value' })} placeholder={intl.get('value')}
onChange={handleInputChange} onChange={handleInputChange}
value={localValue} value={localValue}
/> />

View File

@@ -12,7 +12,8 @@ import { isEqual, last } from 'lodash';
import { usePrevious } from 'react-use'; import { usePrevious } from 'react-use';
import Icon from 'components/Icon'; import Icon from 'components/Icon';
import { checkRequiredProperties, uniqueMultiProps } from 'utils'; import { checkRequiredProperties, uniqueMultiProps } from 'utils';
import { FormattedMessage as T, useIntl } from 'react-intl'; import { FormattedMessage as T } from 'components';
import intl from 'react-intl-universal';
import { import {
DynamicFilterValueField, DynamicFilterValueField,
DynamicFilterCompatatorField, DynamicFilterCompatatorField,
@@ -41,7 +42,7 @@ export default function FilterDropdown({
initialCondition, initialCondition,
initialConditions, initialConditions,
}) { }) {
const { formatMessage } = useIntl();
// Fields key -> metadata table. // Fields key -> metadata table.
const fieldsKeyMapped = useMemo(() => const fieldsKeyMapped = useMemo(() =>
@@ -51,10 +52,10 @@ export default function FilterDropdown({
// Conditions options. // Conditions options.
const conditionalsOptions = useMemo( const conditionalsOptions = useMemo(
() => [ () => [
{ value: '&&', label: formatMessage({ id: 'and' }) }, { value: '&&', label: intl.get('and') },
{ value: '||', label: formatMessage({ id: 'or' }) }, { value: '||', label: intl.get('or') },
], ],
[formatMessage], [],
); );
// Resources fileds options for fields options. // Resources fileds options for fields options.
const resourceFieldsOptions = useMemo( const resourceFieldsOptions = useMemo(
@@ -91,7 +92,7 @@ export default function FilterDropdown({
if (values.conditions.length >= 12) { if (values.conditions.length >= 12) {
limitToast = Toaster.show( limitToast = Toaster.show(
{ {
message: formatMessage({ id: 'you_reached_conditions_limit' }), message: intl.get('you_reached_conditions_limit'),
intent: Intent.WARNING, intent: Intent.WARNING,
}, },
limitToast, limitToast,
@@ -102,7 +103,7 @@ export default function FilterDropdown({
defaultFilterCondition defaultFilterCondition
]); ]);
} }
}, [values, setFieldValue, formatMessage, defaultFilterCondition]); }, [values, setFieldValue, defaultFilterCondition]);
// Filtered conditions that filters conditions that don't contain atleast // Filtered conditions that filters conditions that don't contain atleast
// on required fields or fileds keys that not exists. // on required fields or fileds keys that not exists.

View File

@@ -1,7 +1,8 @@
import React, { useMemo, useCallback } from 'react'; import React, { useMemo, useCallback } from 'react';
import moment from 'moment'; import moment from 'moment';
import classnames from 'classnames'; import classnames from 'classnames';
import { FormattedMessage as T, useIntl } from 'react-intl'; import { FormattedMessage as T } from 'components';
import intl from 'react-intl-universal';
import 'style/pages/FinancialStatements/FinancialSheet.scss'; import 'style/pages/FinancialStatements/FinancialSheet.scss';
@@ -23,7 +24,7 @@ export default function FinancialSheet({
fullWidth = false, fullWidth = false,
currentDate = true, currentDate = true,
}) { }) {
const { formatMessage } = useIntl();
const format = 'DD MMMM YYYY'; const format = 'DD MMMM YYYY';
const formattedFromDate = useMemo(() => moment(fromDate).format(format), [ const formattedFromDate = useMemo(() => moment(fromDate).format(format), [
fromDate, fromDate,
@@ -38,10 +39,10 @@ export default function FinancialSheet({
const nameModifer = name ? `financial-sheet--${name}` : ''; const nameModifer = name ? `financial-sheet--${name}` : '';
const methodsLabels = useMemo( const methodsLabels = useMemo(
() => ({ () => ({
cash: formatMessage({ id: 'cash' }), cash: intl.get('cash'),
accrual: formatMessage({ id: 'accrual' }), accrual: intl.get('accrual'),
}), }),
[formatMessage], [],
); );
const getBasisLabel = useCallback((b) => methodsLabels[b], [methodsLabels]); const getBasisLabel = useCallback((b) => methodsLabels[b], [methodsLabels]);
const basisLabel = useMemo(() => getBasisLabel(basis), [ const basisLabel = useMemo(() => getBasisLabel(basis), [

View File

@@ -0,0 +1,9 @@
import intl from 'react-intl-universal';
export function FormattedMessage({ id }) {
return intl.get(id);
}
export function FormattedHTMLMessage({ ...args }) {
return intl.formatHTMLMessage({ ...args })
}

View File

@@ -5,7 +5,7 @@ import { CLASSES } from 'common/classes';
import { Suggest } from '@blueprintjs/select'; import { Suggest } from '@blueprintjs/select';
import { FormattedMessage as T } from 'react-intl'; import { FormattedMessage as T } from 'components';
export default function ItemsSuggestField({ export default function ItemsSuggestField({
items, items,

View File

@@ -1,7 +1,7 @@
import React, { useState, useMemo, useEffect } from 'react'; import React, { useState, useMemo, useEffect } from 'react';
import { Button, MenuItem } from '@blueprintjs/core'; import { Button, MenuItem } from '@blueprintjs/core';
import { Select } from '@blueprintjs/select'; import { Select } from '@blueprintjs/select';
import { FormattedMessage as T } from 'react-intl'; import { FormattedMessage as T } from './FormattedMessage';
import classNames from 'classnames'; import classNames from 'classnames';
import { CLASSES } from 'common/classes'; import { CLASSES } from 'common/classes';

View File

@@ -3,7 +3,7 @@ import { FastField, ErrorMessage } from 'formik';
import { FormGroup, Checkbox, Switch } from '@blueprintjs/core'; import { FormGroup, Checkbox, Switch } from '@blueprintjs/core';
import { CLASSES } from 'common/classes'; import { CLASSES } from 'common/classes';
import { ListSelect } from 'components'; import { ListSelect } from 'components';
import { FormattedMessage as T } from 'react-intl'; import { FormattedMessage as T } from 'components';
import { inputIntent } from 'utils'; import { inputIntent } from 'utils';
import { import {
moneyFormat, moneyFormat,

View File

@@ -2,7 +2,7 @@ import React from 'react';
import { useFormikContext } from 'formik'; import { useFormikContext } from 'formik';
import { Button, Classes, Intent } from '@blueprintjs/core'; import { Button, Classes, Intent } from '@blueprintjs/core';
import classNames from 'classnames'; import classNames from 'classnames';
import { FormattedMessage as T } from 'react-intl'; import { FormattedMessage as T } from 'components';
/** /**
* Number format footer. * Number format footer.

View File

@@ -1,7 +1,7 @@
import React, { useReducer, useEffect } from 'react'; import React, { useReducer, useEffect } from 'react';
import classNames from 'classnames'; import classNames from 'classnames';
import { Button, ButtonGroup, Intent, HTMLSelect } from '@blueprintjs/core'; import { Button, ButtonGroup, Intent, HTMLSelect } from '@blueprintjs/core';
import { FormattedMessage as T } from 'react-intl'; import { FormattedMessage as T } from 'components';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { range } from 'lodash'; import { range } from 'lodash';
import { Icon } from 'components'; import { Icon } from 'components';

View File

@@ -1,7 +1,7 @@
import React, { useCallback } from 'react'; import React, { useCallback } from 'react';
import { MenuItem } from '@blueprintjs/core'; import { MenuItem } from '@blueprintjs/core';
import ListSelect from 'components/ListSelect'; import ListSelect from 'components/ListSelect';
import { FormattedMessage as T } from 'react-intl'; import { FormattedMessage as T } from 'components';
function PaymentReceiveListField({ function PaymentReceiveListField({
invoices, invoices,

View File

@@ -1,7 +1,7 @@
import React from 'react'; import React from 'react';
import { Menu, MenuItem, MenuDivider } from '@blueprintjs/core'; import { Menu, MenuItem, MenuDivider } from '@blueprintjs/core';
import { useHistory, useLocation } from 'react-router-dom'; import { useHistory, useLocation } from 'react-router-dom';
import { FormattedMessage as T } from 'react-intl'; import { FormattedMessage as T } from 'components';
import preferencesMenu from 'config/preferencesMenu'; import preferencesMenu from 'config/preferencesMenu';
import PreferencesSidebarContainer from './PreferencesSidebarContainer'; import PreferencesSidebarContainer from './PreferencesSidebarContainer';

View File

@@ -1,5 +1,5 @@
import React from 'react'; import React from 'react';
import { formatMessage } from 'services/intl'; import intl from 'react-intl-universal';
import { ListSelect } from 'components'; import { ListSelect } from 'components';
@@ -15,7 +15,7 @@ export default function SalutationList({ ...restProps }) {
items={items} items={items}
selectedItemProp={'key'} selectedItemProp={'key'}
textProp={'label'} textProp={'label'}
defaultText={formatMessage({ id: 'salutation' })} defaultText={intl.get('salutation')}
filterable={false} filterable={false}
{...restProps} {...restProps}
/> />

View File

@@ -3,6 +3,7 @@ import Money from './Money';
import Icon from './Icon'; import Icon from './Icon';
import Choose from './Utils/Choose'; import Choose from './Utils/Choose';
import For from './Utils/For'; import For from './Utils/For';
import { FormattedMessage, FormattedHTMLMessage } from './FormattedMessage';
import ListSelect from './ListSelect'; import ListSelect from './ListSelect';
import FinancialStatement from './FinancialStatement'; import FinancialStatement from './FinancialStatement';
import DynamicFilterValueField from './DynamicFilter/DynamicFilterValueField'; import DynamicFilterValueField from './DynamicFilter/DynamicFilterValueField';
@@ -58,14 +59,19 @@ import MaterialProgressBar from './MaterialProgressBar';
const Hint = FieldHint; const Hint = FieldHint;
const T = FormattedMessage;
export { export {
If, If,
For, For,
Money, Choose,
Icon, Icon,
FormattedMessage,
FormattedHTMLMessage,
T,
Money,
ListSelect, ListSelect,
FinancialStatement, FinancialStatement,
Choose,
DynamicFilterValueField, DynamicFilterValueField,
DynamicFilterCompatatorField, DynamicFilterCompatatorField,
MODIFIER, MODIFIER,

View File

@@ -1,5 +1,5 @@
import React from 'react'; import React from 'react';
import { FormattedMessage as T } from 'react-intl'; import { FormattedMessage as T } from 'components';
export const financialReportMenus = [ export const financialReportMenus = [
{ {
@@ -66,7 +66,7 @@ export const SalesAndPurchasesReportMenus = [
desc: ( desc: (
<T <T
id={ id={
'shows_the_average_age_of_unresolved_issues_for_a_project_or_filter' 'summarize_the_business_s_purchase_items_quantity_cost_and_average'
} }
/> />
), ),
@@ -107,7 +107,9 @@ export const SalesAndPurchasesReportMenus = [
}, },
{ {
title: <T id={'vendors_balance_summary'} />, title: <T id={'vendors_balance_summary'} />,
desc: 'summerize_the_total_amount_your_business_owes_each_vendor', desc: (
<T id={'summerize_the_total_amount_your_business_owes_each_vendor'} />
),
link: '/financial-reports/vendors-balance-summary', link: '/financial-reports/vendors-balance-summary',
}, },
{ {

View File

@@ -1,5 +1,5 @@
import React from 'react' import React from 'react'
import { FormattedMessage as T} from 'react-intl'; import { FormattedMessage as T } from 'components';
export default [ export default [
{ {

View File

@@ -1,5 +1,5 @@
import React from 'react'; import React from 'react';
import { FormattedMessage as T } from 'react-intl'; import { FormattedMessage as T } from 'components';
export default [ export default [
{ {
@@ -16,7 +16,7 @@ export default [
text: <T id={'items'} />, text: <T id={'items'} />,
children: [ children: [
{ {
text: <T id={'items_list'} />, text: <T id={'items'} />,
href: '/items', href: '/items',
}, },
{ {
@@ -67,7 +67,7 @@ export default [
newTabHref: '/bills/new', newTabHref: '/bills/new',
}, },
{ {
text: <T id={'payment_made'} />, text: <T id={'payment_mades'} />,
href: '/payment-mades', href: '/payment-mades',
newTabHref: '/payment-mades/new', newTabHref: '/payment-mades/new',
}, },

View File

@@ -12,7 +12,7 @@ import {
} from '@blueprintjs/core'; } from '@blueprintjs/core';
import classNames from 'classnames'; import classNames from 'classnames';
import { useHistory } from 'react-router-dom'; import { useHistory } from 'react-router-dom';
import { FormattedMessage as T } from 'react-intl'; import { FormattedMessage as T } from 'components';
import { useManualJournalsContext } from './ManualJournalsListProvider'; import { useManualJournalsContext } from './ManualJournalsListProvider';
import DashboardActionsBar from 'components/Dashboard/DashboardActionsBar'; import DashboardActionsBar from 'components/Dashboard/DashboardActionsBar';

View File

@@ -2,7 +2,7 @@ import React from 'react';
import { Button, Intent } from '@blueprintjs/core'; import { Button, Intent } from '@blueprintjs/core';
import { useHistory } from 'react-router-dom'; import { useHistory } from 'react-router-dom';
import { EmptyStatus } from 'components'; import { EmptyStatus } from 'components';
import { FormattedMessage as T } from 'react-intl'; import { FormattedMessage as T } from 'components';
export default function ManualJournalsEmptyStatus() { export default function ManualJournalsEmptyStatus() {
const history = useHistory(); const history = useHistory();

View File

@@ -11,11 +11,11 @@ import {
MenuDivider, MenuDivider,
Popover, Popover,
} from '@blueprintjs/core'; } from '@blueprintjs/core';
import { FormattedMessage as T } from 'react-intl'; import { FormattedMessage as T } from 'components';
import moment from 'moment'; import moment from 'moment';
import { Choose, Money, If, Icon } from 'components'; import { Choose, Money, If, Icon } from 'components';
import { safeCallback } from 'utils'; import { safeCallback } from 'utils';
import { formatMessage } from 'services/intl'; import intl from 'react-intl-universal';
/** /**
* Amount accessor. * Amount accessor.
@@ -155,24 +155,24 @@ export const ActionsMenu = ({
<Menu> <Menu>
<MenuItem <MenuItem
icon={<Icon icon="reader-18" />} icon={<Icon icon="reader-18" />}
text={formatMessage({ id: 'view_details' })} text={intl.get('view_details')}
onClick={safeCallback(onViewDetails, original)} onClick={safeCallback(onViewDetails, original)}
/> />
<MenuDivider /> <MenuDivider />
<If condition={!original.is_published}> <If condition={!original.is_published}>
<MenuItem <MenuItem
icon={<Icon icon="arrow-to-top" />} icon={<Icon icon="arrow-to-top" />}
text={formatMessage({ id: 'publish_journal' })} text={intl.get('publish_journal')}
onClick={safeCallback(onPublish, original)} onClick={safeCallback(onPublish, original)}
/> />
</If> </If>
<MenuItem <MenuItem
icon={<Icon icon="pen-18" />} icon={<Icon icon="pen-18" />}
text={formatMessage({ id: 'edit_journal' })} text={intl.get('edit_journal')}
onClick={safeCallback(onEdit, original)} onClick={safeCallback(onEdit, original)}
/> />
<MenuItem <MenuItem
text={formatMessage({ id: 'delete_journal' })} text={intl.get('delete_journal')}
icon={<Icon icon="trash-16" iconSize={16} />} icon={<Icon icon="trash-16" iconSize={16} />}
intent={Intent.DANGER} intent={Intent.DANGER}
onClick={safeCallback(onDelete, original)} onClick={safeCallback(onDelete, original)}

View File

@@ -1,5 +1,5 @@
import React from 'react'; import React from 'react';
import { formatMessage } from 'services/intl'; import intl from 'react-intl-universal';
import moment from 'moment'; import moment from 'moment';
import { import {
NoteAccessor, NoteAccessor,
@@ -16,42 +16,42 @@ export const useManualJournalsColumns = () => {
() => [ () => [
{ {
id: 'date', id: 'date',
Header: formatMessage({ id: 'date' }), Header: intl.get('date'),
accessor: DateAccessor, accessor: DateAccessor,
width: 115, width: 115,
className: 'date', className: 'date',
}, },
{ {
id: 'amount', id: 'amount',
Header: formatMessage({ id: 'amount' }), Header: intl.get('amount'),
accessor: AmountAccessor, accessor: AmountAccessor,
className: 'amount', className: 'amount',
width: 115, width: 115,
}, },
{ {
id: 'journal_number', id: 'journal_number',
Header: formatMessage({ id: 'journal_no' }), Header: intl.get('journal_no'),
accessor: (row) => `#${row.journal_number}`, accessor: (row) => `#${row.journal_number}`,
className: 'journal_number', className: 'journal_number',
width: 100, width: 100,
}, },
{ {
id: 'journal_type', id: 'journal_type',
Header: formatMessage({ id: 'journal_type' }), Header: intl.get('journal_type'),
accessor: 'journal_type', accessor: 'journal_type',
width: 110, width: 110,
className: 'journal_type', className: 'journal_type',
}, },
{ {
id: 'status', id: 'status',
Header: formatMessage({ id: 'publish' }), Header: intl.get('publish'),
accessor: (row) => StatusAccessor(row), accessor: (row) => StatusAccessor(row),
width: 95, width: 95,
className: 'status', className: 'status',
}, },
{ {
id: 'note', id: 'note',
Header: formatMessage({ id: 'note' }), Header: intl.get('note'),
accessor: NoteAccessor, accessor: NoteAccessor,
disableSortBy: true, disableSortBy: true,
width: 85, width: 85,
@@ -59,7 +59,7 @@ export const useManualJournalsColumns = () => {
}, },
{ {
id: 'created_at', id: 'created_at',
Header: formatMessage({ id: 'created_at' }), Header: intl.get('created_at'),
accessor: (r) => moment(r.created_at).format('YYYY MMM DD'), accessor: (r) => moment(r.created_at).format('YYYY MMM DD'),
width: 125, width: 125,
className: 'created_at', className: 'created_at',

View File

@@ -1,5 +1,5 @@
import * as Yup from 'yup'; import * as Yup from 'yup';
import { formatMessage } from 'services/intl'; import intl from 'react-intl-universal';
import { DATATYPES_LENGTH } from 'common/dataTypes'; import { DATATYPES_LENGTH } from 'common/dataTypes';
const Schema = Yup.object().shape({ const Schema = Yup.object().shape({
@@ -7,15 +7,15 @@ const Schema = Yup.object().shape({
.required() .required()
.min(1) .min(1)
.max(DATATYPES_LENGTH.STRING) .max(DATATYPES_LENGTH.STRING)
.label(formatMessage({ id: 'journal_number_' })), .label(intl.get('journal_number_')),
journal_type: Yup.string() journal_type: Yup.string()
.required() .required()
.min(1) .min(1)
.max(DATATYPES_LENGTH.STRING) .max(DATATYPES_LENGTH.STRING)
.label(formatMessage({ id: 'journal_type' })), .label(intl.get('journal_type')),
date: Yup.date() date: Yup.date()
.required() .required()
.label(formatMessage({ id: 'date' })), .label(intl.get('date')),
currency_code: Yup.string().max(3), currency_code: Yup.string().max(3),
publish: Yup.boolean(), publish: Yup.boolean(),
reference: Yup.string().nullable().min(1).max(DATATYPES_LENGTH.STRING), reference: Yup.string().nullable().min(1).max(DATATYPES_LENGTH.STRING),

View File

@@ -9,7 +9,7 @@ import {
Menu, Menu,
MenuItem, MenuItem,
} from '@blueprintjs/core'; } from '@blueprintjs/core';
import { FormattedMessage as T } from 'react-intl'; import { FormattedMessage as T } from 'components';
import { useFormikContext } from 'formik'; import { useFormikContext } from 'formik';
import { CLASSES } from 'common/classes'; import { CLASSES } from 'common/classes';
import classNames from 'classnames'; import classNames from 'classnames';

View File

@@ -1,7 +1,7 @@
import React, { useMemo } from 'react'; import React, { useMemo } from 'react';
import { Formik, Form } from 'formik'; import { Formik, Form } from 'formik';
import { Intent } from '@blueprintjs/core'; import { Intent } from '@blueprintjs/core';
import { useIntl } from 'react-intl'; import intl from 'react-intl-universal';
import { defaultTo, isEmpty, omit } from 'lodash'; import { defaultTo, isEmpty, omit } from 'lodash';
import classNames from 'classnames'; import classNames from 'classnames';
import { useHistory } from 'react-router-dom'; import { useHistory } from 'react-router-dom';
@@ -48,7 +48,6 @@ function MakeJournalEntriesForm({
submitPayload, submitPayload,
} = useMakeJournalFormContext(); } = useMakeJournalFormContext();
const { formatMessage } = useIntl();
const history = useHistory(); const history = useHistory();
// New journal number. // New journal number.
@@ -92,18 +91,14 @@ function MakeJournalEntriesForm({
// Validate the total credit should be eqials total debit. // Validate the total credit should be eqials total debit.
if (totalCredit !== totalDebit) { if (totalCredit !== totalDebit) {
AppToaster.show({ AppToaster.show({
message: formatMessage({ message: intl.get('should_total_of_credit_and_debit_be_equal'),
id: 'should_total_of_credit_and_debit_be_equal',
}),
intent: Intent.DANGER, intent: Intent.DANGER,
}); });
setSubmitting(false); setSubmitting(false);
return; return;
} else if (totalCredit === 0 || totalDebit === 0) { } else if (totalCredit === 0 || totalDebit === 0) {
AppToaster.show({ AppToaster.show({
message: formatMessage({ message: intl.get('amount_cannot_be_zero_or_empty'),
id: 'amount_cannot_be_zero_or_empty',
}),
intent: Intent.DANGER, intent: Intent.DANGER,
}); });
setSubmitting(false); setSubmitting(false);
@@ -131,12 +126,10 @@ function MakeJournalEntriesForm({
// Handle the request success. // Handle the request success.
const handleSuccess = (errors) => { const handleSuccess = (errors) => {
AppToaster.show({ AppToaster.show({
message: formatMessage( message: intl.get(
{ isNewMode
id: isNewMode ? 'the_journal_has_been_created_successfully'
? 'the_journal_has_been_created_successfully' : 'the_journal_has_been_edited_successfully',
: 'the_journal_has_been_edited_successfully',
},
{ number: values.journal_number }, { number: values.journal_number },
), ),
intent: Intent.SUCCESS, intent: Intent.SUCCESS,

View File

@@ -2,7 +2,7 @@ import React from 'react';
import classNames from 'classnames'; import classNames from 'classnames';
import { useFormikContext } from 'formik'; import { useFormikContext } from 'formik';
import { CLASSES } from 'common/classes'; import { CLASSES } from 'common/classes';
import { FormattedMessage as T } from 'react-intl'; import { FormattedMessage as T } from 'components';
import MakeJournalEntriesHeaderFields from './MakeJournalEntriesHeaderFields'; import MakeJournalEntriesHeaderFields from './MakeJournalEntriesHeaderFields';
import { PageFormBigNumber } from 'components'; import { PageFormBigNumber } from 'components';
import { safeSumBy } from 'utils'; import { safeSumBy } from 'utils';

View File

@@ -7,7 +7,7 @@ import {
} from '@blueprintjs/core'; } from '@blueprintjs/core';
import { FastField, ErrorMessage } from 'formik'; import { FastField, ErrorMessage } from 'formik';
import { DateInput } from '@blueprintjs/datetime'; import { DateInput } from '@blueprintjs/datetime';
import { FormattedMessage as T } from 'react-intl'; import { FormattedMessage as T } from 'components';
import classNames from 'classnames'; import classNames from 'classnames';
import { CLASSES } from 'common/classes'; import { CLASSES } from 'common/classes';

View File

@@ -11,7 +11,7 @@ import {
} from '@blueprintjs/core'; } from '@blueprintjs/core';
import { useFormikContext } from 'formik'; import { useFormikContext } from 'formik';
import classNames from 'classnames'; import classNames from 'classnames';
import { FormattedMessage as T } from 'react-intl'; import { FormattedMessage as T } from 'components';
import { CLASSES } from 'common/classes'; import { CLASSES } from 'common/classes';
import { Icon, If } from 'components'; import { Icon, If } from 'components';
import { useHistory } from 'react-router-dom'; import { useHistory } from 'react-router-dom';

View File

@@ -3,7 +3,7 @@ import { FastField } from 'formik';
import classNames from 'classnames'; import classNames from 'classnames';
import { CLASSES } from 'common/classes'; import { CLASSES } from 'common/classes';
import { FormGroup, TextArea } from '@blueprintjs/core'; import { FormGroup, TextArea } from '@blueprintjs/core';
import { FormattedMessage as T } from 'react-intl'; import { FormattedMessage as T } from 'components';
import { Postbox, ErrorMessage, Row, Col } from 'components'; import { Postbox, ErrorMessage, Row, Col } from 'components';
import Dragzone from 'components/Dragzone'; import Dragzone from 'components/Dragzone';
import { inputIntent } from 'utils'; import { inputIntent } from 'utils';

View File

@@ -1,8 +1,8 @@
import React from 'react'; import React from 'react';
import { Intent, Position, Button, Tooltip } from '@blueprintjs/core'; import { Intent, Position, Button, Tooltip } from '@blueprintjs/core';
import { FormattedMessage as T } from 'react-intl'; import { FormattedMessage as T } from 'components';
import { Icon, Money, Hint } from 'components'; import { Icon, Money, Hint } from 'components';
import { formatMessage } from 'services/intl'; import intl from 'react-intl-universal';
import { import {
AccountsListFieldCell, AccountsListFieldCell,
MoneyFieldCell, MoneyFieldCell,
@@ -30,14 +30,14 @@ export function ContactHeaderCell() {
* Credit header cell. * Credit header cell.
*/ */
export function CreditHeaderCell({ payload: { currencyCode } }) { export function CreditHeaderCell({ payload: { currencyCode } }) {
return formatMessage({ id: 'credit_currency' }, { currency: currencyCode }); return intl.get('credit_currency', { currency: currencyCode });
} }
/** /**
* debit header cell. * debit header cell.
*/ */
export function DebitHeaderCell({ payload: { currencyCode } }) { export function DebitHeaderCell({ payload: { currencyCode } }) {
return formatMessage({ id: 'debit_currency' }, { currency: currencyCode }); return intl.get('debit_currency', { currency: currencyCode });
} }
/** /**
@@ -46,7 +46,7 @@ export function DebitHeaderCell({ payload: { currencyCode } }) {
function AccountFooterCell({ payload: { currencyCode } }) { function AccountFooterCell({ payload: { currencyCode } }) {
return ( return (
<span> <span>
{formatMessage({ id: 'total_currency' }, { currency: currencyCode })} {intl.get('total_currency', { currency: currencyCode })}
</span> </span>
); );
} }
@@ -120,7 +120,7 @@ export const useJournalTableEntriesColumns = () => {
sticky: 'left', sticky: 'left',
}, },
{ {
Header: formatMessage({ id: 'account' }), Header: intl.get('account'),
id: 'account_id', id: 'account_id',
accessor: 'account_id', accessor: 'account_id',
Cell: AccountsListFieldCell, Cell: AccountsListFieldCell,
@@ -157,7 +157,7 @@ export const useJournalTableEntriesColumns = () => {
width: 120, width: 120,
}, },
{ {
Header: formatMessage({ id: 'note' }), Header: intl.get('note'),
accessor: 'note', accessor: 'note',
Cell: InputGroupCell, Cell: InputGroupCell,
disableSortBy: true, disableSortBy: true,
@@ -174,6 +174,6 @@ export const useJournalTableEntriesColumns = () => {
width: 45, width: 45,
}, },
], ],
[formatMessage], [],
); );
}; };

View File

@@ -10,7 +10,7 @@ import {
transformToForm, transformToForm,
} from 'utils'; } from 'utils';
import { AppToaster } from 'components'; import { AppToaster } from 'components';
import { formatMessage } from 'services/intl'; import intl from 'react-intl-universal';
import { useFormikContext } from 'formik'; import { useFormikContext } from 'formik';
const ERROR = { const ERROR = {
@@ -118,23 +118,19 @@ export const transformErrors = (resErrors, { setErrors, errors }) => {
if ((error = getError(ERROR.RECEIVABLE_ENTRIES_HAS_NO_CUSTOMERS))) { if ((error = getError(ERROR.RECEIVABLE_ENTRIES_HAS_NO_CUSTOMERS))) {
toastMessages.push( toastMessages.push(
formatMessage({ intl.get('should_select_customers_with_entries_have_receivable_account'),
id: 'should_select_customers_with_entries_have_receivable_account',
}),
); );
setEntriesErrors(error.indexes, 'contact_id', 'error'); setEntriesErrors(error.indexes, 'contact_id', 'error');
} }
if ((error = getError(ERROR.ENTRIES_SHOULD_ASSIGN_WITH_CONTACT))) { if ((error = getError(ERROR.ENTRIES_SHOULD_ASSIGN_WITH_CONTACT))) {
if (error.meta.find(meta => meta.contact_type === 'customer')) { if (error.meta.find(meta => meta.contact_type === 'customer')) {
toastMessages.push( toastMessages.push(
formatMessage({ intl.get('receivable_accounts_should_assign_with_customers'),
id: 'receivable_accounts_should_assign_with_customers',
}),
); );
} }
if (error.meta.find(meta => meta.contact_type === 'vendor')) { if (error.meta.find(meta => meta.contact_type === 'vendor')) {
toastMessages.push( toastMessages.push(
formatMessage({ id: 'payable_accounts_should_assign_with_vendors' }), intl.get('payable_accounts_should_assign_with_vendors'),
); );
} }
const indexes = error.meta.map((meta => meta.indexes)).flat(); const indexes = error.meta.map((meta => meta.indexes)).flat();
@@ -144,9 +140,7 @@ export const transformErrors = (resErrors, { setErrors, errors }) => {
newErrors = setWith( newErrors = setWith(
newErrors, newErrors,
'journal_number', 'journal_number',
formatMessage({ intl.get('journal_number_is_already_used'),
id: 'journal_number_is_already_used',
}),
); );
} }
setErrors({ ...newErrors }); setErrors({ ...newErrors });

View File

@@ -12,7 +12,7 @@ import {
Intent, Intent,
} from '@blueprintjs/core'; } from '@blueprintjs/core';
import classNames from 'classnames'; import classNames from 'classnames';
import { FormattedMessage as T } from 'react-intl'; import { FormattedMessage as T } from 'components';
import { If, DashboardActionViewsList } from 'components'; import { If, DashboardActionViewsList } from 'components';
import DashboardActionsBar from 'components/Dashboard/DashboardActionsBar'; import DashboardActionsBar from 'components/Dashboard/DashboardActionsBar';

View File

@@ -10,9 +10,8 @@ import {
Popover, Popover,
Button, Button,
} from '@blueprintjs/core'; } from '@blueprintjs/core';
import { useIntl } from 'react-intl';
import { Icon, Money, If } from 'components'; import { Icon, Money, If } from 'components';
import { formatMessage } from 'services/intl'; import intl from 'react-intl-universal';
import { safeCallback } from 'utils'; import { safeCallback } from 'utils';
/** /**
@@ -34,37 +33,37 @@ export function ActionsMenu({
<Menu> <Menu>
<MenuItem <MenuItem
icon={<Icon icon="reader-18" />} icon={<Icon icon="reader-18" />}
text={formatMessage({ id: 'view_details' })} text={intl.get('view_details')}
onClick={safeCallback(onViewDetails, original)} onClick={safeCallback(onViewDetails, original)}
/> />
<MenuDivider /> <MenuDivider />
<MenuItem <MenuItem
icon={<Icon icon="pen-18" />} icon={<Icon icon="pen-18" />}
text={formatMessage({ id: 'edit_account' })} text={intl.get('edit_account')}
onClick={safeCallback(onEdit, original)} onClick={safeCallback(onEdit, original)}
/> />
<MenuItem <MenuItem
icon={<Icon icon="plus" />} icon={<Icon icon="plus" />}
text={formatMessage({ id: 'new_child_account' })} text={intl.get('new_child_account')}
onClick={safeCallback(onNewChild, original)} onClick={safeCallback(onNewChild, original)}
/> />
<MenuDivider /> <MenuDivider />
<If condition={original.active}> <If condition={original.active}>
<MenuItem <MenuItem
text={formatMessage({ id: 'inactivate_account' })} text={intl.get('inactivate_account')}
icon={<Icon icon="pause-16" iconSize={16} />} icon={<Icon icon="pause-16" iconSize={16} />}
onClick={safeCallback(onInactivate, original)} onClick={safeCallback(onInactivate, original)}
/> />
</If> </If>
<If condition={!original.active}> <If condition={!original.active}>
<MenuItem <MenuItem
text={formatMessage({ id: 'activate_account' })} text={intl.get('activate_account')}
icon={<Icon icon="play-16" iconSize={16} />} icon={<Icon icon="play-16" iconSize={16} />}
onClick={safeCallback(onActivate, original)} onClick={safeCallback(onActivate, original)}
/> />
</If> </If>
<MenuItem <MenuItem
text={formatMessage({ id: 'delete_account' })} text={intl.get('delete_account')}
icon={<Icon icon="trash-16" iconSize={16} />} icon={<Icon icon="trash-16" iconSize={16} />}
intent={Intent.DANGER} intent={Intent.DANGER}
onClick={safeCallback(onDelete, original)} onClick={safeCallback(onDelete, original)}
@@ -77,7 +76,6 @@ export function ActionsMenu({
* Normal cell. * Normal cell.
*/ */
export function NormalCell({ cell: { value } }) { export function NormalCell({ cell: { value } }) {
const { formatMessage } = useIntl();
const arrowDirection = value === 'credit' ? 'down' : 'up'; const arrowDirection = value === 'credit' ? 'down' : 'up';
// Can't continue if the value is not `credit` or `debit`. // Can't continue if the value is not `credit` or `debit`.
@@ -87,7 +85,7 @@ export function NormalCell({ cell: { value } }) {
return ( return (
<Tooltip <Tooltip
className={Classes.TOOLTIP_INDICATOR} className={Classes.TOOLTIP_INDICATOR}
content={formatMessage({ id: value })} content={intl.get(value)}
position={Position.RIGHT} position={Position.RIGHT}
hoverOpenDelay={100} hoverOpenDelay={100}
> >

View File

@@ -1,7 +1,7 @@
import React from 'react'; import React from 'react';
import { Intent, Tag } from '@blueprintjs/core'; import { Intent, Tag } from '@blueprintjs/core';
import { If, AppToaster } from 'components'; import { If, AppToaster } from 'components';
import { formatMessage } from 'services/intl'; import intl from 'react-intl-universal';
import { NormalCell, BalanceCell } from './components'; import { NormalCell, BalanceCell } from './components';
import { isBlank, compose } from 'utils'; import { isBlank, compose } from 'utils';
@@ -25,17 +25,13 @@ export const accountNameAccessor = (account) => {
export const handleDeleteErrors = (errors) => { export const handleDeleteErrors = (errors) => {
if (errors.find((e) => e.type === 'ACCOUNT.PREDEFINED')) { if (errors.find((e) => e.type === 'ACCOUNT.PREDEFINED')) {
AppToaster.show({ AppToaster.show({
message: formatMessage({ message: intl.get('you_could_not_delete_predefined_accounts'),
id: 'you_could_not_delete_predefined_accounts',
}),
intent: Intent.DANGER, intent: Intent.DANGER,
}); });
} }
if (errors.find((e) => e.type === 'ACCOUNT.HAS.ASSOCIATED.TRANSACTIONS')) { if (errors.find((e) => e.type === 'ACCOUNT.HAS.ASSOCIATED.TRANSACTIONS')) {
AppToaster.show({ AppToaster.show({
message: formatMessage({ message: intl.get('cannot_delete_account_has_associated_transactions'),
id: 'cannot_delete_account_has_associated_transactions',
}),
intent: Intent.DANGER, intent: Intent.DANGER,
}); });
} }
@@ -56,28 +52,28 @@ export const useAccountsTableColumns = () => {
() => [ () => [
{ {
id: 'name', id: 'name',
Header: formatMessage({ id: 'account_name' }), Header: intl.get('account_name'),
accessor: 'name', accessor: 'name',
className: 'account_name', className: 'account_name',
width: 200, width: 200,
}, },
{ {
id: 'code', id: 'code',
Header: formatMessage({ id: 'code' }), Header: intl.get('code'),
accessor: AccountCodeAccessor, accessor: AccountCodeAccessor,
className: 'code', className: 'code',
width: 80, width: 80,
}, },
{ {
id: 'type', id: 'type',
Header: formatMessage({ id: 'type' }), Header: intl.get('type'),
accessor: 'account_type_label', accessor: 'account_type_label',
className: 'type', className: 'type',
width: 140, width: 140,
}, },
{ {
id: 'normal', id: 'normal',
Header: formatMessage({ id: 'normal' }), Header: intl.get('account_normal'),
Cell: NormalCell, Cell: NormalCell,
accessor: 'account_normal', accessor: 'account_normal',
className: 'normal', className: 'normal',
@@ -85,13 +81,13 @@ export const useAccountsTableColumns = () => {
}, },
{ {
id: 'currency', id: 'currency',
Header: formatMessage({ id: 'currency' }), Header: intl.get('currency'),
accessor: 'currency_code', accessor: 'currency_code',
width: 75, width: 75,
}, },
{ {
id: 'balance', id: 'balance',
Header: formatMessage({ id: 'balance' }), Header: intl.get('balance'),
accessor: 'amount', accessor: 'amount',
Cell: BalanceCell, Cell: BalanceCell,
width: 150, width: 150,

View File

@@ -1,7 +1,7 @@
import React from 'react'; import React from 'react';
import { FormattedMessage as T, useIntl } from 'react-intl'; import intl from 'react-intl-universal';
import { Intent, Alert } from '@blueprintjs/core'; import { Intent, Alert } from '@blueprintjs/core';
import { AppToaster } from 'components'; import { AppToaster, FormattedMessage as T } from 'components';
import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect'; import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect';
import withAlertActions from 'containers/Alert/withAlertActions'; import withAlertActions from 'containers/Alert/withAlertActions';
@@ -20,7 +20,7 @@ function AccountActivateAlert({
// #withAlertActions // #withAlertActions
closeAlert, closeAlert,
}) { }) {
const { formatMessage } = useIntl();
const { const {
mutateAsync: activateAccount, mutateAsync: activateAccount,
isLoading isLoading
@@ -35,9 +35,7 @@ function AccountActivateAlert({
const handleConfirmAccountActivate = () => { const handleConfirmAccountActivate = () => {
activateAccount(accountId).then(() => { activateAccount(accountId).then(() => {
AppToaster.show({ AppToaster.show({
message: formatMessage({ message: intl.get('the_account_has_been_successfully_activated'),
id: 'the_account_has_been_successfully_activated',
}),
intent: Intent.SUCCESS, intent: Intent.SUCCESS,
}); });
closeAlert('account-activate'); closeAlert('account-activate');

View File

@@ -1,8 +1,8 @@
import React, { useState } from 'react'; import React, { useState } from 'react';
import { FormattedMessage as T, useIntl } from 'react-intl'; import intl from 'react-intl-universal';
import { Intent, Alert } from '@blueprintjs/core'; import { Intent, Alert } from '@blueprintjs/core';
import { queryCache } from 'react-query'; import { queryCache } from 'react-query';
import { AppToaster } from 'components'; import { FormattedMessage as T, AppToaster } from 'components';
import withAccountsActions from 'containers/Accounts/withAccountsActions'; import withAccountsActions from 'containers/Accounts/withAccountsActions';
import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect'; import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect';
@@ -20,7 +20,6 @@ function AccountBulkActivateAlert({
requestBulkActivateAccounts, requestBulkActivateAccounts,
}) { }) {
const { formatMessage } = useIntl();
const [isLoading, setLoading] = useState(false); const [isLoading, setLoading] = useState(false);
const selectedRowsCount = 0; const selectedRowsCount = 0;
@@ -35,9 +34,7 @@ function AccountBulkActivateAlert({
requestBulkActivateAccounts(accountsIds) requestBulkActivateAccounts(accountsIds)
.then(() => { .then(() => {
AppToaster.show({ AppToaster.show({
message: formatMessage({ message: intl.get('the_accounts_has_been_successfully_activated'),
id: 'the_accounts_has_been_successfully_activated',
}),
intent: Intent.SUCCESS, intent: Intent.SUCCESS,
}); });
queryCache.invalidateQueries('accounts-table'); queryCache.invalidateQueries('accounts-table');
@@ -52,9 +49,7 @@ function AccountBulkActivateAlert({
return ( return (
<Alert <Alert
cancelButtonText={<T id={'cancel'} />} cancelButtonText={<T id={'cancel'} />}
confirmButtonText={`${formatMessage({ confirmButtonText={`${intl.get('activate')} (${selectedRowsCount})`}
id: 'activate',
})} (${selectedRowsCount})`}
intent={Intent.WARNING} intent={Intent.WARNING}
isOpen={isOpen} isOpen={isOpen}
onCancel={handleClose} onCancel={handleClose}

View File

@@ -1,5 +1,6 @@
import React, { useState } from 'react'; import React, { useState } from 'react';
import { FormattedMessage as T, useIntl } from 'react-intl'; import { FormattedMessage as T } from 'components';
import intl from 'react-intl-universal';
import { Intent, Alert } from '@blueprintjs/core'; import { Intent, Alert } from '@blueprintjs/core';
import { queryCache } from 'react-query'; import { queryCache } from 'react-query';
import { AppToaster } from 'components'; import { AppToaster } from 'components';
@@ -29,7 +30,7 @@ function AccountBulkDeleteAlert({
// #withAccountsActions // #withAccountsActions
requestDeleteBulkAccounts, requestDeleteBulkAccounts,
}) { }) {
const { formatMessage } = useIntl();
const [isLoading, setLoading] = useState(false); const [isLoading, setLoading] = useState(false);
const selectedRowsCount = 0; const selectedRowsCount = 0;
@@ -43,9 +44,7 @@ function AccountBulkDeleteAlert({
requestDeleteBulkAccounts(accountsIds) requestDeleteBulkAccounts(accountsIds)
.then(() => { .then(() => {
AppToaster.show({ AppToaster.show({
message: formatMessage({ message: intl.get('the_accounts_has_been_successfully_deleted'),
id: 'the_accounts_has_been_successfully_deleted',
}),
intent: Intent.SUCCESS, intent: Intent.SUCCESS,
}); });
queryCache.invalidateQueries('accounts-table'); queryCache.invalidateQueries('accounts-table');
@@ -62,9 +61,7 @@ function AccountBulkDeleteAlert({
return ( return (
<Alert <Alert
cancelButtonText={<T id={'cancel'} />} cancelButtonText={<T id={'cancel'} />}
confirmButtonText={`${formatMessage({ confirmButtonText={`${intl.get('delete')} (${selectedRowsCount})`}
id: 'delete',
})} (${selectedRowsCount})`}
icon="trash" icon="trash"
intent={Intent.DANGER} intent={Intent.DANGER}
isOpen={isOpen} isOpen={isOpen}

View File

@@ -1,5 +1,6 @@
import React, { useState } from 'react'; import React, { useState } from 'react';
import { FormattedMessage as T, useIntl } from 'react-intl'; import { FormattedMessage as T } from 'components';
import intl from 'react-intl-universal';
import { Intent, Alert } from '@blueprintjs/core'; import { Intent, Alert } from '@blueprintjs/core';
import { queryCache } from 'react-query'; import { queryCache } from 'react-query';
import { AppToaster } from 'components'; import { AppToaster } from 'components';
@@ -20,7 +21,7 @@ function AccountBulkInactivateAlert({
closeAlert, closeAlert,
}) { }) {
const { formatMessage } = useIntl();
const [isLoading, setLoading] = useState(false); const [isLoading, setLoading] = useState(false);
const selectedRowsCount = 0; const selectedRowsCount = 0;
@@ -34,9 +35,7 @@ function AccountBulkInactivateAlert({
requestBulkInactiveAccounts(accountsIds) requestBulkInactiveAccounts(accountsIds)
.then(() => { .then(() => {
AppToaster.show({ AppToaster.show({
message: formatMessage({ message: intl.get('the_accounts_have_been_successfully_inactivated'),
id: 'the_accounts_have_been_successfully_inactivated',
}),
intent: Intent.SUCCESS, intent: Intent.SUCCESS,
}); });
queryCache.invalidateQueries('accounts-table'); queryCache.invalidateQueries('accounts-table');
@@ -51,9 +50,7 @@ function AccountBulkInactivateAlert({
return ( return (
<Alert <Alert
cancelButtonText={<T id={'cancel'} />} cancelButtonText={<T id={'cancel'} />}
confirmButtonText={`${formatMessage({ confirmButtonText={`${intl.get('inactivate')} (${selectedRowsCount})`}
id: 'inactivate',
})} (${selectedRowsCount})`}
intent={Intent.WARNING} intent={Intent.WARNING}
isOpen={isOpen} isOpen={isOpen}
onCancel={handleCancel} onCancel={handleCancel}

View File

@@ -1,10 +1,8 @@
import React from 'react'; import React from 'react';
import { import intl from 'react-intl-universal';
FormattedMessage as T, import { FormattedMessage as T, FormattedHTMLMessage } from 'components';
FormattedHTMLMessage,
useIntl,
} from 'react-intl';
import { Intent, Alert } from '@blueprintjs/core'; import { Intent, Alert } from '@blueprintjs/core';
import { AppToaster } from 'components'; import { AppToaster } from 'components';
import { handleDeleteErrors } from 'containers/Accounts/utils'; import { handleDeleteErrors } from 'containers/Accounts/utils';
@@ -28,7 +26,6 @@ function AccountDeleteAlert({
// #withAlertActions // #withAlertActions
closeAlert, closeAlert,
}) { }) {
const { formatMessage } = useIntl();
const { isLoading, mutateAsync: deleteAccount } = useDeleteAccount(); const { isLoading, mutateAsync: deleteAccount } = useDeleteAccount();
// handle cancel delete account alert. // handle cancel delete account alert.
@@ -40,9 +37,7 @@ function AccountDeleteAlert({
deleteAccount(accountId) deleteAccount(accountId)
.then(() => { .then(() => {
AppToaster.show({ AppToaster.show({
message: formatMessage({ message: intl.get('the_account_has_been_successfully_deleted'),
id: 'the_account_has_been_successfully_deleted',
}),
intent: Intent.SUCCESS, intent: Intent.SUCCESS,
}); });
closeAlert(name); closeAlert(name);

View File

@@ -1,5 +1,6 @@
import React from 'react'; import React from 'react';
import { FormattedMessage as T, useIntl } from 'react-intl'; import { FormattedMessage as T } from 'components';
import intl from 'react-intl-universal';
import { Intent, Alert } from '@blueprintjs/core'; import { Intent, Alert } from '@blueprintjs/core';
import { AppToaster } from 'components'; import { AppToaster } from 'components';
@@ -22,7 +23,7 @@ function AccountInactivateAlert({
// #withAlertActions // #withAlertActions
closeAlert, closeAlert,
}) { }) {
const { formatMessage } = useIntl();
const { const {
mutateAsync: inactivateAccount, mutateAsync: inactivateAccount,
isLoading isLoading
@@ -35,9 +36,7 @@ function AccountInactivateAlert({
const handleConfirmAccountActive = () => { const handleConfirmAccountActive = () => {
inactivateAccount(accountId).then(() => { inactivateAccount(accountId).then(() => {
AppToaster.show({ AppToaster.show({
message: formatMessage({ message: intl.get('the_account_has_been_successfully_inactivated'),
id: 'the_account_has_been_successfully_inactivated',
}),
intent: Intent.SUCCESS, intent: Intent.SUCCESS,
}); });
}).catch(() => { }).catch(() => {

View File

@@ -1,5 +1,6 @@
import React from 'react'; import React from 'react';
import { FormattedMessage as T, useIntl } from 'react-intl'; import { FormattedMessage as T } from 'components';
import intl from 'react-intl-universal';
import { Intent, Alert } from '@blueprintjs/core'; import { Intent, Alert } from '@blueprintjs/core';
import { AppToaster } from 'components'; import { AppToaster } from 'components';
@@ -23,7 +24,7 @@ function BillDeleteAlert({
// #withAlertActions // #withAlertActions
closeAlert, closeAlert,
}) { }) {
const { formatMessage } = useIntl();
const { isLoading, mutateAsync: deleteBillMutate } = useDeleteBill(); const { isLoading, mutateAsync: deleteBillMutate } = useDeleteBill();
// Handle cancel Bill // Handle cancel Bill
@@ -36,9 +37,7 @@ function BillDeleteAlert({
deleteBillMutate(billId) deleteBillMutate(billId)
.then(() => { .then(() => {
AppToaster.show({ AppToaster.show({
message: formatMessage({ message: intl.get('the_bill_has_been_deleted_successfully'),
id: 'the_bill_has_been_deleted_successfully',
}),
intent: Intent.SUCCESS, intent: Intent.SUCCESS,
}); });
}) })

View File

@@ -1,5 +1,6 @@
import React from 'react'; import React from 'react';
import { FormattedMessage as T, useIntl } from 'react-intl'; import { FormattedMessage as T } from 'components';
import intl from 'react-intl-universal';
import { Intent, Alert } from '@blueprintjs/core'; import { Intent, Alert } from '@blueprintjs/core';
import { AppToaster } from 'components'; import { AppToaster } from 'components';
@@ -22,7 +23,7 @@ function BillOpenAlert({
// #withAlertActions // #withAlertActions
closeAlert, closeAlert,
}) { }) {
const { formatMessage } = useIntl();
const { isLoading, mutateAsync: openBillMutate } = useOpenBill(); const { isLoading, mutateAsync: openBillMutate } = useOpenBill();
// Handle cancel open bill alert. // Handle cancel open bill alert.
@@ -35,9 +36,7 @@ function BillOpenAlert({
openBillMutate(billId) openBillMutate(billId)
.then(() => { .then(() => {
AppToaster.show({ AppToaster.show({
message: formatMessage({ message: intl.get('the_bill_has_been_opened_successfully'),
id: 'the_bill_has_been_opened_successfully',
}),
intent: Intent.SUCCESS, intent: Intent.SUCCESS,
}); });
closeAlert(name); closeAlert(name);

View File

@@ -1,10 +1,8 @@
import React from 'react'; import React from 'react';
import { import intl from 'react-intl-universal';
FormattedMessage as T, import { FormattedMessage as T, FormattedHTMLMessage } from 'components';
FormattedHTMLMessage,
useIntl,
} from 'react-intl';
import { Intent, Alert } from '@blueprintjs/core'; import { Intent, Alert } from '@blueprintjs/core';
import { AppToaster } from 'components'; import { AppToaster } from 'components';
import { useDeleteCurrency } from 'hooks/query'; import { useDeleteCurrency } from 'hooks/query';
@@ -27,7 +25,7 @@ function CurrencyDeleteAlert({
// #withAlertActions // #withAlertActions
closeAlert, closeAlert,
}) { }) {
const { formatMessage } = useIntl();
const { mutateAsync: deleteCurrency, isLoading } = useDeleteCurrency(); const { mutateAsync: deleteCurrency, isLoading } = useDeleteCurrency();
// handle cancel delete currency alert. // handle cancel delete currency alert.
@@ -38,9 +36,7 @@ function CurrencyDeleteAlert({
deleteCurrency(currency_code) deleteCurrency(currency_code)
.then((response) => { .then((response) => {
AppToaster.show({ AppToaster.show({
message: formatMessage({ message: intl.get('the_currency_has_been_deleted_successfully'),
id: 'the_currency_has_been_deleted_successfully',
}),
intent: Intent.SUCCESS, intent: Intent.SUCCESS,
}); });
closeAlert(name); closeAlert(name);

View File

@@ -1,5 +1,6 @@
import React, { useCallback, useState } from 'react'; import React, { useCallback, useState } from 'react';
import { FormattedMessage as T, useIntl } from 'react-intl'; import { FormattedMessage as T } from 'components';
import intl from 'react-intl-universal';
import { Intent, Alert } from '@blueprintjs/core'; import { Intent, Alert } from '@blueprintjs/core';
import { AppToaster } from 'components'; import { AppToaster } from 'components';
import { transformErrors } from 'containers/Customers/utils'; import { transformErrors } from 'containers/Customers/utils';
@@ -22,7 +23,7 @@ function CustomerBulkDeleteAlert({
// #withAlertActions // #withAlertActions
closeAlert, closeAlert,
}) { }) {
const { formatMessage } = useIntl();
const [isLoading, setLoading] = useState(false); const [isLoading, setLoading] = useState(false);
// handle cancel delete alert. // handle cancel delete alert.
@@ -38,9 +39,7 @@ function CustomerBulkDeleteAlert({
requestDeleteBulkCustomers(customersIds) requestDeleteBulkCustomers(customersIds)
.then(() => { .then(() => {
AppToaster.show({ AppToaster.show({
message: formatMessage({ message: intl.get('the_customers_has_been_deleted_successfully'),
id: 'the_customers_has_been_deleted_successfully',
}),
intent: Intent.SUCCESS, intent: Intent.SUCCESS,
}); });
}) })
@@ -51,7 +50,7 @@ function CustomerBulkDeleteAlert({
setLoading(false); setLoading(false);
closeAlert(name); closeAlert(name);
}); });
}, [requestDeleteBulkCustomers, customersIds, formatMessage]); }, [requestDeleteBulkCustomers, customersIds]);
return ( return (
<Alert <Alert

View File

@@ -1,9 +1,6 @@
import React, { useCallback } from 'react'; import React, { useCallback } from 'react';
import { import intl from 'react-intl-universal';
FormattedMessage as T, import { FormattedMessage as T, FormattedHTMLMessage } from 'components';
FormattedHTMLMessage,
useIntl,
} from 'react-intl';
import { Intent, Alert } from '@blueprintjs/core'; import { Intent, Alert } from '@blueprintjs/core';
import { AppToaster } from 'components'; import { AppToaster } from 'components';
import { transformErrors } from 'containers/Customers/utils'; import { transformErrors } from 'containers/Customers/utils';
@@ -28,7 +25,7 @@ function CustomerDeleteAlert({
// #withAlertActions // #withAlertActions
closeAlert, closeAlert,
}) { }) {
const { formatMessage } = useIntl();
const { const {
mutateAsync: deleteCustomerMutate, mutateAsync: deleteCustomerMutate,
isLoading isLoading
@@ -44,9 +41,7 @@ function CustomerDeleteAlert({
deleteCustomerMutate(customerId) deleteCustomerMutate(customerId)
.then(() => { .then(() => {
AppToaster.show({ AppToaster.show({
message: formatMessage({ message: intl.get('the_customer_has_been_deleted_successfully'),
id: 'the_customer_has_been_deleted_successfully',
}),
intent: Intent.SUCCESS, intent: Intent.SUCCESS,
}); });
}) })
@@ -56,7 +51,7 @@ function CustomerDeleteAlert({
.finally(() => { .finally(() => {
closeAlert(name); closeAlert(name);
}); });
}, [deleteCustomerMutate, customerId, closeAlert, name, formatMessage]); }, [deleteCustomerMutate, customerId, closeAlert, name]);
return ( return (
<Alert <Alert

View File

@@ -1,5 +1,6 @@
import React, { useCallback } from 'react'; import React, { useCallback } from 'react';
import { FormattedMessage as T, useIntl } from 'react-intl'; import { FormattedMessage as T } from 'components';
import intl from 'react-intl-universal';
import { Intent, Alert } from '@blueprintjs/core'; import { Intent, Alert } from '@blueprintjs/core';
import { queryCache } from 'react-query'; import { queryCache } from 'react-query';
@@ -24,7 +25,7 @@ function EstimateApproveAlert({
// #withAlertActions // #withAlertActions
closeAlert, closeAlert,
}) { }) {
const { formatMessage } = useIntl();
const { const {
mutateAsync: deliverEstimateMutate, mutateAsync: deliverEstimateMutate,
isLoading, isLoading,
@@ -39,9 +40,7 @@ function EstimateApproveAlert({
deliverEstimateMutate(estimateId) deliverEstimateMutate(estimateId)
.then(() => { .then(() => {
AppToaster.show({ AppToaster.show({
message: formatMessage({ message: intl.get('the_estimate_has_been_approved_successfully'),
id: 'the_estimate_has_been_approved_successfully',
}),
intent: Intent.SUCCESS, intent: Intent.SUCCESS,
}); });
queryCache.invalidateQueries('estimates-table'); queryCache.invalidateQueries('estimates-table');
@@ -50,7 +49,7 @@ function EstimateApproveAlert({
.finally(() => { .finally(() => {
closeAlert(name); closeAlert(name);
}); });
}, [estimateId, deliverEstimateMutate, closeAlert, name, formatMessage]); }, [estimateId, deliverEstimateMutate, closeAlert, name]);
return ( return (
<Alert <Alert

View File

@@ -1,10 +1,8 @@
import React, { useCallback } from 'react'; import React, { useCallback } from 'react';
import { import intl from 'react-intl-universal';
FormattedMessage as T, import { FormattedMessage as T, FormattedHTMLMessage } from 'components';
FormattedHTMLMessage,
useIntl,
} from 'react-intl';
import { Intent, Alert } from '@blueprintjs/core'; import { Intent, Alert } from '@blueprintjs/core';
import { useDeleteEstimate } from 'hooks/query'; import { useDeleteEstimate } from 'hooks/query';
import { AppToaster } from 'components'; import { AppToaster } from 'components';
@@ -27,7 +25,7 @@ function EstimateDeleteAlert({
// #withAlertActions // #withAlertActions
closeAlert, closeAlert,
}) { }) {
const { formatMessage } = useIntl();
const { mutateAsync: deleteEstimateMutate, isLoading } = useDeleteEstimate(); const { mutateAsync: deleteEstimateMutate, isLoading } = useDeleteEstimate();
// handle cancel delete alert. // handle cancel delete alert.
@@ -40,9 +38,7 @@ function EstimateDeleteAlert({
deleteEstimateMutate(estimateId) deleteEstimateMutate(estimateId)
.then(() => { .then(() => {
AppToaster.show({ AppToaster.show({
message: formatMessage({ message: intl.get('the_estimate_has_been_deleted_successfully'),
id: 'the_estimate_has_been_deleted_successfully',
}),
intent: Intent.SUCCESS, intent: Intent.SUCCESS,
}); });
}) })

View File

@@ -1,5 +1,6 @@
import React from 'react'; import React from 'react';
import { FormattedMessage as T, useIntl } from 'react-intl'; import { FormattedMessage as T } from 'components';
import intl from 'react-intl-universal';
import { Intent, Alert } from '@blueprintjs/core'; import { Intent, Alert } from '@blueprintjs/core';
import { useDeliverEstimate } from 'hooks/query'; import { useDeliverEstimate } from 'hooks/query';
@@ -23,7 +24,7 @@ function EstimateDeliveredAlert({
// #withAlertActions // #withAlertActions
closeAlert, closeAlert,
}) { }) {
const { formatMessage } = useIntl();
const { mutateAsync: deliverEstimateMutate, isLoading } = useDeliverEstimate(); const { mutateAsync: deliverEstimateMutate, isLoading } = useDeliverEstimate();
// Handle cancel delivered estimate alert. // Handle cancel delivered estimate alert.
@@ -36,9 +37,7 @@ function EstimateDeliveredAlert({
deliverEstimateMutate(estimateId) deliverEstimateMutate(estimateId)
.then(() => { .then(() => {
AppToaster.show({ AppToaster.show({
message: formatMessage({ message: intl.get('the_estimate_has_been_delivered_successfully'),
id: 'the_estimate_has_been_delivered_successfully',
}),
intent: Intent.SUCCESS, intent: Intent.SUCCESS,
}) })
}) })

View File

@@ -1,5 +1,6 @@
import React from 'react'; import React from 'react';
import { FormattedMessage as T, useIntl } from 'react-intl'; import { FormattedMessage as T } from 'components';
import intl from 'react-intl-universal';
import { Intent, Alert } from '@blueprintjs/core'; import { Intent, Alert } from '@blueprintjs/core';
import { AppToaster } from 'components'; import { AppToaster } from 'components';
@@ -23,7 +24,7 @@ function EstimateRejectAlert({
// #withAlertActions // #withAlertActions
closeAlert, closeAlert,
}) { }) {
const { formatMessage } = useIntl();
const { const {
mutateAsync: rejectEstimateMutate, mutateAsync: rejectEstimateMutate,
isLoading isLoading
@@ -39,9 +40,7 @@ function EstimateRejectAlert({
rejectEstimateMutate(estimateId) rejectEstimateMutate(estimateId)
.then(() => { .then(() => {
AppToaster.show({ AppToaster.show({
message: formatMessage({ message: intl.get('the_estimate_has_been_rejected_successfully'),
id: 'the_estimate_has_been_rejected_successfully',
}),
intent: Intent.SUCCESS, intent: Intent.SUCCESS,
}); });
}) })

View File

@@ -1,5 +1,6 @@
import React, { useState } from 'react'; import React, { useState } from 'react';
import { FormattedMessage as T, useIntl } from 'react-intl'; import { FormattedMessage as T } from 'components';
import intl from 'react-intl-universal';
import { Intent, Alert } from '@blueprintjs/core'; import { Intent, Alert } from '@blueprintjs/core';
import { size } from 'lodash'; import { size } from 'lodash';
import { AppToaster } from 'components'; import { AppToaster } from 'components';

View File

@@ -1,9 +1,6 @@
import React from 'react'; import React from 'react';
import { import intl from 'react-intl-universal';
FormattedMessage as T, import { FormattedMessage as T, FormattedHTMLMessage } from 'components';
FormattedHTMLMessage,
useIntl,
} from 'react-intl';
import { Intent, Alert } from '@blueprintjs/core'; import { Intent, Alert } from '@blueprintjs/core';
import { AppToaster } from 'components'; import { AppToaster } from 'components';
@@ -30,7 +27,7 @@ function ExchangeRateDeleteAlert({
mutateAsync: deleteExchangeRate, mutateAsync: deleteExchangeRate,
isLoading, isLoading,
} = useDeleteExchangeRate(); } = useDeleteExchangeRate();
const { formatMessage } = useIntl();
// Handle cancel delete exchange rate alert. // Handle cancel delete exchange rate alert.
const handleCancelExchangeRateDelete = () => closeAlert(name); const handleCancelExchangeRateDelete = () => closeAlert(name);
@@ -39,9 +36,7 @@ function ExchangeRateDeleteAlert({
deleteExchangeRate(exchangeRateId) deleteExchangeRate(exchangeRateId)
.then((response) => { .then((response) => {
AppToaster.show({ AppToaster.show({
message: formatMessage({ message: intl.get('the_exchange_rates_has_been_deleted_successfully'),
id: 'the_exchange_rates_has_been_deleted_successfully',
}),
intent: Intent.SUCCESS, intent: Intent.SUCCESS,
}); });
closeAlert(name); closeAlert(name);

View File

@@ -1,5 +1,6 @@
import React from 'react'; import React from 'react';
import { FormattedMessage as T, useIntl } from 'react-intl'; import { FormattedMessage as T } from 'components';
import intl from 'react-intl-universal';
import { Intent, Alert } from '@blueprintjs/core'; import { Intent, Alert } from '@blueprintjs/core';
import { AppToaster } from 'components'; import { AppToaster } from 'components';

View File

@@ -1,5 +1,6 @@
import React from 'react'; import React from 'react';
import { FormattedMessage as T, useIntl } from 'react-intl'; import { FormattedMessage as T } from 'components';
import intl from 'react-intl-universal';
import { Intent, Alert } from '@blueprintjs/core'; import { Intent, Alert } from '@blueprintjs/core';
import { AppToaster } from 'components'; import { AppToaster } from 'components';
@@ -20,7 +21,7 @@ function ExpenseDeleteAlert({
isOpen, isOpen,
payload: { expenseId }, payload: { expenseId },
}) { }) {
const { formatMessage } = useIntl();
const { const {
mutateAsync: deleteExpenseMutate, mutateAsync: deleteExpenseMutate,
isLoading, isLoading,
@@ -35,8 +36,8 @@ function ExpenseDeleteAlert({
const handleConfirmExpenseDelete = () => { const handleConfirmExpenseDelete = () => {
deleteExpenseMutate(expenseId).then(() => { deleteExpenseMutate(expenseId).then(() => {
AppToaster.show({ AppToaster.show({
message: formatMessage( message: intl.get(
{ id: 'the_expense_has_been_deleted_successfully' }, 'the_expense_has_been_deleted_successfully',
{ number: expenseId }, { number: expenseId },
), ),
intent: Intent.SUCCESS, intent: Intent.SUCCESS,

View File

@@ -1,6 +1,6 @@
import React from 'react'; import React from 'react';
import { Intent, Alert } from '@blueprintjs/core'; import { Intent, Alert } from '@blueprintjs/core';
import { FormattedMessage as T } from 'react-intl'; import { FormattedMessage as T } from 'components';
import withAlertActions from 'containers/Alert/withAlertActions'; import withAlertActions from 'containers/Alert/withAlertActions';
import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect'; import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect';

View File

@@ -1,5 +1,6 @@
import React from 'react'; import React from 'react';
import { FormattedMessage as T, useIntl } from 'react-intl'; import { FormattedMessage as T } from 'components';
import intl from 'react-intl-universal';
import { Intent, Alert } from '@blueprintjs/core'; import { Intent, Alert } from '@blueprintjs/core';
import { AppToaster } from 'components'; import { AppToaster } from 'components';
@@ -20,7 +21,7 @@ function ExpensePublishAlert({
payload: { expenseId }, payload: { expenseId },
isOpen, isOpen,
}) { }) {
const { formatMessage } = useIntl();
const { mutateAsync: publishExpenseMutate, isLoading } = usePublishExpense(); const { mutateAsync: publishExpenseMutate, isLoading } = usePublishExpense();
const handleCancelPublishExpense = () => { const handleCancelPublishExpense = () => {
@@ -32,9 +33,7 @@ function ExpensePublishAlert({
publishExpenseMutate(expenseId) publishExpenseMutate(expenseId)
.then(() => { .then(() => {
AppToaster.show({ AppToaster.show({
message: formatMessage({ message: intl.get('the_expense_has_been_published'),
id: 'the_expense_has_been_published',
}),
intent: Intent.SUCCESS, intent: Intent.SUCCESS,
}); });
closeAlert(name) closeAlert(name)

View File

@@ -1,9 +1,6 @@
import React from 'react'; import React from 'react';
import { import intl from 'react-intl-universal';
FormattedMessage as T, import { FormattedMessage as T, FormattedHTMLMessage } from 'components';
FormattedHTMLMessage,
useIntl,
} from 'react-intl';
import { Intent, Alert } from '@blueprintjs/core'; import { Intent, Alert } from '@blueprintjs/core';
import { AppToaster } from 'components'; import { AppToaster } from 'components';
import { useDeleteInvoice } from 'hooks/query'; import { useDeleteInvoice } from 'hooks/query';
@@ -28,7 +25,7 @@ function InvoiceDeleteAlert({
// #withAlertActions // #withAlertActions
closeAlert, closeAlert,
}) { }) {
const { formatMessage } = useIntl();
const { mutateAsync: deleteInvoiceMutate, isLoading } = useDeleteInvoice(); const { mutateAsync: deleteInvoiceMutate, isLoading } = useDeleteInvoice();
// handle cancel delete invoice alert. // handle cancel delete invoice alert.
@@ -41,9 +38,7 @@ function InvoiceDeleteAlert({
deleteInvoiceMutate(invoiceId) deleteInvoiceMutate(invoiceId)
.then(() => { .then(() => {
AppToaster.show({ AppToaster.show({
message: formatMessage({ message: intl.get('the_invoice_has_been_deleted_successfully'),
id: 'the_invoice_has_been_deleted_successfully',
}),
intent: Intent.SUCCESS, intent: Intent.SUCCESS,
}); });
}) })

View File

@@ -1,5 +1,6 @@
import React from 'react'; import React from 'react';
import { FormattedMessage as T, useIntl } from 'react-intl'; import { FormattedMessage as T } from 'components';
import intl from 'react-intl-universal';
import { Intent, Alert } from '@blueprintjs/core'; import { Intent, Alert } from '@blueprintjs/core';
import { useDeliverInvoice } from 'hooks/query'; import { useDeliverInvoice } from 'hooks/query';
@@ -23,7 +24,7 @@ function InvoiceDeliverAlert({
// #withAlertActions // #withAlertActions
closeAlert, closeAlert,
}) { }) {
const { formatMessage } = useIntl();
const { const {
mutateAsync: deliverInvoiceMutate, mutateAsync: deliverInvoiceMutate,
isLoading isLoading
@@ -39,9 +40,7 @@ function InvoiceDeliverAlert({
deliverInvoiceMutate(invoiceId) deliverInvoiceMutate(invoiceId)
.then(() => { .then(() => {
AppToaster.show({ AppToaster.show({
message: formatMessage({ message: intl.get('the_invoice_has_been_delivered_successfully'),
id: 'the_invoice_has_been_delivered_successfully',
}),
intent: Intent.SUCCESS, intent: Intent.SUCCESS,
}); });
}) })

View File

@@ -1,9 +1,6 @@
import React from 'react'; import React from 'react';
import { import intl from 'react-intl-universal';
FormattedMessage as T, import { FormattedMessage as T, FormattedHTMLMessage } from 'components';
FormattedHTMLMessage,
useIntl,
} from 'react-intl';
import { Intent, Alert } from '@blueprintjs/core'; import { Intent, Alert } from '@blueprintjs/core';
import { AppToaster } from 'components'; import { AppToaster } from 'components';
@@ -28,7 +25,7 @@ function InventoryAdjustmentDeleteAlert({
// #withAlertActions // #withAlertActions
closeAlert, closeAlert,
}) { }) {
const { formatMessage } = useIntl();
const { const {
mutateAsync: deleteInventoryAdjMutate, mutateAsync: deleteInventoryAdjMutate,
isLoading isLoading
@@ -44,9 +41,7 @@ function InventoryAdjustmentDeleteAlert({
deleteInventoryAdjMutate(inventoryId) deleteInventoryAdjMutate(inventoryId)
.then(() => { .then(() => {
AppToaster.show({ AppToaster.show({
message: formatMessage({ message: intl.get('the_adjustment_has_been_deleted_successfully'),
id: 'the_adjustment_has_been_deleted_successfully',
}),
intent: Intent.SUCCESS, intent: Intent.SUCCESS,
}); });
}) })

View File

@@ -1,5 +1,6 @@
import React from 'react'; import React from 'react';
import { FormattedMessage as T, useIntl } from 'react-intl'; import { FormattedMessage as T } from 'components';
import intl from 'react-intl-universal';
import { Intent, Alert } from '@blueprintjs/core'; import { Intent, Alert } from '@blueprintjs/core';
import { AppToaster } from 'components'; import { AppToaster } from 'components';
@@ -25,7 +26,7 @@ function ItemActivateAlert({
// #withAlertActions // #withAlertActions
closeAlert, closeAlert,
}) { }) {
const { formatMessage } = useIntl();
const { mutateAsync: activateItem, isLoading } = useActivateItem(); const { mutateAsync: activateItem, isLoading } = useActivateItem();
// Handle activate item alert cancel. // Handle activate item alert cancel.
@@ -38,9 +39,7 @@ function ItemActivateAlert({
activateItem(itemId) activateItem(itemId)
.then(() => { .then(() => {
AppToaster.show({ AppToaster.show({
message: formatMessage({ message: intl.get('the_item_has_been_activated_successfully'),
id: 'the_item_has_been_activated_successfully',
}),
intent: Intent.SUCCESS, intent: Intent.SUCCESS,
}); });
}) })

View File

@@ -1,5 +1,6 @@
import React, { useState } from 'react'; import React, { useState } from 'react';
import { FormattedMessage as T, useIntl } from 'react-intl'; import { FormattedMessage as T } from 'components';
import intl from 'react-intl-universal';
import { Intent, Alert } from '@blueprintjs/core'; import { Intent, Alert } from '@blueprintjs/core';
import { size } from 'lodash'; import { size } from 'lodash';
import { AppToaster } from 'components'; import { AppToaster } from 'components';
@@ -26,7 +27,7 @@ function ItemBulkDeleteAlert({
// #withAlertActions // #withAlertActions
closeAlert, closeAlert,
}) { }) {
const { formatMessage } = useIntl();
const [isLoading, setLoading] = useState(false); const [isLoading, setLoading] = useState(false);
// handle cancel item bulk delete alert. // handle cancel item bulk delete alert.
@@ -39,9 +40,7 @@ function ItemBulkDeleteAlert({
requestDeleteBulkItems(itemsIds) requestDeleteBulkItems(itemsIds)
.then(() => { .then(() => {
AppToaster.show({ AppToaster.show({
message: formatMessage({ message: intl.get('the_items_has_been_deleted_successfully'),
id: 'the_items_has_been_deleted_successfully',
}),
intent: Intent.SUCCESS, intent: Intent.SUCCESS,
}); });
}) })

View File

@@ -1,9 +1,6 @@
import React, { useState } from 'react'; import React, { useState } from 'react';
import { import intl from 'react-intl-universal';
FormattedMessage as T, import { FormattedMessage as T, FormattedHTMLMessage } from 'components';
FormattedHTMLMessage,
useIntl,
} from 'react-intl';
import { Intent, Alert } from '@blueprintjs/core'; import { Intent, Alert } from '@blueprintjs/core';
import { size } from 'lodash'; import { size } from 'lodash';
import { AppToaster } from 'components'; import { AppToaster } from 'components';
@@ -30,7 +27,7 @@ function ItemCategoryBulkDeleteAlert({
// #withAlertActions // #withAlertActions
closeAlert, closeAlert,
}) { }) {
const { formatMessage } = useIntl();
const [isLoading, setLoading] = useState(false); const [isLoading, setLoading] = useState(false);
// handle cancel bulk delete alert. // handle cancel bulk delete alert.
@@ -44,9 +41,7 @@ function ItemCategoryBulkDeleteAlert({
requestDeleteBulkItemCategories(itemCategoriesIds) requestDeleteBulkItemCategories(itemCategoriesIds)
.then(() => { .then(() => {
AppToaster.show({ AppToaster.show({
message: formatMessage({ message: intl.get('the_item_categories_has_been_deleted_successfully'),
id: 'the_item_categories_has_been_deleted_successfully',
}),
intent: Intent.SUCCESS, intent: Intent.SUCCESS,
}); });
}) })

View File

@@ -1,9 +1,6 @@
import React from 'react'; import React from 'react';
import { import intl from 'react-intl-universal';
FormattedMessage as T, import { FormattedMessage as T, FormattedHTMLMessage } from 'components';
FormattedHTMLMessage,
useIntl,
} from 'react-intl';
import { Intent, Alert } from '@blueprintjs/core'; import { Intent, Alert } from '@blueprintjs/core';
import { useDeleteItemCategory } from 'hooks/query'; import { useDeleteItemCategory } from 'hooks/query';
@@ -27,7 +24,7 @@ function ItemCategoryDeleteAlert({
// #withAlertActions // #withAlertActions
closeAlert, closeAlert,
}) { }) {
const { formatMessage } = useIntl();
const { const {
mutateAsync: deleteItemCategory, mutateAsync: deleteItemCategory,
isLoading, isLoading,
@@ -43,9 +40,7 @@ function ItemCategoryDeleteAlert({
deleteItemCategory(itemCategoryId) deleteItemCategory(itemCategoryId)
.then(() => { .then(() => {
AppToaster.show({ AppToaster.show({
message: formatMessage({ message: intl.get('the_item_category_has_been_deleted_successfully'),
id: 'the_item_category_has_been_deleted_successfully',
}),
intent: Intent.SUCCESS, intent: Intent.SUCCESS,
}); });
}) })

View File

@@ -1,9 +1,6 @@
import React from 'react'; import React from 'react';
import { import intl from 'react-intl-universal';
FormattedMessage as T, import { FormattedMessage as T, FormattedHTMLMessage } from 'components';
FormattedHTMLMessage,
useIntl,
} from 'react-intl';
import { Intent, Alert } from '@blueprintjs/core'; import { Intent, Alert } from '@blueprintjs/core';
import { AppToaster } from 'components'; import { AppToaster } from 'components';
@@ -33,7 +30,7 @@ function ItemDeleteAlert({
setItemsTableState, setItemsTableState,
}) { }) {
const { mutateAsync: deleteItem, isLoading } = useDeleteItem(); const { mutateAsync: deleteItem, isLoading } = useDeleteItem();
const { formatMessage } = useIntl();
// Handle cancel delete item alert. // Handle cancel delete item alert.
const handleCancelItemDelete = () => { const handleCancelItemDelete = () => {
@@ -45,9 +42,7 @@ function ItemDeleteAlert({
deleteItem(itemId) deleteItem(itemId)
.then(() => { .then(() => {
AppToaster.show({ AppToaster.show({
message: formatMessage({ message: intl.get('the_item_has_been_deleted_successfully'),
id: 'the_item_has_been_deleted_successfully',
}),
intent: Intent.SUCCESS, intent: Intent.SUCCESS,
}); });
// Reset to page number one. // Reset to page number one.

View File

@@ -1,5 +1,6 @@
import React from 'react'; import React from 'react';
import { FormattedMessage as T, useIntl } from 'react-intl'; import { FormattedMessage as T } from 'components';
import intl from 'react-intl-universal';
import { Intent, Alert } from '@blueprintjs/core'; import { Intent, Alert } from '@blueprintjs/core';
import { AppToaster } from 'components'; import { AppToaster } from 'components';
@@ -23,7 +24,7 @@ function ItemInactivateAlert({
// #withAlertActions // #withAlertActions
closeAlert, closeAlert,
}) { }) {
const { formatMessage } = useIntl();
const { mutateAsync: inactivateItem, isLoading } = useInactivateItem(); const { mutateAsync: inactivateItem, isLoading } = useInactivateItem();
// Handle cancel inactivate alert. // Handle cancel inactivate alert.
@@ -36,9 +37,7 @@ function ItemInactivateAlert({
inactivateItem(itemId) inactivateItem(itemId)
.then(() => { .then(() => {
AppToaster.show({ AppToaster.show({
message: formatMessage({ message: intl.get('the_item_has_been_inactivated_successfully'),
id: 'the_item_has_been_inactivated_successfully',
}),
intent: Intent.SUCCESS, intent: Intent.SUCCESS,
}); });
}) })

View File

@@ -1,6 +1,6 @@
import React from 'react'; import React from 'react';
import { Intent, Alert } from '@blueprintjs/core'; import { Intent, Alert } from '@blueprintjs/core';
import { FormattedMessage as T } from 'react-intl'; import { FormattedMessage as T } from 'components';
import withAlertActions from 'containers/Alert/withAlertActions'; import withAlertActions from 'containers/Alert/withAlertActions';
import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect'; import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect';

View File

@@ -1,6 +1,7 @@
import React from 'react'; import React from 'react';
import { Intent, Alert } from '@blueprintjs/core'; import { Intent, Alert } from '@blueprintjs/core';
import { FormattedMessage as T, useIntl } from 'react-intl'; import { FormattedMessage as T } from 'components';
import intl from 'react-intl-universal';
import { useDeleteJournal } from 'hooks/query'; import { useDeleteJournal } from 'hooks/query';
import { AppToaster } from 'components'; import { AppToaster } from 'components';
@@ -23,7 +24,7 @@ function JournalDeleteAlert({
// #withAlertActions // #withAlertActions
closeAlert, closeAlert,
}) { }) {
const { formatMessage } = useIntl();
const { mutateAsync: deleteJournalMutate, isLoading } = useDeleteJournal(); const { mutateAsync: deleteJournalMutate, isLoading } = useDeleteJournal();
// Handle cancel delete manual journal. // Handle cancel delete manual journal.
@@ -36,8 +37,8 @@ function JournalDeleteAlert({
deleteJournalMutate(manualJournalId) deleteJournalMutate(manualJournalId)
.then(() => { .then(() => {
AppToaster.show({ AppToaster.show({
message: formatMessage( message: intl.get(
{ id: 'the_journal_has_been_deleted_successfully' }, 'the_journal_has_been_deleted_successfully',
{ number: journalNumber }, { number: journalNumber },
), ),
intent: Intent.SUCCESS, intent: Intent.SUCCESS,

View File

@@ -1,6 +1,6 @@
import React from 'react'; import React from 'react';
import { Intent, Alert } from '@blueprintjs/core'; import { Intent, Alert } from '@blueprintjs/core';
import { FormattedMessage as T } from 'react-intl'; import { FormattedMessage as T } from 'components';
import withAlertActions from 'containers/Alert/withAlertActions'; import withAlertActions from 'containers/Alert/withAlertActions';
import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect'; import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect';

View File

@@ -1,6 +1,7 @@
import React from 'react'; import React from 'react';
import { Intent, Alert } from '@blueprintjs/core'; import { Intent, Alert } from '@blueprintjs/core';
import { FormattedMessage as T, useIntl } from 'react-intl'; import { FormattedMessage as T } from 'components';
import intl from 'react-intl-universal';
import { usePublishJournal } from 'hooks/query'; import { usePublishJournal } from 'hooks/query';
import { AppToaster } from 'components'; import { AppToaster } from 'components';
@@ -23,7 +24,7 @@ function JournalPublishAlert({
// #withAlertActions // #withAlertActions
closeAlert, closeAlert,
}) { }) {
const { formatMessage } = useIntl();
const { mutateAsync: publishJournalMutate, isLoading } = usePublishJournal(); const { mutateAsync: publishJournalMutate, isLoading } = usePublishJournal();
// Handle cancel manual journal alert. // Handle cancel manual journal alert.
@@ -36,9 +37,7 @@ function JournalPublishAlert({
publishJournalMutate(manualJournalId) publishJournalMutate(manualJournalId)
.then(() => { .then(() => {
AppToaster.show({ AppToaster.show({
message: formatMessage({ message: intl.get('the_manual_journal_has_been_published'),
id: 'the_manual_journal_has_been_published',
}),
intent: Intent.SUCCESS, intent: Intent.SUCCESS,
}); });
}) })

Some files were not shown because too many files have changed in this diff Show More