Fix disabled button with AccountSelect

This commit is contained in:
elforjani3
2020-11-02 17:16:50 +02:00
parent 28fe1c25e6
commit 5b32d8fe7d
5 changed files with 17 additions and 10 deletions

View File

@@ -76,6 +76,7 @@ export default function AccountsSelectList({
popoverProps={{ minimal: true }}
filterable={true}
onItemSelect={onAccountSelect}
disabled={disabled}
>
<Button
disabled={disabled}

View File

@@ -1,13 +1,12 @@
import React, { useCallback } from 'react';
import {
ListSelect,
} from 'components';
import { ListSelect } from 'components';
export default function AccountsTypesSelect({
accountsTypes,
selectedTypeId,
defaultSelectText = 'Select account type',
onTypeSelected,
disabled = false,
...restProps
}) {
// Filters accounts types items.
@@ -28,7 +27,8 @@ export default function AccountsTypesSelect({
};
const items = accountsTypes.map((type) => ({
id: type.id, label: type.label,
id: type.id,
label: type.label,
}));
return (
@@ -40,7 +40,8 @@ export default function AccountsTypesSelect({
defaultText={defaultSelectText}
onItemSelect={handleItemSelected}
itemPredicate={filterAccountTypeItems}
disabled={disabled}
{...restProps}
/>
);
}
}

View File

@@ -15,7 +15,7 @@ export default function ListSelect({
initialSelectedItem,
onItemSelect,
disabled = false,
...selectProps
}) {
const selectedItemObj = useMemo(
@@ -24,7 +24,10 @@ export default function ListSelect({
);
const selectedInitialItem = useMemo(
() => selectProps.items.find((i) => i[selectedItemProp] === initialSelectedItem),
() =>
selectProps.items.find(
(i) => i[selectedItemProp] === initialSelectedItem,
),
[initialSelectedItem],
);
@@ -65,10 +68,12 @@ export default function ListSelect({
onItemSelect={handleItemSelect}
{...selectProps}
noResults={noResults}
disabled={disabled}
>
<Button
text={currentItem ? currentItem[labelProp] : defaultText}
loading={isLoading}
disabled={disabled}
{...buttonProps}
/>
</Select>

View File

@@ -282,7 +282,7 @@ function AccountFormDialogContent({
selectedTypeId={values.account_type_id}
defaultSelectText={<T id={'select_account_type'} />}
onTypeSelected={onChangeAccountType}
buttonProps={{ disabled: action === 'edit' }}
disabled={action === 'edit'}
popoverProps={{ minimal: true }}
/>
</FormGroup>

View File

@@ -149,11 +149,11 @@ export const editAccount = (id, form) => {
};
export const activateAccount = ({ id }) => {
return (dispatch) => ApiService.post(`accounts/${id}/active`);
return (dispatch) => ApiService.post(`accounts/${id}/activate`);
};
export const inactiveAccount = ({ id }) => {
return (dispatch) => ApiService.post(`accounts/${id}/inactive`);
return (dispatch) => ApiService.post(`accounts/${id}/inactivate`);
};
export const bulkActivateAccounts = ({ ids }) => {