mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 13:50:31 +00:00
wip
This commit is contained in:
@@ -19,7 +19,7 @@ interface Account {
|
||||
account_normal?: string;
|
||||
}
|
||||
|
||||
interface AccountSelect extends Account, SelectOptionProps { }
|
||||
export interface AccountSelect extends Partial<Account>, SelectOptionProps { }
|
||||
|
||||
type MultiSelectProps = React.ComponentProps<typeof FMultiSelect>;
|
||||
|
||||
@@ -49,10 +49,13 @@ const createNewItemRenderer = (
|
||||
};
|
||||
|
||||
// Create new item from the given query string.
|
||||
const createNewItemFromQuery = (query: string): SelectOptionProps => ({
|
||||
const createNewItemFromQuery = (query: string): AccountSelect => ({
|
||||
label: query,
|
||||
value: query,
|
||||
text: query,
|
||||
id: 0,
|
||||
name: query,
|
||||
code: query,
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,7 +14,6 @@ import {
|
||||
FormattedMessage as T,
|
||||
} from '@/components';
|
||||
import { nestedArrayToflatten, filterAccountsByQuery } from '@/utils';
|
||||
|
||||
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
||||
|
||||
// Create new account renderer.
|
||||
@@ -31,9 +30,7 @@ const createNewItemRenderer = (query, active, handleClick) => {
|
||||
|
||||
// Create new item from the given query string.
|
||||
const createNewItemFromQuery = (name) => {
|
||||
return {
|
||||
name,
|
||||
};
|
||||
return { name };
|
||||
};
|
||||
|
||||
// Filters accounts items.
|
||||
@@ -72,6 +69,22 @@ function AccountsSuggestFieldRoot({
|
||||
() => nestedArrayToflatten(accounts),
|
||||
[accounts],
|
||||
);
|
||||
const filteredAccounts = useMemo(
|
||||
() =>
|
||||
filterAccountsByQuery(flattenAccounts, {
|
||||
filterByParentTypes,
|
||||
filterByTypes,
|
||||
filterByNormal,
|
||||
filterByRootTypes,
|
||||
}),
|
||||
[
|
||||
flattenAccounts,
|
||||
filterByParentTypes,
|
||||
filterByTypes,
|
||||
filterByNormal,
|
||||
filterByRootTypes,
|
||||
],
|
||||
);
|
||||
const handleCreateItemSelect = useCallback(
|
||||
(item) => {
|
||||
if (!item.id) {
|
||||
|
||||
@@ -1,7 +1,14 @@
|
||||
// @ts-nocheck
|
||||
|
||||
import { AccountSelect } from "./AccountsMultiSelect";
|
||||
|
||||
// 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 normalizedQuery = query.toLowerCase();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user