// @ts-nocheck
import React from 'react';
import Base from '../base/base';

// import ApiUtils from './../core/utils/api.utils';

// import RoleAdd from '../core/components/roles/role-add/role-add';

// import RoleList from '../core/components/roles/role-list/role-list';

// import RoleDetail from '../core/components/roles/role-detail/role-detail';

import MenuRolesAdd from './components/menu-roles-add/menu-roles-add';

import { DateUtils } from './../../lib/';


class MenuRole extends Base {
    constructor() {
        super();

        this.fields = [
            {
                field: 'name',
                caption: 'Name',
            },
            {
                field: 'amount',
                caption: 'Amount',
            },
        ];
    }

    get getEndpoint() {
        return 'core-menu-roles';
    }

    get path() {
        return `core-menu-roles`;
    }

    get getName() {
        return this.modelName + `s`;
    }

    get modelName() {
        return `core-menu-role`;
    }

    get columns() {

        return [
            {
                field: 'role.name',
                caption: 'Role'
            },
            {
                field: 'created_at',
                caption: 'Created At',
                render: (ele) => {
                    return ele.created_at ? DateUtils.formatDate(ele.created_at) : null
                },
            }
        ];

    }


    get disableAddModal() {
        return false;
    }

    get disableEditModal() {
        return false;
    }


    // ListComponent = RoleList;

    // DetailComponent = RoleDetail;

    // ModalAddComponent = (props) => <RoleAdd model={this} {...props} />;

    // ModalAddComponent = (props) => <GenericAdd model={this} {...props} />;

    /**
     * Get the data from the table
     */
    // get = (queries) => {
    //     return this.getMethod(queries).then((result) => {
    //         return Promise.all(result.menus.map((menu) => this.loadModule(menu))).then((result) => {
    //             return { menus: result };
    //         });
    //     });
    // };

    /**
     * Load the module of the menu
     *
     * @param {*} param0
     * @returns
     */
    loadModule = (menu) => { };

    /**
     * load the detail of menu
     *
     * @param {*} menu
     * @returns
     */
    getDetail = (id) => {
        return this.getRecord(id).then((result) => {
            return result;
        });
    };

    /**
     * load the list of menu
     *
     * @param {*} menu
     * @returns
     */
    getMenus = (config) => {

        // return this.getData({ path: `menus/get-menus`, queries: queries}).then((result) => {
        //     return result;
        // });

        return this.get({ url: `menus/get-menus`, config: config }).then((result) => {
            return result;
        });

    };

    /**
     * 
     * @param {*} formBody 
     * @returns 
     */
    addMenuRole = ({ values }) => {

        return this.post({
            url: 'core-menu-roles/create-menu-roles',
            formBody: values
        })
    }

    /**
     * 
     * 
     * @param props 
     * @returns 
     */
    ModalAddComponent = (props) => <MenuRolesAdd model={this} {...props} />;

}

export default MenuRole;
