// @ts-nocheck import React from 'react'; import styled from 'styled-components'; import classNames from 'classnames'; import { Form } from 'formik'; import { Button, FormGroup, InputGroup, Intent } from '@blueprintjs/core'; import { TimezonePicker } from '@blueprintjs/timezone'; import { ErrorMessage, FastField } from 'formik'; import { useHistory } from 'react-router-dom'; import { ListSelect, FieldRequiredHint, FormattedMessage as T, } from '@/components'; import { inputIntent } from '@/utils'; import { CLASSES } from '@/constants/classes'; import { getCountries } from '@/constants/countries'; import { getAllCurrenciesOptions } from '@/constants/currencies'; import { getFiscalYear } from '@/constants/fiscalYearOptions'; import { getLanguages } from '@/constants/languagesOptions'; import { useGeneralFormContext } from './GeneralFormProvider'; import { shouldBaseCurrencyUpdate } from './utils'; /** * Preferences general form. */ export default function PreferencesGeneralForm({ isSubmitting }) { const history = useHistory(); const FiscalYear = getFiscalYear(); const Countries = getCountries(); const Languages = getLanguages(); const Currencies = getAllCurrenciesOptions(); const { dateFormats, baseCurrencyMutateAbility } = useGeneralFormContext(); const baseCurrencyDisabled = baseCurrencyMutateAbility.length > 0; // Handle close click. 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={} > )} {/* ---------- Industry ---------- */} {({ 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.key); }} selectedItem={value} selectedItemProp={'key'} defaultText={} textProp={'name'} labelProp={'key'} popoverProps={{ minimal: true }} disabled={baseCurrencyDisabled} /> )} {/* --------- Fiscal Year ----------- */} {({ form, field: { value }, meta: { error, touched } }) => ( } labelInfo={} className={classNames('form-group--fiscal-year', CLASSES.FILL)} inline={true} intent={inputIntent({ error, touched })} helperText={} > { form.setFieldValue('fiscal_year', option.key); }} selectedItem={value} selectedItemProp={'key'} 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('timezone', 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.key); }} selectedItem={value} selectedItemProp={'key'} defaultText={} textProp={'label'} popoverProps={{ minimal: true }} /> )}
); } const CardFooterActions = styled.div` padding-top: 16px; border-top: 1px solid #e0e7ea; margin-top: 30px; .bp3-button { min-width: 70px; + .bp3-button { margin-left: 10px; } } `;