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

import { Link } from 'react-router-dom';

import { Tag } from 'antd';

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

// Components
import PageAdd from './pages/components/page-add/page-add';
import PageList from './pages/components/page-list/page-list';
import PageDetails from './pages/components/page-details/page-details';


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

        this.fields = [
            {
                field: 'name',
                caption: 'Name',
            },

            {
                field: 'description',
                caption: 'Description',
            },

            {
                field: 'path',
                caption: 'Path',
            },
        ];
    }

    get getEndpoint() {
        return 'core-page-definitions';
    }

    get path() {
        return `pages`;
    }

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

    get modelName() {
        return `page`;
    }

    get route() {
        return 'pages';
    }

    /**
     *
     */
    get columns() {
        return [
            {
                caption: 'Name',
                field: 'name',
                key: 'name',
            },

            {
                caption: 'Description',
                field: 'description',
                key: 'description',
            },

            {
                caption: 'Path',
                field: 'path',
                key: 'path',
            },

            // {
            //     caption: 'Created By',
            //     field: 'created_by',
            //     key: 'created_by',
            // },

            {
                caption: 'Created at',
                field: 'created_at',
                key: 'created_at',
                render: (ele) => {
                    return ele.created_at ? DateUtils.formatDate(ele.created_at) : null
                },
            },
        ];
    }



    ListComponent = PageList;

    DetailComponent = PageDetails;

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


    /**
     * load all Pages
     *
     * @param {*} menu
     * @returns
     */
    getPages = () => {

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

        return this.get({ url: `core-page-definitions` }).then((result) => {
            return result;
        });

    }

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

}


export default Pages;
