/**
 * Registration Model
 *
 *
 * To seperate all login for Script
 *
 */

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

import { ApiUtils } from 'soxo-firebase-core'


class CoreScript extends Base {

    constructor() {
        super();

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

        // this.columns = ;
    }

    get id() {
        return 'id';
    }

    get getEndpoint() {
        return 'core-scripts';
    }


    get modelName() {
        return `core-scripts`;
    }

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


    /**
     *
     * @returns
     */
    getReportingLisitng = (id, formBody) => {
        console.log('Fb', formBody);

        return ApiUtils.post({
            url: `core-scripts/dashboardquery/${id}`,
            formBody,
        });
    };

    /**
     * 
     */
    getReportMenu = async ({ id }) => {

        const result = await this.getRecord({ id })

        return {
            ...result,
            caption: result.caption,
            path: '/reports/' + result.id,
            is_visible: true
        }
    }
}

export default CoreScript;
