From 574f596eea63c3364d84b413f682d1cdf9ab2efc Mon Sep 17 00:00:00 2001 From: "a.bouhuolia" Date: Tue, 15 Feb 2022 16:08:48 +0200 Subject: [PATCH] refactor: invoice topbar. --- src/components/Branches/BranchSelect.js | 69 ++++++++++++++ src/components/Branches/index.js | 1 + src/components/Forms/FSelect.tsx | 85 ++++++++++++++++++ src/components/Forms/index.js | 3 +- src/components/Warehouses/WarehouseSelect.js | 74 +++++++++++++++ src/components/Warehouses/index.js | 1 + src/components/index.js | 5 +- .../Invoices/InvoiceForm/InvoiceFormTopBar.js | 89 ++++++++++--------- src/lang/en/index.json | 4 +- 9 files changed, 287 insertions(+), 44 deletions(-) create mode 100644 src/components/Branches/BranchSelect.js create mode 100644 src/components/Branches/index.js create mode 100644 src/components/Forms/FSelect.tsx create mode 100644 src/components/Warehouses/WarehouseSelect.js create mode 100644 src/components/Warehouses/index.js diff --git a/src/components/Branches/BranchSelect.js b/src/components/Branches/BranchSelect.js new file mode 100644 index 000000000..02f693705 --- /dev/null +++ b/src/components/Branches/BranchSelect.js @@ -0,0 +1,69 @@ +import React from 'react'; + +import { MenuItem, Button } from '@blueprintjs/core'; +import { FSelect } from '../Forms'; + +/** + * + * @param {*} query + * @param {*} branch + * @param {*} _index + * @param {*} exactMatch + * @returns + */ +const branchItemPredicate = (query, branch, _index, exactMatch) => { + const normalizedTitle = branch.name.toLowerCase(); + const normalizedQuery = query.toLowerCase(); + + if (exactMatch) { + return normalizedTitle === normalizedQuery; + } else { + return `${branch.code}. ${normalizedTitle}`.indexOf(normalizedQuery) >= 0; + } +}; + +/** + * + * @param {*} film + * @param {*} param1 + * @returns + */ +const branchItemRenderer = (branch, { handleClick, modifiers, query }) => { + const text = `${branch.name}`; + + return ( + + ); +}; + +const branchSelectProps = { + itemPredicate: branchItemPredicate, + itemRenderer: branchItemRenderer, + valueAccessor: 'id', + labelAccessor: 'name', +}; + +/** + * + * @param {*} param0 + * @returns + */ +export function BranchSelect({ branches, ...rest }) { + return ; +} + +/** + * + * @param {*} param0 + * @returns + */ +export function BranchSelectButton({ label, ...rest }) { + return