From 8d990ae85d6cfcb549b31c9235e2fb332b7bca7b Mon Sep 17 00:00:00 2001 From: Ahmed Bouhuolia Date: Wed, 28 Jun 2023 18:07:47 +0200 Subject: [PATCH] fix(webapp): no default branch for customer/vendor opening balance branch --- .../src/components/Branches/BranchSelect.tsx | 61 ++++--------------- .../webapp/src/components/Forms/Select.tsx | 2 +- .../PageForm/FormTopbarSelectInputs.tsx | 27 ++++++++ .../webapp/src/components/PageForm/index.ts | 1 + .../components/Warehouses/WarehouseSelect.tsx | 2 +- .../MakeJournal/MakeJournalFormTopBar.tsx | 14 +---- .../CustomerForm/CustomerFinancialPanel.tsx | 3 - .../ExpenseForm/ExpenseFormTopBar.tsx | 19 ++---- .../Bills/BillForm/BillFormTopBar.tsx | 33 ++-------- .../VendorCreditNoteFormTopBar.tsx | 31 ++-------- .../PaymentForm/PaymentMadeFormTopBar.tsx | 19 ++---- .../CreditNoteForm/CreditNoteFormTopBar.tsx | 34 +++-------- .../EstimateForm/EstimtaeFormTopBar.tsx | 33 ++-------- .../InvoiceForm/InvoiceFormTopBar.tsx | 33 ++-------- .../PaymentReceiveFormTopBar.tsx | 26 +++----- .../ReceiptForm/ReceiptFormTopbar.tsx | 34 ++--------- .../VendorForm/VendorFinanicalPanelTab.tsx | 3 - packages/webapp/src/lang/en/index.json | 18 +----- 18 files changed, 100 insertions(+), 293 deletions(-) create mode 100644 packages/webapp/src/components/PageForm/FormTopbarSelectInputs.tsx diff --git a/packages/webapp/src/components/Branches/BranchSelect.tsx b/packages/webapp/src/components/Branches/BranchSelect.tsx index 6e463ad9a..2641f2704 100644 --- a/packages/webapp/src/components/Branches/BranchSelect.tsx +++ b/packages/webapp/src/components/Branches/BranchSelect.tsx @@ -5,59 +5,20 @@ 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', -}; - -/** - * + * Branch select field. * @param {*} param0 - * @returns + * @returns {JSX.Element} */ export function BranchSelect({ branches, ...rest }) { - return ; + return ( + + ); } /** diff --git a/packages/webapp/src/components/Forms/Select.tsx b/packages/webapp/src/components/Forms/Select.tsx index 459912b62..6916e115c 100644 --- a/packages/webapp/src/components/Forms/Select.tsx +++ b/packages/webapp/src/components/Forms/Select.tsx @@ -16,7 +16,7 @@ export function FSelect({ ...props }) { /> ); }; - return ; } const SelectButton = styled(Button)` diff --git a/packages/webapp/src/components/PageForm/FormTopbarSelectInputs.tsx b/packages/webapp/src/components/PageForm/FormTopbarSelectInputs.tsx new file mode 100644 index 000000000..f3f2f1f84 --- /dev/null +++ b/packages/webapp/src/components/PageForm/FormTopbarSelectInputs.tsx @@ -0,0 +1,27 @@ +// @ts-nocheck +import React from 'react'; +import intl from 'react-intl-universal'; +import { Button } from '@blueprintjs/core'; +import { Icon } from '@/components'; + +export function FormWarehouseSelectButton({ text }) { + return ( +