diff --git a/client/package.json b/client/package.json index 43e6e59e3..e0e0ae294 100644 --- a/client/package.json +++ b/client/package.json @@ -56,6 +56,7 @@ "lodash": "^4.17.15", "mini-css-extract-plugin": "0.9.0", "moment": "^2.24.0", + "moment-timezone": "^0.5.33", "node-sass": "^4.13.1", "optimize-css-assets-webpack-plugin": "5.0.3", "pnp-webpack-plugin": "1.6.0", diff --git a/client/src/common/currencies.js b/client/src/common/currencies.js index b47f16807..4a1f0c9ad 100644 --- a/client/src/common/currencies.js +++ b/client/src/common/currencies.js @@ -1,7 +1,23 @@ import intl from 'react-intl-universal'; +import currencies from 'js-money/lib/currency'; +import { sortBy } from 'lodash'; export const getCurrencies = () => [ { name: intl.get('us_dollar'), code: 'USD' }, { name: intl.get('euro'), code: 'EUR' }, { name: intl.get('libyan_diner'), code: 'LYD' }, ]; + +export const getAllCurrenciesOptions = () => { + const codes = Object.keys(currencies); + const sortedCodes = sortBy(codes); + + return sortedCodes.map((code) => { + const currency = currencies[code]; + + return { + key: code, + name: `${code} - ${currency.name}`, + }; + }); +}; diff --git a/client/src/common/fiscalYearOptions.js b/client/src/common/fiscalYearOptions.js index 9fd5c3845..14d887946 100644 --- a/client/src/common/fiscalYearOptions.js +++ b/client/src/common/fiscalYearOptions.js @@ -2,63 +2,51 @@ import intl from 'react-intl-universal'; export const getFiscalYear = () => [ { - id: 0, name: `${intl.get('january')} - ${intl.get('december')}`, - value: 'january', + key: 'january', }, { - id: 1, name: `${intl.get('february')} - ${intl.get('january')}`, - value: 'february', + key: 'february', }, { - id: 2, name: `${intl.get('march')} - ${intl.get('february')}`, - value: 'March', + key: 'march', }, { - id: 3, name: `${intl.get('april')} - ${intl.get('march')}`, - value: 'april', + key: 'april', }, { - id: 4, name: `${intl.get('may')} - ${intl.get('april')}`, - value: 'may', + key: 'may', }, { - id: 5, name: `${intl.get('june')} - ${intl.get('may')}`, - value: 'june', + key: 'june', }, { - id: 6, name: `${intl.get('july')} - ${intl.get('june')}`, - value: 'july', + key: 'july', }, { - id: 7, name: `${intl.get('august')} - ${intl.get('july')}`, - value: 'August', + key: 'august', }, { - id: 8, name: `${intl.get('september')} - ${intl.get('august')}`, - value: 'september', + key: 'september', }, { - id: 9, name: `${intl.get('october')} - ${intl.get('november')}`, - value: 'october', + key: 'october', }, { - id: 10, name: `${intl.get('november')} - ${intl.get('october')}`, - value: 'november', + key: 'november', }, { - id: 11, name: `${intl.get('december')} - ${intl.get('november')}`, - value: 'december', + key: 'december', }, ] \ No newline at end of file diff --git a/client/src/containers/Setup/SetupOrganization.schema.js b/client/src/containers/Setup/SetupOrganization.schema.js index b7d4c93ad..3517eb6a0 100644 --- a/client/src/containers/Setup/SetupOrganization.schema.js +++ b/client/src/containers/Setup/SetupOrganization.schema.js @@ -4,10 +4,12 @@ import intl from 'react-intl-universal'; // Retrieve the setup organization form validation. export const getSetupOrganizationValidation = () => Yup.object().shape({ - organization_name: Yup.string() + organizationName: Yup.string() .required() .label(intl.get('organization_name_')), - financialDateStart: Yup.date().required().label(intl.get('date_start_')), + location: Yup.string() + .required() + .label(intl.get('setup.organization.location')), baseCurrency: Yup.string().required().label(intl.get('base_currency_')), language: Yup.string().required().label(intl.get('language')), fiscalYear: Yup.string().required().label(intl.get('fiscal_year_')), diff --git a/client/src/containers/Setup/SetupOrganizationForm.js b/client/src/containers/Setup/SetupOrganizationForm.js index 423602d45..e09501a03 100644 --- a/client/src/containers/Setup/SetupOrganizationForm.js +++ b/client/src/containers/Setup/SetupOrganizationForm.js @@ -7,24 +7,18 @@ import { InputGroup, MenuItem, Classes, - Position, } from '@blueprintjs/core'; -import { DateInput } from '@blueprintjs/datetime'; import classNames from 'classnames'; import { TimezonePicker } from '@blueprintjs/timezone'; import { FormattedMessage as T } from 'components'; +import { getCountries } from 'common/countries'; import { Col, Row, ListSelect } from 'components'; -import { - momentFormatter, - tansformDateValue, - inputIntent, - handleDateChange, -} from 'utils'; +import { inputIntent } from 'utils'; import { getFiscalYear } from 'common/fiscalYearOptions'; import { getLanguages } from 'common/languagesOptions'; -import { getCurrencies } from 'common/currencies'; +import { getAllCurrenciesOptions } from 'common/currencies'; /** * Setup organization form. @@ -32,7 +26,8 @@ import { getCurrencies } from 'common/currencies'; export default function SetupOrganizationForm({ isSubmitting, values }) { const FiscalYear = getFiscalYear(); const Languages = getLanguages(); - const Currencies = getCurrencies(); + const currencies = getAllCurrenciesOptions(); + const countries = getCountries(); return (