This commit is contained in:
Ahmed Bouhuolia
2025-11-25 21:29:32 +02:00
parent ff04c4b762
commit adfa8852db
7 changed files with 57 additions and 58 deletions

View File

@@ -19,7 +19,7 @@ interface Account {
account_normal?: string; account_normal?: string;
} }
interface AccountSelect extends Account, SelectOptionProps { } export interface AccountSelect extends Partial<Account>, SelectOptionProps { }
type MultiSelectProps = React.ComponentProps<typeof FMultiSelect>; type MultiSelectProps = React.ComponentProps<typeof FMultiSelect>;
@@ -49,10 +49,13 @@ const createNewItemRenderer = (
}; };
// Create new item from the given query string. // Create new item from the given query string.
const createNewItemFromQuery = (query: string): SelectOptionProps => ({ const createNewItemFromQuery = (query: string): AccountSelect => ({
label: query, label: query,
value: query, value: query,
text: query,
id: 0, id: 0,
name: query,
code: query,
}); });
/** /**

View File

@@ -14,7 +14,6 @@ import {
FormattedMessage as T, FormattedMessage as T,
} from '@/components'; } from '@/components';
import { nestedArrayToflatten, filterAccountsByQuery } from '@/utils'; import { nestedArrayToflatten, filterAccountsByQuery } from '@/utils';
import withDialogActions from '@/containers/Dialog/withDialogActions'; import withDialogActions from '@/containers/Dialog/withDialogActions';
// Create new account renderer. // Create new account renderer.
@@ -31,9 +30,7 @@ const createNewItemRenderer = (query, active, handleClick) => {
// Create new item from the given query string. // Create new item from the given query string.
const createNewItemFromQuery = (name) => { const createNewItemFromQuery = (name) => {
return { return { name };
name,
};
}; };
// Filters accounts items. // Filters accounts items.
@@ -72,6 +69,22 @@ function AccountsSuggestFieldRoot({
() => nestedArrayToflatten(accounts), () => nestedArrayToflatten(accounts),
[accounts], [accounts],
); );
const filteredAccounts = useMemo(
() =>
filterAccountsByQuery(flattenAccounts, {
filterByParentTypes,
filterByTypes,
filterByNormal,
filterByRootTypes,
}),
[
flattenAccounts,
filterByParentTypes,
filterByTypes,
filterByNormal,
filterByRootTypes,
],
);
const handleCreateItemSelect = useCallback( const handleCreateItemSelect = useCallback(
(item) => { (item) => {
if (!item.id) { if (!item.id) {

View File

@@ -1,7 +1,14 @@
// @ts-nocheck // @ts-nocheck
import { AccountSelect } from "./AccountsMultiSelect";
// Filters accounts items. // Filters accounts items.
export const accountPredicate = (query, account, _index, exactMatch) => { export const accountPredicate = (
query: string,
account: AccountSelect,
_index?: number,
exactMatch?: boolean,
) => {
const normalizedTitle = account.name.toLowerCase(); const normalizedTitle = account.name.toLowerCase();
const normalizedQuery = query.toLowerCase(); const normalizedQuery = query.toLowerCase();

View File

@@ -56,7 +56,7 @@ export function SidebarMenu({ menu }) {
<div> <div>
<Menu className="sidebar-menu"> <Menu className="sidebar-menu">
{menu.map((item, index) => ( {menu.map((item, index) => (
<SidebarMenuItemComposer index={index} item={item} /> <SidebarMenuItemComposer key={index} index={index} item={item} />
))} ))}
</Menu> </Menu>
</div> </div>

View File

@@ -58,10 +58,7 @@ function QuickPaymentMadeFormFields({
<FeatureCan feature={Features.Branches}> <FeatureCan feature={Features.Branches}>
<Row> <Row>
<Col xs={5}> <Col xs={5}>
<FFormGroup <FFormGroup label={<T id={'branch'} />} name={'branch_id'}>
label={<T id={'branch'} />}
className={classNames('form-group--select-list', Classes.FILL)}
>
<BranchSelect <BranchSelect
name={'branch_id'} name={'branch_id'}
branches={branches} branches={branches}
@@ -91,15 +88,9 @@ function QuickPaymentMadeFormFields({
</Row> </Row>
{/*------------ Amount Received -----------*/} {/*------------ Amount Received -----------*/}
<FFormGroup <FFormGroup name={'amount'} label={<T id={'amount_received'} />}>
name={'amount'}
label={<T id={'amount_received'} />}
labelInfo={<FieldRequiredHint />}
className={classNames('form-group--payment_amount', CLASSES.FILL)}
>
<ControlGroup> <ControlGroup>
<InputPrependText text={values.currency_code} /> <InputPrependText text={values.currency_code} />
<FMoneyInputGroup <FMoneyInputGroup
name={'amount'} name={'amount'}
minimal={true} minimal={true}
@@ -130,8 +121,8 @@ function QuickPaymentMadeFormFields({
className={classNames('form-group--select-list', CLASSES.FILL)} className={classNames('form-group--select-list', CLASSES.FILL)}
> >
<FDateInput <FDateInput
{...momentFormatter('YYYY/MM/DD')}
name={'payment_date'} name={'payment_date'}
{...momentFormatter('YYYY/MM/DD')}
popoverProps={{ position: Position.BOTTOM, minimal: true }} popoverProps={{ position: Position.BOTTOM, minimal: true }}
inputProps={{ inputProps={{
leftIcon: <Icon icon={'date-range'} />, leftIcon: <Icon icon={'date-range'} />,
@@ -139,6 +130,7 @@ function QuickPaymentMadeFormFields({
/> />
</FFormGroup> </FFormGroup>
</Col> </Col>
<Col xs={5}> <Col xs={5}>
{/* ------------ payment account ------------ */} {/* ------------ payment account ------------ */}
<FFormGroup <FFormGroup
@@ -146,10 +138,8 @@ function QuickPaymentMadeFormFields({
label={<T id={'payment_account'} />} label={<T id={'payment_account'} />}
> >
<AccountsSuggestField <AccountsSuggestField
name={'payment_account_id'}
accounts={accounts} accounts={accounts}
onAccountSelected={({ id }) =>
form.setFieldValue('payment_account_id', id)
}
inputProps={{ inputProps={{
placeholder: intl.get('select_account'), placeholder: intl.get('select_account'),
}} }}
@@ -164,21 +154,13 @@ function QuickPaymentMadeFormFields({
</Row> </Row>
{/* ------------ Reference No. ------------ */} {/* ------------ Reference No. ------------ */}
<FFormGroup <FFormGroup name={'reference'} label={<T id={'reference'} />}>
name={'reference'}
label={<T id={'reference'} />}
className={classNames('form-group--reference', CLASSES.FILL)}
>
<FInputGroup name={'reference'} minimal={true} /> <FInputGroup name={'reference'} minimal={true} />
</FFormGroup> </FFormGroup>
{/* --------- Statement --------- */} {/* --------- Statement --------- */}
<FFormGroup <FFormGroup name={'statement'} label={<T id={'statement'} />}>
name={'statement'} <FTextArea name={'statement'} growVertically={true} fill={true} />
label={<T id={'statement'} />}
className={'form-group--statement'}
>
<FTextArea name={'statement'} growVertically={true} />
</FFormGroup> </FFormGroup>
</div> </div>
); );
@@ -190,4 +172,8 @@ export const BranchRowDivider = styled.div`
height: 1px; height: 1px;
background: #ebf1f6; background: #ebf1f6;
margin-bottom: 15px; margin-bottom: 15px;
.bp4-dark &{
background: rgba(255, 255, 255, 0.1);
}
`; `;

View File

@@ -26,17 +26,11 @@ import {
FInputGroup, FInputGroup,
FTextArea, FTextArea,
FDateInput, FDateInput,
FMoneyInputGroup,
} from '@/components'; } from '@/components';
import { import { momentFormatter, compose } from '@/utils';
inputIntent,
momentFormatter,
tansformDateValue,
handleDateChange,
compose,
} from '@/utils';
import { useSetPrimaryBranchToForm } from './utils'; import { useSetPrimaryBranchToForm } from './utils';
import { useQuickPaymentReceiveContext } from './QuickPaymentReceiveFormProvider'; import { useQuickPaymentReceiveContext } from './QuickPaymentReceiveFormProvider';
import withCurrentOrganization from '@/containers/Organization/withCurrentOrganization'; import withCurrentOrganization from '@/containers/Organization/withCurrentOrganization';
import withSettings from '@/containers/Settings/withSettings'; import withSettings from '@/containers/Settings/withSettings';
@@ -64,10 +58,7 @@ function QuickPaymentReceiveFormFields({
<FeatureCan feature={Features.Branches}> <FeatureCan feature={Features.Branches}>
<Row> <Row>
<Col xs={5}> <Col xs={5}>
<FFormGroup <FFormGroup name={'branch_id'} label={<T id={'branch'} />}>
label={<T id={'branch'} />}
className={classNames('form-group--select-list', Classes.FILL)}
>
<BranchSelect <BranchSelect
name={'branch_id'} name={'branch_id'}
branches={branches} branches={branches}
@@ -108,20 +99,16 @@ function QuickPaymentReceiveFormFields({
</Row> </Row>
{/*------------ Amount Received -----------*/} {/*------------ Amount Received -----------*/}
{/* <FFormGroup name={'amount'} label={<T id={'amount_received'} />}> <FFormGroup name={'amount'} label={<T id={'amount_received'} />}>
<ControlGroup> <ControlGroup>
<InputPrependText text={values.currency_code} /> <InputPrependText text={values.currency_code} />
<MoneyInputGroup <FMoneyInputGroup
value={value} name={'amount'}
minimal={true} minimal={true}
onChange={(amount) => {
setFieldValue('amount', amount);
}}
intent={inputIntent({ error, touched })}
inputRef={(ref) => (paymentReceiveFieldRef.current = ref)} inputRef={(ref) => (paymentReceiveFieldRef.current = ref)}
/> />
</ControlGroup> </ControlGroup>
</FFormGroup> */} </FFormGroup>
<If condition={!isEqual(base_currency, values.currency_code)}> <If condition={!isEqual(base_currency, values.currency_code)}>
{/*------------ exchange rate -----------*/} {/*------------ exchange rate -----------*/}
@@ -152,7 +139,7 @@ function QuickPaymentReceiveFormFields({
<Col xs={5}> <Col xs={5}>
{/* ------------ Deposit account ------------ */} {/* ------------ Deposit account ------------ */}
{/* <FFormGroup <FFormGroup
name={'deposit_account_id'} name={'deposit_account_id'}
label={<T id={'deposit_to'} />} label={<T id={'deposit_to'} />}
> >
@@ -168,7 +155,7 @@ function QuickPaymentReceiveFormFields({
ACCOUNT_TYPE.OTHER_CURRENT_ASSET, ACCOUNT_TYPE.OTHER_CURRENT_ASSET,
]} ]}
/> />
</FFormGroup> */} </FFormGroup>
</Col> </Col>
</Row> </Row>
@@ -200,4 +187,8 @@ export const BranchRowDivider = styled.div`
height: 1px; height: 1px;
background: #ebf1f6; background: #ebf1f6;
margin-bottom: 15px; margin-bottom: 15px;
.bp4-dark & {
background: rgba(255, 255, 255, 0.1);
}
`; `;

View File

@@ -1,4 +1,3 @@
// @ts-nocheck
import react from '@vitejs/plugin-react'; import react from '@vitejs/plugin-react';
import legacy from '@vitejs/plugin-legacy'; import legacy from '@vitejs/plugin-legacy';
import path from 'node:path'; import path from 'node:path';
@@ -62,7 +61,7 @@ export default defineConfig(({ mode }) => {
}, },
optimizeDeps: { optimizeDeps: {
esbuildOptions: { esbuildOptions: {
plugins: [fixReactVirtualized], plugins: [fixReactVirtualized as any],
}, },
}, },
}; };