import { useQuery } from "@tanstack/react-query";
import { getinventoryCheck } from "../../../-utils/querys/logistics/getInventoryCheck";
import { invColumns } from "../../../-utils/tableData/InventoryCards/inventoryColumns";
import { InvTable } from "../../../-utils/tableData/InventoryCards/inventoryData";
//import { CircleX } from "lucide-react";
//import { Suspense } from "react";
//import { toast } from "sonner";

export default function INVCheckCard(props: any) {
	const { age, rowType } = props.data;

	//console.log(props.data);
	const { data, isError, isLoading } = useQuery(
		getinventoryCheck({ age: age }),
	);

	if (isLoading) return <div>Loading inventory data...</div>;
	if (isError) {
		return (
			<div>
				<p>There was an error getting the inv.</p>
			</div>
		);
	}
	let laneData: any = data;
	if (props.type != "") {
		laneData = laneData.filter((l: any) => l.rowType === rowType.toUpperCase());

		// age
		laneData = laneData.filter((l: any) => l.DaysSinceLast >= age);
	}

	// const handleCloseCard = () => {
	//     //removeCard("PPOO");

	//     toast.success("card removed");
	// };

	return <InvTable columns={invColumns} data={laneData} info={props.data} />;
}
