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

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

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


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

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

        // this.columns = ;
    }

    get id() {
        return 'id';
    }

    get getEndpoint() {
        return 'dashboard';
    }


    get modelName() {
        return `dashboard`;
    }

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

    loadDashboards(user) {

        let group = user.user_group;

        if (typeof user.user_group === 'string') {

        } else {

            group = user.user_group.wug_code
        }

        return ApiUtils.get({
            url: `dashboard/get-dashboard/${group}`
        });
    }

    execDashboard(id) {
        return ApiUtils.get({
            url: 'dashboard/exec/' + id,
            hideError: true
        });

    }

    execPopQuery(id) {
        return ApiUtils.get({
            url: 'dashboard/pop/' + id,
            hideError: true
        });
    }
}

export default Dashboard;
