// RentalContext.js
import React, { createContext, useState, useContext } from 'react';

const RentalContext = createContext();

export const useRentalContext = () => useContext(RentalContext);

export const RentalProvider = ({ children }) => {
    const [rentals, setRentals] = useState([]);

    const addRental = (newRental) => {
        setRentals([...rentals, newRental]);
    };

    const clearRentals = () => {
        setRentals([]);
    };

    return (
        <RentalContext.Provider value={{ rentals, addRental, clearRentals }}>
            {children}
        </RentalContext.Provider>
    );
};