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

// @ts-nocheck
import React from 'react';
import { Link } from 'react-router-dom';

import ApiUtils from './../../lib/';

// import GenericAdd from './../modules/common/resources/generic/generic-add/generic-add';

import GenericList from '../modules/generic/components/generic-list/generic-list';

import GenericAdd from '../modules/generic/components/generic-add/generic-add';

import GenericEdit from '../modules/generic/components/generic-edit/generic-edit';

import GenericDetail from '../modules/generic/components/generic-detail/generic-detail';

import GenericAddModal from '../modules/generic/components/generic-add-modal/generic-add-modal';


// import GenericUpload from './../modules/common/resources/generic/generic-upload/generic-upload';

const moment = require('moment-timezone');

class BaseClone {
    // name;
    // endpoint;
    // pluralName;
    // schema;

    // getEndpoint;

    // getEndpoint;

    endpoint;

    fields;
    // listFields;
    // filterFields;

    // columns = [];

    constructor(fields = []) {
        // this.path = this.path();

        this.endpoint = this.getEndpoint;

        this.name = this.getName;

        this.fields = fields;

        // this.columns = [];
    }

    // get columns() {
    //     return [];
    // }

    filterDate() {
        return false;
    }

    /**
     * Link for redirection
     */
    get link() {
        return this.name.toLowerCase();
    }

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

    /**
     * Get the data from the table
     */
    get(config, queries = []) {
        // Get the records from firebase

        return ApiUtils.get({ url: this.endpoint, config });
    }

    getRelations(id) {
        // Get the records from firebase
        return ApiUtils.get({ url: `modelrelationship/getRelations/${id}` });
    }


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

    /**
     *
     * @param {*} values
     * @returns
     */
    getRecord = ({ id }) => {
        return ApiUtils.get({ url: this.endpoint + '/' + id });
        // return FirebaseUtils.getRecord(id, this);
    };

    /**
     *
     * @param {*} values
     * @param {*} user
     * @returns
     */
    add = ({ values, user }) => {
        let formBody = {
            ...values,
        };

        return ApiUtils.post({ url: this.endpoint, formBody });
    };

    /**
     * Update of model
     *
     * @param {*} id
     * @param {*} values
     * @param {*} user
     * @returns
     */
    update = ({ id, formBody, user }) => {
        return ApiUtils.put({ url: this.endpoint + '/' + id, formBody });
    };

    columns() {
        return [
            {
                caption: 'Name',
                field: 'name',
                key: 'name',
            },
            {
                caption: 'Weight',
                field: 'weight',
                key: 'weight',
            },
            {
                caption: 'Date',
                field: 'created_at',
                key: 'created_at',
            },
        ];
    }

    AddComponent = GenericAdd;

    ListComponent = GenericList;

    EditComponent = GenericEdit;

    DetailComponent = GenericDetail;

    Card = ({ record, model }) => {
        return (
            <Link className="booking-card" to={`/${model.link}/${record['id']}`}>
                <div className="listing-card">
                    <h2 className="">{record.name}</h2>

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

                    <p className="address">Created by {record.created_by}</p>
                </div>
            </Link>
        );
    };

    // UploadComponent = GenericUpload;

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

    // ModalAddComponent = GenericAddMo;
}

export default BaseClone;
