import {apiGet, useAmis} from '../../components/constants.js'
import {userChangePasswordDialog} from "../../components/user/dialog-user-change-password.js";
import {tabUser} from "./tab-user.js";
import {tabData} from "./tab-data.js";
import {tabSettings} from "./tab-settings.js";
import {tabCheck} from "./tab-check.js";
import {tabPermissions} from "./tab-permissions.js";
import {tabMarket} from "./tab-market.js";

useAmis(information => {
    return {
        id: 'header-service',
        className: 'h-full',
        type: 'service',
        api: apiGet('${base}/user/state'),
        onEvent: {
            fetchInited: {
                actions: [
                    {
                        expression: '${!event.data.responseData.token}',
                        actionType: 'url',
                        args: {
                            url: '/pages/login/index.html',
                            blank: false,
                        }
                    }
                ]
            }
        },
        body: [
            {
                type: 'page',
                title: information.title,
                subTitle: '提供合法合规的数据要素可信供给工具',
                toolbar: [
                    {
                        type: 'dropdown-button',
                        label: '${username}',
                        align: 'right',
                        trigger: 'hover',
                        buttons: [
                            {
                                label: '修改密码',
                                ...userChangePasswordDialog(),
                            },
                            {
                                label: '退出登陆',
                                actionType: 'ajax',
                                api: apiGet('${base}/user/logout'),
                                reload: 'header-service',
                            }
                        ]
                    }
                ],
                bodyClassName: 'p-0',
                body: {
                    className: 'h-full border-0',
                    type: 'tabs',
                    tabsMode: 'vertical',
                    tabs: [
                        // tabOverview(),
                        tabMarket(),
                        tabPermissions(),
                        tabCheck(),
                        tabData(),
                        tabUser(),
                        tabSettings(),
                    ]
                },
            }
        ]
    }
})
