
import React from "react";

import { Base } from './../';

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

import { Tag } from 'antd';

import FirebaseUtils from './../../../lib/utils/firebase.utils';

import ModelDetail from './../../models/models/components/model-detail/model-detail';

class Scripts extends Base {

    constructor() {
        super();

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

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

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

        // this.columns = ;
    }


    /**
     * Get the data from the table
     */
    getMethod(queries = []) {
        // Get the records from firebase
        return FirebaseUtils.getRecords(queries, this);
    }

    get getEndpoint() {
        return 'scripts';
    }

    get path() {
        return `scripts`;
    }

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

    get modelName() {
        return `script`;
    }

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

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

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


    /**
     * Card Component for Staff
     *
     * @param {*} record
     * @returns
     */
    Card = (record) => {
        return (
            <Link className="booking-card" to={`/models/${record['id']}`}>
                <div className="card">
                    <h2 className="">{record.name}</h2>

                    <h3 className="title">{record.description}</h3>

                    <p className="address">
                        Created by {record.created_by}
                        <Tag color="magenta">{record['Consultant Name']}</Tag>
                    </p>
                </div>
            </Link>
        );
    };

    DetailComponent = () => <ModelDetail model={this} />
}

export default Scripts;

