
import React, { useEffect, useState } from "react";

import { Dashboard } from './../../../../models/'

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

import { Skeleton, Empty } from "antd";


export default function PopQueryDashboard({ record, id }) {

    const [loading, setLoading] = useState(false);

    const [result, setResult] = useState([[], 0]);

    useEffect(() => {

        setLoading(true);

        Dashboard.execPopQuery(id)
            .then((result) => {
                var data = {};

                setResult(result[0])

                setLoading(false);


                console.log(record.tiletypeptr, result);
            })
            .catch(() => {
                // setResult({ error: 'Error' });
            });
    }, []);

    return <>

        {loading ? (
            <Skeleton active />
        ) : (
            <>
                {result.length ? <BasicTable result={result} /> : <Empty />}
            </>
        )}
    </>;
}
