Skip to content

Commit

Permalink
refactor: use buildArrayFieldQuery for declarative approach
Browse files Browse the repository at this point in the history
  • Loading branch information
alisher-epam committed Nov 28, 2023
1 parent 43547fe commit 3579df5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/invoices/InvoicesList/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ export const FILTERS = {
FUND_CODE: 'fundCode',
LOCK_TOTAL: 'lockTotal',
FISCAL_YEAR: 'fiscalYearId',
INVOICE_LINE_TAGS: 'invoiceLines.tags.tagList',
};
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ import { getKeywordQuery } from '../../InvoicesListSearchConfig';
import { FILTERS } from '../../constants';

function getQueryForTags(filterValue) {
const value = Array.isArray(filterValue) ? `(${filterValue.map(v => `"*${v}*"`).join(' or ')})` : `"*${filterValue}*"`;
const tagsQuery = buildArrayFieldQuery(FILTERS.TAGS, filterValue);
const invoiceLineTagsQuery = buildArrayFieldQuery(FILTERS.INVOICE_LINE_TAGS, filterValue);

return `${FILTERS.TAGS}==${value} or invoiceLines.tags.tagList==${value}`;
return `${tagsQuery} or ${invoiceLineTagsQuery}`;
}

export const useBuildQuery = () => {
Expand Down

0 comments on commit 3579df5

Please sign in to comment.