// Fusion Accounting - Redirect Action
// Copyright (C) 2026 Nexa Systems Inc.

import { registry } from "@web/core/registry";
import { useService } from "@web/core/utils/hooks";
import { Component } from "@odoo/owl";
import { standardActionServiceProps } from "@web/webclient/actions/action_service";
import { Dialog } from "@web/core/dialog/dialog";

/**
 * RedirectAction - Client action that displays a dialog prompting the user
 * to install a required module before accessing a feature.
 */
class RedirectAction extends Component {
    static template = "fusion_accounting.redirectAction";
    static components = { Dialog };

    static props = {
        ...standardActionServiceProps,
        action: Object
    }

    setup() {
        this.actionService = useService("action");
    }

    openClientAction() {
        this.actionService.doAction(this.props.action.params.depending_action);
    }

    close() {
        this.actionService.doAction({type: 'ir.actions.act_window_close'});
    }
}

registry.category("actions").add("fusion_accounting.redirect_action", RedirectAction);
