// @ts-nocheck import React from 'react'; import styled from 'styled-components'; import classNames from 'classnames'; import { Form, useFormikContext } from 'formik'; import { Button, FormGroup, Intent } from '@blueprintjs/core'; import { TimezonePicker, getTimezoneMetadata } from '@blueprintjs/timezone'; import { ErrorMessage } from 'formik'; import { useHistory } from 'react-router-dom'; import { getAllCountries } from '@bigcapital/utils'; import { FieldRequiredHint, FormattedMessage as T, FFormGroup, FInputGroup, FSelect, Stack, Group, } from '@/components'; import { inputIntent } from '@/utils'; import { CLASSES } from '@/constants/classes'; import { getAllCurrenciesOptions } from '@/constants/currencies'; import { getFiscalYear } from '@/constants/fiscalYearOptions'; import { getLanguages } from '@/constants/languagesOptions'; import { useGeneralFormContext } from './GeneralFormProvider'; import { shouldBaseCurrencyUpdate } from './utils'; import { SelectButton } from '@/components/Forms/Select'; const Countries = getAllCountries(); /** * Preferences general form. */ export default function PreferencesGeneralForm({ isSubmitting }) { const history = useHistory(); const FiscalYear = getFiscalYear(); 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 ---------- */} } labelInfo={} inline={true} helperText={} fastField={true} > {/* ---------- Organization Tax Number ---------- */} } inline={true} helperText={} fastField={true} > {/* ---------- Industry ---------- */} } inline={true} fastField={true} > {/* ---------- Location ---------- */} } inline={true} fastField={true} > } popoverProps={{ minimal: true }} fastField={true} /> {/* ---------- Address ---------- */} {/* ---------- Base currency ---------- */} } labelInfo={} inline={true} helperText={ } fastField={true} shouldUpdate={shouldBaseCurrencyUpdate} > } popoverProps={{ minimal: true }} disabled={baseCurrencyDisabled} fastField={true} shouldUpdate={shouldBaseCurrencyUpdate} baseCurrencyDisabled={baseCurrencyDisabled} /> {/* --------- Fiscal Year ----------- */} } labelInfo={} inline={true} helperText={} fastField={true} > } popoverProps={{ minimal: true }} fastField={true} /> {/* ---------- Language ---------- */} } labelInfo={} inline={true} fastField={true} > } popoverProps={{ minimal: true }} fastField={true} /> {/* --------- Timezone ----------- */} {/* --------- Data format ----------- */} } labelInfo={} inline={true} helperText={} fastField={true} > } popoverProps={{ minimal: true }} fastField={true} /> ); } const CardFooterActions = styled.div` --x-color-border: #e0e7ea; --x-color-border: rgba(255, 255, 255, 0.15); padding-top: 16px; border-top: 1px solid var(--x-color-border); margin-top: 30px; .bp4-button { min-width: 70px; + .bp4-button { margin-left: 10px; } } `; function TimezoneField() { const { values, setFieldValue, touched, errors } = useFormikContext(); const value = values?.timezone; const error = errors?.timezone; const isTouched = touched?.timezone; const compositeLabel = React.useMemo(() => { const placeholder = ; if (!value) return placeholder; try { const { abbreviation, offsetAsString } = getTimezoneMetadata( value, new Date(), ); return `${value}${abbreviation ? ` (${abbreviation})` : ''} ${offsetAsString}`; } catch (e) { return value; // fallback } }, [value]); return ( } labelInfo={} inline={true} intent={inputIntent({ error, touched: isTouched })} helperText={} > setFieldValue('timezone', timezone)} popoverProps={{ minimal: true, fill: true }} fill > ); }