Skip to content

Commit

Permalink
UIOR-1174 Do not disable account numbers having only one account avai…
Browse files Browse the repository at this point in the history
…lable
  • Loading branch information
NikitaSedyx committed Nov 3, 2023
1 parent 59f4f00 commit 642b1c2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Allow Editing of "Renewal Date" and "Subscription to" on open purchase order line. Refs UIOR-1078.
* Add missed permission to fetch org types in view only mode. Refs UIOR-1168.
* Preview contains blank page when trying to print an order. Refs UIOR-1173.
* Do not disable account numbers having only one account available. Refs UIOR-1174.

## [5.0.0](https://github.com/folio-org/ui-orders/tree/v5.0.0) (2023-10-12)
[Full Changelog](https://github.com/folio-org/ui-orders/compare/v4.0.3...v5.0.0)
Expand Down
15 changes: 5 additions & 10 deletions src/components/POLine/Vendor/VendorForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ const VendorForm = ({
const activeAccountOptions = useMemo(() => {
const message = ` - ${formatMessage({ id: 'ui-orders.inactive' })}`;
const activeAccounts = accounts.filter(({ accountStatus, accountNo }) => {
return accountStatus === ACTIVE || accountNo === initialAccountNumber.current;
return (
accountStatus.toLowerCase() === ACTIVE.toLowerCase()
|| accountNo === initialAccountNumber.current
);
});

return activeAccounts.map(({ name, accountNo, accountStatus }) => ({
Expand All @@ -58,14 +61,6 @@ const VendorForm = ({
}, [change, getState, integrationConfigs],
);

const accountNumberDisabled = useMemo(() => {
const hasCurrentAccountNumber = accounts.some(({ accountNo }) => accountNo === currentAccountNumber);
const isOnlyOneActiveAccount = activeAccountOptions.length === 1;
const noActiveAccounts = activeAccountOptions.length === 0;

return noActiveAccounts || (hasCurrentAccountNumber && isOnlyOneActiveAccount);
}, [accounts, activeAccountOptions, currentAccountNumber]);

const isSelectedAccountInactive = useMemo(() => {
return accounts.some(({ accountNo, accountStatus }) => {
return accountNo === currentAccountNumber && accountStatus === INACTIVE;
Expand All @@ -85,7 +80,7 @@ const VendorForm = ({
>
<FieldVendorAccountNumber
accounts={activeAccountOptions}
disabled={isPostPendingOrder || accountNumberDisabled}
disabled={isPostPendingOrder}
onChange={onAccountChange}
/>
{
Expand Down

0 comments on commit 642b1c2

Please sign in to comment.