import api from "../lib/axios";


export const getVehicles = async(filter) => {
    try {
        const endpoint = `/v1/vehicles/find${filter}`;
        const {data} = await api.get(endpoint);
        return data;
    } catch (error) {
        console.log(error);
        return null;
    }
}

export const updateVehicle = async(id, formData) => {
    try {
        const endpoint = `/v1/vehicles/${id}`;
        const {data} = await api.patch(endpoint, formData);
        return data;
    } catch (error) {
        console.log(error);
        return null;
    }
}

export const deleteVehicle = async(id) => {
    try {
        const endpoint = `/v1/vehicles/${id}`;
        const {data} = await api.delete(endpoint);
        return data;
    } catch (error) {
        console.log(error);
        return null;
    }
}

export const createVehicle = async(formData) => {
    try {
        const endpoint = `/v1/vehicles/new`;
        const {data} = await api.post(endpoint, formData);
        return data;
    } catch (error) {
        console.log(error);
        return null;
    }
}

export const saveProposal = async(formData) => {
    try {
        const endpoint = `/v1/proposals/new`;
        const {data} = await api.post(endpoint, formData);
        return data;
    } catch (error) {
        console.log(error);
        return null;
    }
}

export const updateProposal = async(id, formData) => {
    try {
        const endpoint = `/v1/proposals/${id}`;
        const {data} = await api.patch(endpoint, formData);
        return data;
    } catch (error) {
        console.log(error);
        return null;
    }
}