import { Form } from 'formik'; import React from 'react'; import { Button, FormGroup, InputGroup, Intent, Position, } from '@blueprintjs/core'; import classNames from 'classnames'; import { TimezonePicker } from '@blueprintjs/timezone'; import { ErrorMessage, FastField } from 'formik'; import { DateInput } from '@blueprintjs/datetime'; import { useHistory } from 'react-router-dom'; import { FormattedMessage as T } from 'components'; import { ListSelect, FieldRequiredHint } from 'components'; import { inputIntent, momentFormatter, tansformDateValue, handleDateChange, } from 'utils'; import { CLASSES } from 'common/classes'; import { getCountries } from 'common/countries'; import { getCurrencies } from 'common/currencies'; import { getFiscalYear } from 'common/fiscalYearOptions'; import { getLanguages } from 'common/languagesOptions'; import { getDateFormats } from 'common/dateFormatsOptions'; export default function PreferencesGeneralForm({}) { const history = useHistory(); const FiscalYear = getFiscalYear(); const Countries = getCountries(); const Languages = getLanguages(); const Currencies = getCurrencies(); const DataFormats = getDateFormats(); const handleCloseClick = () => { history.go(-1); }; return (
{/* ---------- Organization name ---------- */} {({ field, meta: { error, touched } }) => ( } labelInfo={} inline={true} intent={inputIntent({ error, touched })} className={'form-group--org-name'} helperText={} > )} {/* ---------- Financial starting date ---------- */} {({ form, field: { value }, meta: { error, touched } }) => ( } labelInfo={} inline={true} intent={inputIntent({ error, touched })} className={classNames('form-group--select-list', CLASSES.FILL)} helperText={} > { form.setFieldValue('financial_date_start', formattedDate); })} popoverProps={{ position: Position.BOTTOM, minimal: true }} /> )} {({ field, meta: { error, touched } }) => ( } inline={true} intent={inputIntent({ error, touched })} helperText={} className={'form-group--org-industry'} > )} {/* ---------- Location ---------- */} {({ form, field: { value }, meta: { error, touched } }) => ( } className={classNames( 'form-group--business-location', CLASSES.FILL, )} inline={true} helperText={} intent={inputIntent({ error, touched })} > { form.setFieldValue('location', value); }} selectedItem={value} selectedItemProp={'value'} defaultText={} textProp={'name'} popoverProps={{ minimal: true }} /> )} {/* ---------- Base currency ---------- */} {({ form, field: { value }, meta: { error, touched } }) => ( } labelInfo={} className={classNames('form-group--base-currency', CLASSES.FILL)} inline={true} intent={inputIntent({ error, touched })} helperText={ } > { form.setFieldValue('base_currency', currency.code); }} selectedItem={value} selectedItemProp={'code'} defaultText={} textProp={'name'} labelProp={'code'} popoverProps={{ minimal: true }} /> )} {/* --------- Fiscal Year ----------- */} {({ form, field: { value }, meta: { error, touched } }) => ( } labelInfo={} className={classNames('form-group--fiscal-year', CLASSES.FILL)} inline={true} helperText={} intent={inputIntent({ error, touched })} > form.setFieldValue('fiscal_year', value) } selectedItem={value} selectedItemProp={'value'} defaultText={} textProp={'name'} popoverProps={{ minimal: true }} /> )} {/* ---------- Language ---------- */} {({ form, field: { value }, meta: { error, touched } }) => ( } labelInfo={} inline={true} className={classNames('form-group--language', CLASSES.FILL)} intent={inputIntent({ error, touched })} helperText={} > } selectedItem={value} onItemSelect={(item) => form.setFieldValue('language', item.value) } popoverProps={{ minimal: true }} /> )} {/* ---------- Time zone ---------- */} {({ form, field: { value }, meta: { error, touched } }) => ( } labelInfo={} inline={true} className={classNames( 'form-group--time-zone', CLASSES.FORM_GROUP_LIST_SELECT, CLASSES.FILL, )} intent={inputIntent({ error, touched })} helperText={} > { form.setFieldValue('time_zone', timezone); }} valueDisplayFormat="composite" placeholder={} /> )} {/* --------- Data format ----------- */} {({ form, field: { value }, meta: { error, touched } }) => ( } labelInfo={} inline={true} className={classNames('form-group--date-format', CLASSES.FILL)} intent={inputIntent({ error, touched })} helperText={} > { form.setFieldValue('date_format', dateFormat.value); }} selectedItem={value} selectedItemProp={'value'} defaultText={} textProp={'name'} labelProp={'label'} popoverProps={{ minimal: true }} /> )}
); }