import ListVirtual from "./components/ListVirtual";
import { ApiProvider } from "./components/ApiContext";
import { API_TOKEN } from "./config/constants";
import { useState } from "react";

const Testing = () => {
        const token = API_TOKEN;
        const [selectedVehicle, setSelectedVehicle] = useState(null);

        return (
            <div style={{ padding: 8, marginTop: 12 }}>
                <ApiProvider
                    headers={{
                        Authorization: `Bearer ${token}`,
                    }}
                >
                    <ListVirtual
                        id="company-select"
                        label="Company"
                        name="name"
                        url="/company"
                        defaultValue={442}
                        size="small"
                    /> 
                    <ListVirtual
                        label="License Plate"
                        name="license_plate"
                        url="/vehicle"
                        defaultValue={selectedVehicle}
                        getData={(data) => {
                            if (data) {
                                setSelectedVehicle(data.id);
                            }
                        }}
                        size="small"
                        filter={[
                            {name:"company_id",value: "442","logic_operator":"=","operator":"AND"}
                        ]}
                    />
                </ApiProvider>
            </div>
        )
}

export default Testing;