feat: migrate from CRA to Vite for speed

This commit is contained in:
Ahmed Bouhuolia
2025-11-24 14:18:56 +02:00
parent 43faa45dcf
commit caf232d928
20 changed files with 1770 additions and 6525 deletions

View File

@@ -1,13 +1,43 @@
// @ts-nocheck
import React from 'react';
import { MenuItem } from '@blueprintjs/core';
import intl from 'react-intl-universal';
import { FMultiSelect } from '../Forms';
import { accountPredicate } from './_components';
import { MenuItemNestedText } from '../Menu';
import { usePreprocessingAccounts } from './_hooks';
import { DialogsName } from '@/constants/dialogs';
import { useDialogActions } from '@/hooks/state/dashboard';
import { SelectOptionProps } from '@blueprintjs-formik/select';
interface Account {
id: number;
name: string;
code: string;
account_level: number;
account_type?: string;
account_parent_type?: string;
account_root_type?: string;
account_normal?: string;
}
interface AccountSelect extends Account, SelectOptionProps { }
type MultiSelectProps = React.ComponentProps<typeof FMultiSelect>;
interface AccountsMultiSelectProps extends Omit<MultiSelectProps, 'items'> {
items: AccountSelect[];
allowCreate?: boolean;
filterByRootTypes?: string[];
filterByParentTypes?: string[];
filterByTypes?: string[];
filterByNormal?: string[];
}
// Create new account renderer.
const createNewItemRenderer = (query, active, handleClick) => {
const createNewItemRenderer = (
query: string,
active: boolean,
handleClick: (event: React.MouseEvent<HTMLElement>) => void,
): React.ReactElement => {
return (
<MenuItem
icon="add"
@@ -18,32 +48,12 @@ const createNewItemRenderer = (query, active, handleClick) => {
);
};
/**
* Default account item renderer of the list.
* @returns {JSX.Element}
*/
const accountRenderer = (
item,
{ handleClick, modifiers, query },
{ isSelected },
) => {
if (!modifiers.matchesPredicate) {
return null;
}
return (
<MenuItem
active={modifiers.active}
disabled={modifiers.disabled}
text={<MenuItemNestedText level={item.account_level} text={item.name} />}
key={item.id}
onClick={handleClick}
icon={isSelected ? 'tick' : 'blank'}
/>
);
};
// Create new item from the given query string.
const createNewItemFromQuery = (name) => ({ name });
const createNewItemFromQuery = (query: string): SelectOptionProps => ({
label: query,
value: query,
id: 0,
});
/**
* Accounts multi-select field binded with Formik form.
@@ -59,27 +69,32 @@ export function AccountsMultiSelect({
filterByNormal,
...rest
}) {
}: AccountsMultiSelectProps): React.ReactElement {
const { openDialog } = useDialogActions();
// Filters accounts based on filter props.
const filteredAccounts = usePreprocessingAccounts(items, {
filterByParentTypes,
filterByTypes,
filterByNormal,
filterByRootTypes,
filterByParentTypes: filterByParentTypes || [],
filterByTypes: filterByTypes || [],
filterByNormal: filterByNormal || [],
filterByRootTypes: filterByRootTypes || [],
});
// Maybe inject new item props to select component.
const maybeCreateNewItemRenderer = allowCreate ? createNewItemRenderer : null;
const maybeCreateNewItemRenderer = allowCreate
? createNewItemRenderer
: undefined;
const maybeCreateNewItemFromQuery = allowCreate
? createNewItemFromQuery
: null;
: undefined;
// Handles the create item click.
const handleCreateItemClick = () => {
const handleCreateItemClick = (): void => {
openDialog(DialogsName.AccountForm);
};
return (
<FMultiSelect
<FMultiSelect<AccountSelect>
{...rest}
items={filteredAccounts}
valueAccessor={'id'}
textAccessor={'name'}
@@ -87,11 +102,9 @@ export function AccountsMultiSelect({
tagAccessor={'name'}
popoverProps={{ minimal: true }}
itemPredicate={accountPredicate}
itemRenderer={accountRenderer}
createNewItemRenderer={maybeCreateNewItemRenderer}
createNewItemFromQuery={maybeCreateNewItemFromQuery}
onCreateItemSelect={handleCreateItemClick}
{...rest}
/>
);
}

View File

@@ -1,15 +1,18 @@
// @ts-nocheck
import React, { useState, useCallback, useEffect, useMemo } from 'react';
import React, { useCallback, useMemo } from 'react';
import * as R from 'ramda';
import intl from 'react-intl-universal';
import classNames from 'classnames';
import { MenuItem } from '@blueprintjs/core';
import { Suggest } from '@blueprintjs/select';
import { CLASSES } from '@/constants/classes';
import { DialogsName } from '@/constants/dialogs';
import { MenuItemNestedText, FormattedMessage as T } from '@/components';
import {
FSuggest,
MenuItemNestedText,
FormattedMessage as T,
} from '@/components';
import { nestedArrayToflatten, filterAccountsByQuery } from '@/utils';
import withDialogActions from '@/containers/Dialog/withDialogActions';
@@ -33,14 +36,6 @@ const createNewItemFromQuery = (name) => {
};
};
// Handle input value renderer.
const handleInputValueRenderer = (inputValue) => {
if (inputValue) {
return inputValue.name.toString();
}
return '';
};
// Filters accounts items.
const filterAccountsPredicater = (query, account, _index, exactMatch) => {
const normalizedTitle = account.name.toLowerCase();
@@ -62,11 +57,7 @@ function AccountsSuggestFieldRoot({
// #ownProps
accounts,
initialAccountId,
selectedAccountId,
defaultSelectText = intl.formatMessage({ id: 'select_account' }),
popoverFill = false,
onAccountSelected,
filterByParentTypes = [],
filterByTypes = [],
@@ -81,67 +72,14 @@ function AccountsSuggestFieldRoot({
() => nestedArrayToflatten(accounts),
[accounts],
);
// Filters accounts based on filter props.
const filteredAccounts = useMemo(() => {
let filteredAccounts = filterAccountsByQuery(flattenAccounts, {
filterByRootTypes,
filterByParentTypes,
filterByTypes,
filterByNormal,
});
return filteredAccounts;
}, [
flattenAccounts,
filterByRootTypes,
filterByParentTypes,
filterByTypes,
filterByNormal,
]);
// Find initial account object to set it as default account in initial render.
const initialAccount = useMemo(
() => filteredAccounts.find((a) => a.id === initialAccountId),
[initialAccountId, filteredAccounts],
);
const [selectedAccount, setSelectedAccount] = useState(
initialAccount || null,
);
useEffect(() => {
if (typeof selectedAccountId !== 'undefined') {
const account = selectedAccountId
? filteredAccounts.find((a) => a.id === selectedAccountId)
: null;
setSelectedAccount(account);
}
}, [selectedAccountId, filteredAccounts, setSelectedAccount]);
// Account item of select accounts field.
const accountItem = useCallback((item, { handleClick, modifiers, query }) => {
return (
<MenuItem
text={<MenuItemNestedText level={item.level} text={item.name} />}
label={item.code}
key={item.id}
onClick={handleClick}
/>
);
}, []);
const handleAccountSelect = useCallback(
(account) => {
if (account.id) {
setSelectedAccount({ ...account });
onAccountSelected && onAccountSelected(account);
} else {
const handleCreateItemSelect = useCallback(
(item) => {
if (!item.id) {
openDialog(DialogsName.AccountForm);
}
},
[setSelectedAccount, onAccountSelected, openDialog],
[openDialog],
);
// Maybe inject new item props to select component.
const maybeCreateNewItemRenderer = allowCreate ? createNewItemRenderer : null;
const maybeCreateNewItemFromQuery = allowCreate
@@ -149,21 +87,15 @@ function AccountsSuggestFieldRoot({
: null;
return (
<Suggest
<FSuggest
items={filteredAccounts}
noResults={<MenuItem disabled={true} text={<T id={'no_accounts'} />} />}
itemRenderer={accountItem}
itemPredicate={filterAccountsPredicater}
onItemSelect={handleAccountSelect}
selectedItem={selectedAccount}
onCreateItemSelect={handleCreateItemSelect}
valueAccessor="id"
textAccessor="name"
labelAccessor="code"
inputProps={{ placeholder: defaultSelectText }}
resetOnClose={true}
fill={true}
resetOnClose
popoverProps={{ minimal: true, boundary: 'window' }}
inputValueRenderer={handleInputValueRenderer}
className={classNames(CLASSES.FORM_GROUP_LIST_SELECT, {
[CLASSES.SELECT_LIST_FILL_POPOVER]: popoverFill,
})}
createNewItemRenderer={maybeCreateNewItemRenderer}
createNewItemFromQuery={maybeCreateNewItemFromQuery}
{...suggestProps}

View File

@@ -36,15 +36,19 @@ function getCurrentLocal() {
/**
* Loads the localization data of the given locale.
*/
function loadLocales(currentLocale) {
return import(`../lang/${currentLocale}/index.json`);
async function loadLocales(currentLocale) {
return await import(`../lang/${currentLocale}/index.json`).then(
(module) => module.default,
);
}
/**
* Loads the localization data of yup validation library.
*/
function loadYupLocales(currentLocale) {
return import(`../lang/${currentLocale}/locale`);
async function loadYupLocales(currentLocale) {
return await import(`../lang/${currentLocale}/locale.tsx`).then(
(module) => module.locale,
);
}
/**
@@ -109,11 +113,11 @@ function useAppYupLoadLocales(currentLocale) {
React.useEffect(() => {
loadYupLocales(currentLocale)
.then(({ locale }) => {
setLocale(locale);
.then((results) => {
setLocale(results);
setIsLoading(false);
})
.then(() => {});
.then(() => { });
}, [currentLocale, stopLoading]);
// Watches the valiue to start/stop splash screen.

View File

@@ -6,10 +6,14 @@ import { Select } from '@blueprintjs/select';
export function CurrenciesSelectList({ selectProps, onItemSelect, className }) {
const currencies = [
{
id: 'USD',
code: 'USD',
name: 'USD US dollars',
key: 'USD',
},
{
id: 'CAD',
code: 'CAD',
name: 'CAD Canadian dollars',
key: 'CAD',
},
];

View File

@@ -2,20 +2,12 @@
import React from 'react';
import intl from 'react-intl-universal';
import styled from 'styled-components';
import { FastField, ErrorMessage, useFormikContext } from 'formik';
import { FastField, useFormikContext } from 'formik';
import { isEqual } from 'lodash';
import {
Classes,
FormGroup,
InputGroup,
TextArea,
Position,
ControlGroup,
} from '@blueprintjs/core';
import { Classes, Position, ControlGroup } from '@blueprintjs/core';
import { useAutofocus } from '@/hooks';
import classNames from 'classnames';
import { CLASSES, ACCOUNT_TYPE, Features } from '@/constants';
import { DateInput } from '@blueprintjs/datetime';
import {
FieldRequiredHint,
@@ -31,13 +23,13 @@ import {
ExchangeRateMutedField,
BranchSelect,
BranchSelectButton,
FFormGroup,
FInputGroup,
FDateInput,
FTextArea,
FMoneyInputGroup,
} from '@/components';
import {
inputIntent,
momentFormatter,
tansformDateValue,
handleDateChange,
} from '@/utils';
import { inputIntent, momentFormatter } from '@/utils';
import { useSetPrimaryBranchToForm } from './utils';
import { useQuickPaymentMadeContext } from './QuickPaymentMadeFormProvider';
@@ -66,7 +58,7 @@ function QuickPaymentMadeFormFields({
<FeatureCan feature={Features.Branches}>
<Row>
<Col xs={5}>
<FormGroup
<FFormGroup
label={<T id={'branch'} />}
className={classNames('form-group--select-list', Classes.FILL)}
>
@@ -76,83 +68,45 @@ function QuickPaymentMadeFormFields({
input={BranchSelectButton}
popoverProps={{ minimal: true }}
/>
</FormGroup>
</FFormGroup>
</Col>
</Row>
<BranchRowDivider />
</FeatureCan>
<Row>
{/* ------------- Vendor name ------------- */}
<Col xs={5}>
{/* ------------- Vendor name ------------- */}
<FastField name={'vendor_id'}>
{({ from, field, meta: { error, touched } }) => (
<FormGroup
label={<T id={'vendor_name'} />}
className={classNames('form-group--select-list', CLASSES.FILL)}
labelInfo={<FieldRequiredHint />}
intent={inputIntent({ error, touched })}
helperText={<ErrorMessage name={'vendor'} />}
>
<InputGroup
intent={inputIntent({ error, touched })}
minimal={true}
disabled={true}
{...field}
/>
</FormGroup>
)}
</FastField>
<FFormGroup name={'vendor_id'} label={<T id={'vendor_name'} />}>
<FInputGroup name={'vendor_id'} minimal={true} disabled={true} />
</FFormGroup>
</Col>
{/* ------------ Payment number. ------------ */}
<Col xs={5}>
{/* ------------ Payment number. ------------ */}
<FastField name={'payment_number'}>
{({ form, field, meta: { error, touched } }) => (
<FormGroup
label={<T id={'payment_no'} />}
className={('form-group--payment_number', CLASSES.FILL)}
intent={inputIntent({ error, touched })}
helperText={<ErrorMessage name="payment_number" />}
>
<InputGroup
intent={inputIntent({ error, touched })}
minimal={true}
{...field}
/>
</FormGroup>
)}
</FastField>
<FFormGroup name={'payment_number'} label={<T id={'payment_no'} />}>
<FInputGroup name={'payment_number'} minimal={true} />
</FFormGroup>
</Col>
</Row>
{/*------------ Amount Received -----------*/}
<FastField name={'amount'}>
{({
form: { values, setFieldValue },
field: { value },
meta: { error, touched },
}) => (
<FormGroup
label={<T id={'amount_received'} />}
labelInfo={<FieldRequiredHint />}
className={classNames('form-group--payment_amount', CLASSES.FILL)}
intent={inputIntent({ error, touched })}
helperText={<ErrorMessage name="amount" />}
>
<ControlGroup>
<InputPrependText text={values.currency_code} />
<MoneyInputGroup
value={value}
minimal={true}
onChange={(amount) => {
setFieldValue('amount', amount);
}}
intent={inputIntent({ error, touched })}
inputRef={(ref) => (paymentMadeFieldRef.current = ref)}
/>
</ControlGroup>
</FormGroup>
)}
</FastField>
{/*------------ Amount Received -----------*/}
<FFormGroup
name={'amount'}
label={<T id={'amount_received'} />}
labelInfo={<FieldRequiredHint />}
className={classNames('form-group--payment_amount', CLASSES.FILL)}
>
<ControlGroup>
<InputPrependText text={values.currency_code} />
<FMoneyInputGroup
name={'amount'}
minimal={true}
inputRef={(ref) => (paymentMadeFieldRef.current = ref)}
/>
</ControlGroup>
</FFormGroup>
<If condition={!isEqual(base_currency, values.currency_code)}>
{/*------------ exchange rate -----------*/}
@@ -165,95 +119,67 @@ function QuickPaymentMadeFormFields({
exchangeRate={values.exchange_rate}
/>
</If>
<Row>
<Col xs={5}>
{/* ------------- Payment date ------------- */}
<FastField name={'payment_date'}>
{({ form, field: { value }, meta: { error, touched } }) => (
<FormGroup
label={<T id={'payment_date'} />}
labelInfo={<FieldRequiredHint />}
className={classNames('form-group--select-list', CLASSES.FILL)}
intent={inputIntent({ error, touched })}
helperText={<ErrorMessage name="payment_date" />}
>
<DateInput
{...momentFormatter('YYYY/MM/DD')}
value={tansformDateValue(value)}
onChange={handleDateChange((formattedDate) => {
form.setFieldValue('payment_date', formattedDate);
})}
popoverProps={{ position: Position.BOTTOM, minimal: true }}
inputProps={{
leftIcon: <Icon icon={'date-range'} />,
}}
/>
</FormGroup>
)}
</FastField>
<FFormGroup
name={'payment_date'}
label={<T id={'payment_date'} />}
labelInfo={<FieldRequiredHint />}
className={classNames('form-group--select-list', CLASSES.FILL)}
>
<FDateInput
{...momentFormatter('YYYY/MM/DD')}
name={'payment_date'}
popoverProps={{ position: Position.BOTTOM, minimal: true }}
inputProps={{
leftIcon: <Icon icon={'date-range'} />,
}}
/>
</FFormGroup>
</Col>
<Col xs={5}>
{/* ------------ payment account ------------ */}
<FastField name={'payment_account_id'}>
{({ form, field: { value }, meta: { error, touched } }) => (
<FormGroup
label={<T id={'payment_account'} />}
className={classNames(
'form-group--payment_account_id',
'form-group--select-list',
CLASSES.FILL,
)}
labelInfo={<FieldRequiredHint />}
intent={inputIntent({ error, touched })}
helperText={<ErrorMessage name={'payment_account_id'} />}
>
<AccountsSuggestField
accounts={accounts}
onAccountSelected={({ id }) =>
form.setFieldValue('payment_account_id', id)
}
inputProps={{
placeholder: intl.get('select_account'),
}}
filterByTypes={[
ACCOUNT_TYPE.CASH,
ACCOUNT_TYPE.BANK,
ACCOUNT_TYPE.OTHER_CURRENT_ASSET,
]}
/>
</FormGroup>
)}
</FastField>
<FFormGroup
name={'payment_account_id'}
label={<T id={'payment_account'} />}
>
<AccountsSuggestField
accounts={accounts}
onAccountSelected={({ id }) =>
form.setFieldValue('payment_account_id', id)
}
inputProps={{
placeholder: intl.get('select_account'),
}}
filterByTypes={[
ACCOUNT_TYPE.CASH,
ACCOUNT_TYPE.BANK,
ACCOUNT_TYPE.OTHER_CURRENT_ASSET,
]}
/>
</FFormGroup>
</Col>
</Row>
{/* ------------ Reference No. ------------ */}
<FastField name={'reference'}>
{({ form, field, meta: { error, touched } }) => (
<FormGroup
label={<T id={'reference'} />}
className={classNames('form-group--reference', CLASSES.FILL)}
intent={inputIntent({ error, touched })}
helperText={<ErrorMessage name="reference" />}
>
<InputGroup
intent={inputIntent({ error, touched })}
minimal={true}
{...field}
/>
</FormGroup>
)}
</FastField>
<FFormGroup
name={'reference'}
label={<T id={'reference'} />}
className={classNames('form-group--reference', CLASSES.FILL)}
>
<FInputGroup name={'reference'} minimal={true} />
</FFormGroup>
{/* --------- Statement --------- */}
<FastField name={'statement'}>
{({ form, field, meta: { error, touched } }) => (
<FormGroup
label={<T id={'statement'} />}
className={'form-group--statement'}
>
<TextArea growVertically={true} {...field} />
</FormGroup>
)}
</FastField>
<FFormGroup
name={'statement'}
label={<T id={'statement'} />}
className={'form-group--statement'}
>
<FTextArea name={'statement'} growVertically={true} />
</FFormGroup>
</div>
);
}

View File

@@ -5,17 +5,9 @@ import intl from 'react-intl-universal';
import { FastField, ErrorMessage, useFormikContext } from 'formik';
import { useAutofocus } from '@/hooks';
import { isEqual } from 'lodash';
import {
Classes,
FormGroup,
InputGroup,
TextArea,
Position,
ControlGroup,
} from '@blueprintjs/core';
import { Classes, Position, ControlGroup } from '@blueprintjs/core';
import classNames from 'classnames';
import { CLASSES, Features, ACCOUNT_TYPE } from '@/constants';
import { DateInput } from '@blueprintjs/datetime';
import {
Row,
Col,
@@ -30,6 +22,10 @@ import {
ExchangeRateMutedField,
BranchSelect,
BranchSelectButton,
FFormGroup,
FInputGroup,
FTextArea,
FDateInput,
} from '@/components';
import {
inputIntent,
@@ -68,7 +64,7 @@ function QuickPaymentReceiveFormFields({
<FeatureCan feature={Features.Branches}>
<Row>
<Col xs={5}>
<FormGroup
<FFormGroup
label={<T id={'branch'} />}
className={classNames('form-group--select-list', Classes.FILL)}
>
@@ -78,85 +74,54 @@ function QuickPaymentReceiveFormFields({
input={BranchSelectButton}
popoverProps={{ minimal: true }}
/>
</FormGroup>
</FFormGroup>
</Col>
</Row>
<BranchRowDivider />
</FeatureCan>
<Row>
<Col xs={5}>
{/* ------------- Customer name ------------- */}
<FastField name={'customer_id'}>
{({ from, field, meta: { error, touched } }) => (
<FormGroup
label={<T id={'customer_name'} />}
className={classNames('form-group--select-list', CLASSES.FILL)}
labelInfo={<FieldRequiredHint />}
intent={inputIntent({ error, touched })}
helperText={<ErrorMessage name={'customer_id'} />}
>
<InputGroup
intent={inputIntent({ error, touched })}
minimal={true}
disabled={true}
{...field}
/>
</FormGroup>
)}
</FastField>
<FFormGroup
name={'customer_id'}
label={<T id={'customer_name'} />}
labelInfo={<FieldRequiredHint />}
>
<FInputGroup name={'customer_id'} minimal={true} disabled={true} />
</FFormGroup>
</Col>
<Col xs={5}>
{/* ------------ Payment receive no. ------------ */}
<FastField name={'payment_receive_no'}>
{({ form, field, meta: { error, touched } }) => (
<FormGroup
label={<T id={'payment_no'} />}
labelInfo={<FieldRequiredHint />}
className={('form-group--payment_receive_no', CLASSES.FILL)}
intent={inputIntent({ error, touched })}
helperText={<ErrorMessage name="payment_receive_no" />}
>
<InputGroup
intent={inputIntent({ error, touched })}
minimal={true}
{...field}
disabled={paymentReceiveAutoIncrement}
/>
</FormGroup>
)}
</FastField>
<FFormGroup
name={'payment_receive_no'}
label={<T id={'payment_no'} />}
>
<FInputGroup
name={'payment_receive_no'}
minimal={true}
disabled={paymentReceiveAutoIncrement}
/>
</FFormGroup>
</Col>
</Row>
{/*------------ Amount Received -----------*/}
<FastField name={'amount'}>
{({
form: { values, setFieldValue },
field: { value },
meta: { error, touched },
}) => (
<FormGroup
label={<T id={'amount_received'} />}
labelInfo={<FieldRequiredHint />}
className={classNames('form-group--payment_amount', CLASSES.FILL)}
intent={inputIntent({ error, touched })}
helperText={<ErrorMessage name="amount" />}
>
<ControlGroup>
<InputPrependText text={values.currency_code} />
<MoneyInputGroup
value={value}
minimal={true}
onChange={(amount) => {
setFieldValue('amount', amount);
}}
intent={inputIntent({ error, touched })}
inputRef={(ref) => (paymentReceiveFieldRef.current = ref)}
/>
</ControlGroup>
</FormGroup>
)}
</FastField>
{/* <FFormGroup name={'amount'} label={<T id={'amount_received'} />}>
<ControlGroup>
<InputPrependText text={values.currency_code} />
<MoneyInputGroup
value={value}
minimal={true}
onChange={(amount) => {
setFieldValue('amount', amount);
}}
intent={inputIntent({ error, touched })}
inputRef={(ref) => (paymentReceiveFieldRef.current = ref)}
/>
</ControlGroup>
</FFormGroup> */}
<If condition={!isEqual(base_currency, values.currency_code)}>
{/*------------ exchange rate -----------*/}
@@ -173,94 +138,53 @@ function QuickPaymentReceiveFormFields({
<Row>
<Col xs={5}>
{/* ------------- Payment date ------------- */}
<FastField name={'payment_date'}>
{({ form, field: { value }, meta: { error, touched } }) => (
<FormGroup
label={<T id={'payment_date'} />}
labelInfo={<FieldRequiredHint />}
className={classNames('form-group--select-list', CLASSES.FILL)}
intent={inputIntent({ error, touched })}
helperText={<ErrorMessage name="payment_date" />}
>
<DateInput
{...momentFormatter('YYYY/MM/DD')}
value={tansformDateValue(value)}
onChange={handleDateChange((formattedDate) => {
form.setFieldValue('payment_date', formattedDate);
})}
popoverProps={{ position: Position.BOTTOM, minimal: true }}
inputProps={{
leftIcon: <Icon icon={'date-range'} />,
}}
/>
</FormGroup>
)}
</FastField>
<FFormGroup name={'payment_date'} label={<T id={'payment_date'} />}>
<FDateInput
{...momentFormatter('YYYY/MM/DD')}
name={'payment_date'}
popoverProps={{ position: Position.BOTTOM, minimal: true }}
inputProps={{
leftIcon: <Icon icon={'date-range'} />,
}}
/>
</FFormGroup>
</Col>
<Col xs={5}>
{/* ------------ Deposit account ------------ */}
<FastField name={'deposit_account_id'}>
{({ form, field: { value }, meta: { error, touched } }) => (
<FormGroup
label={<T id={'deposit_to'} />}
className={classNames(
'form-group--deposit_account_id',
'form-group--select-list',
CLASSES.FILL,
)}
labelInfo={<FieldRequiredHint />}
intent={inputIntent({ error, touched })}
helperText={<ErrorMessage name={'deposit_account_id'} />}
>
<AccountsSuggestField
selectedAccountId={value}
accounts={accounts}
onAccountSelected={({ id }) =>
form.setFieldValue('deposit_account_id', id)
}
inputProps={{
placeholder: intl.get('select_account'),
}}
filterByTypes={[
ACCOUNT_TYPE.CASH,
ACCOUNT_TYPE.BANK,
ACCOUNT_TYPE.OTHER_CURRENT_ASSET,
]}
/>
</FormGroup>
)}
</FastField>
{/* <FFormGroup
name={'deposit_account_id'}
label={<T id={'deposit_to'} />}
>
<AccountsSuggestField
name={'deposit_account_id'}
accounts={accounts}
inputProps={{
placeholder: intl.get('select_account'),
}}
filterByTypes={[
ACCOUNT_TYPE.CASH,
ACCOUNT_TYPE.BANK,
ACCOUNT_TYPE.OTHER_CURRENT_ASSET,
]}
/>
</FFormGroup> */}
</Col>
</Row>
{/* ------------ Reference No. ------------ */}
<FastField name={'reference_no'}>
{({ form, field, meta: { error, touched } }) => (
<FormGroup
label={<T id={'reference'} />}
className={classNames('form-group--reference', CLASSES.FILL)}
intent={inputIntent({ error, touched })}
helperText={<ErrorMessage name="reference" />}
>
<InputGroup
intent={inputIntent({ error, touched })}
minimal={true}
{...field}
/>
</FormGroup>
)}
</FastField>
<FFormGroup label={<T id={'reference'} />} name={'reference_no'}>
<FInputGroup name={'reference_no'} minimal={true} />
</FFormGroup>
{/* --------- Statement --------- */}
<FastField name={'statement'}>
{({ form, field, meta: { error, touched } }) => (
<FormGroup
label={<T id={'statement'} />}
className={'form-group--statement'}
>
<TextArea growVertically={true} {...field} />
</FormGroup>
)}
</FastField>
<FFormGroup
name={'statement'}
label={<T id={'statement'} />}
className={'form-group--statement'}
>
<FTextArea name={'statement'} growVertically={true} />
</FFormGroup>
</div>
);
}

View File

@@ -2,7 +2,7 @@
import { useMutation, useQueryClient } from 'react-query';
import useApiRequest from '../useRequest';
import { useRequestQuery } from '../useQueryRequest';
import { transformPagination } from '@/utils';
import { transformPagination, transformToCamelCase } from '@/utils';
import t from './types';
const defaultPagination = {

View File

@@ -1,7 +1,7 @@
// @ts-nocheck
import { useMutation, useQueryClient } from 'react-query';
import { useRequestQuery } from '../useQueryRequest';
import { transformPagination } from '@/utils';
import { transformPagination, transformToCamelCase } from '@/utils';
import useApiRequest from '../useRequest';
import t from './types';

View File

@@ -1,4 +1,5 @@
// @ts-nocheck
import './wdyr';
import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
@@ -10,11 +11,6 @@ import App from '@/components/App';
import * as serviceWorker from '@/serviceWorker';
import { store, persistor } from '@/store/createStore';
if (process.env.NODE_ENV === 'development') {
const whyDidYouRender = require('@welldone-software/why-did-you-render');
whyDidYouRender(React, { trackAllPureComponents: false });
}
ReactDOM.render(
<Provider store={store}>
<PersistGate loading={null} persistor={persistor}>

View File

@@ -2308,5 +2308,6 @@
"api_key.important": "Important",
"api_key.display_warning": "This API key will only be shown once. Please copy and save it securely.",
"api_key.label": "API Key",
"api_key.copy_to_clipboard": "Copy to clipboard"
"api_key.copy_to_clipboard": "Copy to clipboard",
"the_expenses_has_been_deleted_successfully": "The expenses have been deleted successfully."
}

2
packages/webapp/src/vite-env.d.ts vendored Normal file
View File

@@ -0,0 +1,2 @@
/// <reference types="vite/client" />

View File

@@ -0,0 +1,7 @@
if (process.env.NODE_ENV === 'development') {
import('@welldone-software/why-did-you-render').then(({ default: whyDidYouRender }) => {
if (whyDidYouRender) {
whyDidYouRender(React, { trackAllPureComponents: false });
}
});
}