import { getAdjustments } from "@/utils/querys/logistics/siloAdjustments/getAdjustments";
import { columns } from "@/utils/tableData/siloAdjustmentHist/siloAdjHistColumns";
import { SiloTable } from "@/utils/tableData/siloAdjustmentHist/siloData";
import { useQuery } from "@tanstack/react-query";

export default function HistoricalData(props: any) {
    const { data, isError, isLoading } = useQuery(getAdjustments());

    if (isLoading) return <div>Loading adjustmnet data...</div>;
    if (isError) {
        return (
            <div>
                <p>There was an error getting the adjustments.</p>
            </div>
        );
    }
    //console.log(data[0].locationID, parseInt(props.laneId));
    const adjustments: any = data.filter(
        (l: any) => l.locationID === parseInt(props.laneId)
    );
    return (
        <div className="container mx-auto py-10">
            <SiloTable columns={columns} data={adjustments} />
        </div>
    );
}
