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

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

// 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 UserRolesAdd from './components/user-roles-add/user-roles-add';


class UserRole extends Base {

    constructor() {
        super();

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

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

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

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

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

    get columns() {
        return [
            {
                field: 'role.name',
                caption: 'Role'
            }, {
                field: 'role.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;
    }

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

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

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

}

export default UserRole;
