import { UmbUserItemRepository } from '../../repository/item/user-item.repository.js';
import { UmbDisableUserRepository } from '../../repository/index.js';
import { UmbEntityActionBase } from '../../../../core/entity-action/index.js';
import { umbConfirmModal } from '../../../../core/modal/index.js';
export class UmbDisableUserEntityAction extends UmbEntityActionBase {
    constructor(host, args) {
        super(host, args);
    }
    async execute() {
        if (!this.args.unique)
            throw new Error('Unique is not available');
        const itemRepository = new UmbUserItemRepository(this);
        const { data } = await itemRepository.requestItems([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);
        const { error } = await disableUserRepository.disable([this.args.unique]);
        if (error) {
            throw error;
        }
    }
}
export { UmbDisableUserEntityAction as api };
