<?xml version="1.0" encoding="utf-8"?>
<odoo>

    <!-- Tree View -->
    <record id="fusion_calendar_account_view_tree" model="ir.ui.view">
        <field name="name">fusion.calendar.account.tree</field>
        <field name="model">fusion.calendar.account</field>
        <field name="arch" type="xml">
            <list>
                <field name="x_fc_user_id"/>
                <field name="x_fc_provider"/>
                <field name="x_fc_email"/>
                <field name="x_fc_sync_status" widget="badge"
                       decoration-success="x_fc_sync_status == 'active'"
                       decoration-danger="x_fc_sync_status == 'error'"
                       decoration-warning="x_fc_sync_status == 'paused'"/>
                <field name="x_fc_last_sync"/>
                <field name="x_fc_active"/>
            </list>
        </field>
    </record>

    <!-- Form View -->
    <record id="fusion_calendar_account_view_form" model="ir.ui.view">
        <field name="name">fusion.calendar.account.form</field>
        <field name="model">fusion.calendar.account</field>
        <field name="arch" type="xml">
            <form>
                <header>
                    <field name="x_fc_sync_status" widget="statusbar"
                           statusbar_visible="active,error,paused"/>
                </header>
                <sheet>
                    <div class="oe_title">
                        <h1><field name="x_fc_name" readonly="True"/></h1>
                    </div>
                    <group>
                        <group>
                            <field name="x_fc_user_id"/>
                            <field name="x_fc_provider"/>
                            <field name="x_fc_email"/>
                            <field name="x_fc_calendar_id"/>
                            <field name="x_fc_active"/>
                        </group>
                        <group>
                            <field name="x_fc_last_sync"/>
                            <field name="x_fc_error_message" invisible="x_fc_sync_status != 'error'"/>
                        </group>
                    </group>
                </sheet>
            </form>
        </field>
    </record>

    <!-- Action -->
    <record id="action_fusion_calendar_account" model="ir.actions.act_window">
        <field name="name">Connected Calendar Accounts</field>
        <field name="res_model">fusion.calendar.account</field>
        <field name="view_mode">list,form</field>
    </record>

    <!-- Menu under Settings > Technical -->
    <menuitem id="menu_fusion_calendar_account"
              name="Calendar Accounts"
              parent="base.menu_custom"
              action="action_fusion_calendar_account"
              sequence="99"/>

</odoo>
