check if item exists before getting the first one
This commit is contained in:
@@ -16,18 +16,20 @@ export class UmbDisableUserEntityAction extends UmbEntityActionBase<never> {
|
||||
const itemRepository = new UmbUserItemRepository(this);
|
||||
const { data } = await itemRepository.requestItems([this.args.unique]);
|
||||
|
||||
if (data) {
|
||||
const item = data[0];
|
||||
|
||||
await umbConfirmModal(this._host, {
|
||||
headline: `Disable ${item.name}`,
|
||||
content: 'Are you sure you want to disable this user?',
|
||||
color: 'danger',
|
||||
confirmLabel: 'Disable',
|
||||
});
|
||||
|
||||
const disableUserRepository = new UmbDisableUserRepository(this);
|
||||
await disableUserRepository.disable([this.args.unique]);
|
||||
if (!data?.length) {
|
||||
throw new Error('Item not found.');
|
||||
}
|
||||
|
||||
const item = data[0];
|
||||
|
||||
await umbConfirmModal(this._host, {
|
||||
headline: `Disable ${item.name}`,
|
||||
content: 'Are you sure you want to disable this user?',
|
||||
color: 'danger',
|
||||
confirmLabel: 'Disable',
|
||||
});
|
||||
|
||||
const disableUserRepository = new UmbDisableUserRepository(this);
|
||||
await disableUserRepository.disable([this.args.unique]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,17 +16,19 @@ export class UmbEnableUserEntityAction extends UmbEntityActionBase<never> {
|
||||
const itemRepository = new UmbUserItemRepository(this);
|
||||
const { data } = await itemRepository.requestItems([this.args.unique]);
|
||||
|
||||
if (data) {
|
||||
const item = data[0];
|
||||
|
||||
await umbConfirmModal(this._host, {
|
||||
headline: `Enable ${item.name}`,
|
||||
content: 'Are you sure you want to enable this user?',
|
||||
confirmLabel: 'Enable',
|
||||
});
|
||||
|
||||
const enableRepository = new UmbEnableUserRepository(this);
|
||||
await enableRepository.enable([this.args.unique]);
|
||||
if (!data?.length) {
|
||||
throw new Error('Item not found.');
|
||||
}
|
||||
|
||||
const item = data[0];
|
||||
|
||||
await umbConfirmModal(this._host, {
|
||||
headline: `Enable ${item.name}`,
|
||||
content: 'Are you sure you want to enable this user?',
|
||||
confirmLabel: 'Enable',
|
||||
});
|
||||
|
||||
const enableRepository = new UmbEnableUserRepository(this);
|
||||
await enableRepository.enable([this.args.unique]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,17 +16,19 @@ export class UmbUnlockUserEntityAction extends UmbEntityActionBase<never> {
|
||||
const itemRepository = new UmbUserItemRepository(this);
|
||||
const { data } = await itemRepository.requestItems([this.args.unique]);
|
||||
|
||||
if (data) {
|
||||
const item = data[0];
|
||||
|
||||
await umbConfirmModal(this._host, {
|
||||
headline: `Unlock ${item.name}`,
|
||||
content: 'Are you sure you want to unlock this user?',
|
||||
confirmLabel: 'Unlock',
|
||||
});
|
||||
|
||||
const unlockUserRepository = new UmbUnlockUserRepository(this);
|
||||
await unlockUserRepository?.unlock([this.args.unique]);
|
||||
if (!data?.length) {
|
||||
throw new Error('Item not found.');
|
||||
}
|
||||
|
||||
const item = data[0];
|
||||
|
||||
await umbConfirmModal(this._host, {
|
||||
headline: `Unlock ${item.name}`,
|
||||
content: 'Are you sure you want to unlock this user?',
|
||||
confirmLabel: 'Unlock',
|
||||
});
|
||||
|
||||
const unlockUserRepository = new UmbUnlockUserRepository(this);
|
||||
await unlockUserRepository?.unlock([this.args.unique]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user