import React from "react";


import Base from './../base';

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

import { Tag } from 'antd';

class Branches extends Base {

    constructor() {
        super();

        this.fields = [

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

            {
                field: 'location',
                caption: 'Location',
            },

        ];

        // this.columns = ;
    }

    get getEndpoint() {
        return 'branches';
    }

    get path() {
        return `branches`;
    }

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

    get modelName() {
        return `branch`;
    }

    disableAddModal() {
        return false;
    }

    disableAdd() {
        return false;
    }


    /**
     * 
     * @param {*} param0 
     */
    getBranch = async ({ city }) => {

        var queries = [{
            field: 'city',
            value: city
        }]

        const { branches = [] } = await this.get(queries)

        return branches[0]
    }

    get columns() {
        return [
            // {
            //     caption: 'Caption',
            //     field: 'caption',
            //     key: 'caption',
            // },

            // {
            //     caption: 'Field',
            //     field: 'field',
            //     key: 'field',
            // },
            {
                caption: 'Description',
                field: 'description',
                key: 'description',
            },
            {
                caption: 'Created At',
                field: 'created_at',
                key: 'created_at',
            },
        ];
    }


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

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

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

}

export default Branches;
