From 67a23ce452bbe5cdd4d37c94bd2b52e4987e67b3 Mon Sep 17 00:00:00 2001 From: elforjani3 Date: Tue, 19 May 2020 04:48:50 +0200 Subject: [PATCH] WIP feature/ Dashboard_breadcrumbs & fix_localize --- client/src/components/Breadcrumbs.js | 11 +--- .../Dashboard/DashboardBreadcrumbs.js | 61 +++++++++++-------- client/src/components/Expenses/ExpenseForm.js | 16 ++--- .../Accounting/MakeJournalEntriesForm.js | 6 +- .../containers/Authentication/InviteAccept.js | 10 +-- client/src/containers/Authentication/Login.js | 29 +++++---- .../src/containers/Authentication/Register.js | 16 ++--- .../Authentication/ResetPassword.js | 11 ++-- .../Authentication/SendResetPassword.js | 7 +-- .../containers/Dialogs/AccountFormDialog.js | 4 +- .../src/containers/Dialogs/CurrencyDialog.js | 16 +++-- .../containers/Dialogs/ExchangeRateDialog.js | 6 +- .../containers/Dialogs/InviteUserDialog.js | 8 +-- .../containers/Dialogs/ItemCategoryDialog.js | 2 +- .../src/containers/Dialogs/ItemFromDialog.js | 2 +- .../src/containers/Dialogs/UserFormDialog.js | 2 +- .../BalanceSheet/BalanceSheetHeader.js | 4 +- .../ProfitLossSheet/ProfitLossSheetHeader.js | 4 +- .../TrialBalanceSheetHeader.js | 4 +- client/src/containers/Items/ItemForm.js | 8 +-- .../containers/Preferences/General/General.js | 18 +++--- client/src/index.js | 5 ++ client/src/lang/en/index.js | 44 +++++++++---- client/src/lang/en/locale.js | 60 ++++++++++++++++++ client/src/lang/printValue.js | 48 +++++++++++++++ 25 files changed, 269 insertions(+), 133 deletions(-) create mode 100644 client/src/lang/en/locale.js create mode 100644 client/src/lang/printValue.js diff --git a/client/src/components/Breadcrumbs.js b/client/src/components/Breadcrumbs.js index e09c30a8f..9d88bd8c6 100644 --- a/client/src/components/Breadcrumbs.js +++ b/client/src/components/Breadcrumbs.js @@ -12,15 +12,6 @@ const PureBreadcrumbs = ({ breadcrumbs }) => ( ))} - - //
- // {breadcrumbs.map(({ breadcrumb, match }, index) => ( - //
- // {breadcrumb} - // {index < breadcrumbs.length - 1 && ">"} - //
- // ))} - //
); - + export default withBreadcrumbs(routes)(PureBreadcrumbs); diff --git a/client/src/components/Dashboard/DashboardBreadcrumbs.js b/client/src/components/Dashboard/DashboardBreadcrumbs.js index 82b6faa08..5093cf569 100644 --- a/client/src/components/Dashboard/DashboardBreadcrumbs.js +++ b/client/src/components/Dashboard/DashboardBreadcrumbs.js @@ -3,38 +3,47 @@ import { CollapsibleList, MenuItem, Classes, - Boundary + Boundary, } from '@blueprintjs/core'; import classNames from 'classnames'; +import withBreadcrumbs from 'react-router-breadcrumbs-hoc'; +import routes from 'routes/dashboard'; -export default function DashboardBreadcrumbs() { - function renderBreadcrumb(props) { - if (props.href != null) { - return {props.text}; - } else { - return ( +function DashboardBreadcrumbs({breadcrumbs}){ + + const renderBreadcrumb =(props)=>{ + + if(props.href != null){ + + return {props.text}; + }else{ + + return( + className={classNames(Classes.BREADCRUMB, Classes.BREADCRUMB_CURRENT)}> + {props.text} - ); + ) } } - return ( - } - visibleItemRenderer={renderBreadcrumb} - collapseFrom={Boundary.START} - visibleItemCount={0} - > - - - - - - - - ); + return( +} + visibleItemRenderer={renderBreadcrumb} + collapseFrom={Boundary.START} + visibleItemCount={0}> + + { + breadcrumbs.map(({breadcrumb,match},index)=>{ + + return + }) + } + + + ) } + +export default withBreadcrumbs(routes)(DashboardBreadcrumbs) diff --git a/client/src/components/Expenses/ExpenseForm.js b/client/src/components/Expenses/ExpenseForm.js index d305c6597..a902ac1b7 100644 --- a/client/src/components/Expenses/ExpenseForm.js +++ b/client/src/components/Expenses/ExpenseForm.js @@ -32,14 +32,14 @@ export default function ExpenseForm({ selectedPaymentAccount: null }); const validationSchema = Yup.object().shape({ - date: Yup.date().required(), - description: Yup.string().trim(), - expense_account_id: Yup.number().required(), - payment_account_id: Yup.number().required(), - amount: Yup.number().required(), - currency_code: Yup.string().required(), - publish: Yup.boolean(), - exchange_rate: Yup.number() + date: Yup.date().required().label(formatMessage({id:'date'})), + description: Yup.string().trim().label(formatMessage({id:'description'})), + expense_account_id: Yup.number().required().label(formatMessage({id:'expense_account_id'})), + payment_account_id: Yup.number().required().label(formatMessage({id:'payment_account_id'})), + amount: Yup.number().required().label(formatMessage({id:'amount'})), + currency_code: Yup.string().required().label(formatMessage({id:'currency_code_'})), + publish: Yup.boolean().label(formatMessage({id:'publish'})), + exchange_rate: Yup.number().label(formatMessage({id:'exchange_rate_'})) }); const formik = useFormik({ diff --git a/client/src/containers/Accounting/MakeJournalEntriesForm.js b/client/src/containers/Accounting/MakeJournalEntriesForm.js index 3115e8418..b663bd042 100644 --- a/client/src/containers/Accounting/MakeJournalEntriesForm.js +++ b/client/src/containers/Accounting/MakeJournalEntriesForm.js @@ -63,8 +63,8 @@ function MakeJournalEntriesForm({ }, [changePageTitle, changePageSubtitle, manualJournal]); const validationSchema = Yup.object().shape({ - journal_number: Yup.string().required(), - date: Yup.date().required(), + journal_number: Yup.string().required().label(formatMessage({id:'journal_number_'})), + date: Yup.date().required().label(formatMessage({id:'date'})), reference: Yup.string(), description: Yup.string(), entries: Yup.array().of( @@ -147,7 +147,7 @@ function MakeJournalEntriesForm({ // Validate the total credit should be eqials total debit. if (totalCredit !== totalDebit) { AppToaster.show({ - message: 'credit_and_debit_not_equal', + message: formatMessage({id:'credit_and_debit_not_equal'}), }); setSubmitting(false); return; diff --git a/client/src/containers/Authentication/InviteAccept.js b/client/src/containers/Authentication/InviteAccept.js index f7867965a..cb746408a 100644 --- a/client/src/containers/Authentication/InviteAccept.js +++ b/client/src/containers/Authentication/InviteAccept.js @@ -33,14 +33,14 @@ function Invite({ requestInviteAccept, requestInviteMetaByToken }) { }, [shown]); const ValidationSchema = Yup.object().shape({ - first_name: Yup.string().required(formatMessage({ id: 'required' })), - last_name: Yup.string().required(formatMessage({ id: 'required' })), + first_name: Yup.string().required().label(formatMessage({id:'first_name_'})), + last_name: Yup.string().required().label(formatMessage({id:'last_name_'})), phone_number: Yup.string() .matches() - .required(formatMessage({ id: 'required' })), + .required().label(formatMessage({id:''})), password: Yup.string() - .min(4, 'Password has to be longer than 4 characters!') - .required('Password is required!'), + .min(4) + .required().label(formatMessage({id:'password'})) }); const inviteMeta = useAsync(() => { diff --git a/client/src/containers/Authentication/Login.js b/client/src/containers/Authentication/Login.js index 47d33041d..fe6b47ce8 100644 --- a/client/src/containers/Authentication/Login.js +++ b/client/src/containers/Authentication/Login.js @@ -1,6 +1,8 @@ import React, { useMemo, useState } from 'react'; import { Link, useHistory } from 'react-router-dom'; import * as Yup from 'yup'; + + import { useFormik } from 'formik'; import { FormattedMessage as T, useIntl } from 'react-intl'; import { @@ -34,14 +36,15 @@ function Login({ const [shown, setShown] = useState(false); const passwordRevealer = () => { setShown(!shown); }; + // Validation schema. - const loginValidationSchema = Yup.object().shape({ + const loginValidationSchema = Yup.object().shape({ crediential: Yup.string() - .required(formatMessage({ id: 'required' })) - .email(formatMessage({ id: 'invalid_email_or_phone_number' })), + .required() + .email().label(formatMessage({id:'email'})), password: Yup.string() - .required(formatMessage({ id: 'required' })) - .min(4), + .required() + .min(4).label(formatMessage({id:'password'})) }); // Formik validation schema and submit handler. @@ -69,7 +72,7 @@ function Login({ const toastBuilders = []; if (errors.find((e) => e.type === ERRORS_TYPES.INVALID_DETAILS)) { toastBuilders.push({ - message: formatMessage({id:'email_and_password_entered_did_not_match'}), + message: formatMessage({ id: 'email_and_password_entered_did_not_match' }), intent: Intent.DANGER, }); } @@ -110,7 +113,7 @@ function Login({ } intent={(errors.crediential && touched.crediential) && Intent.DANGER} - helperText={} + helperText={} className={'form-group--crediential'} > - + } labelInfo={passwordRevealerTmp} intent={(errors.password && touched.password) && Intent.DANGER} - helperText={} - className={'form-group--password has-password-revealer'} + helperText={} + className={'form-group--password has-password-revealer'} > - +
- +
@@ -155,7 +158,7 @@ function Login({ - +