import { create } from 'zustand';

interface BookingInfo {
    bookTime: string;
    carID: string;
    date: string;
    chargingWatt: string;
    connectorID: string;
    price: string;
    stationID: string;
    user: string;
    paymentFee: string;
    carCapacitance: string;
    bookDateForDisplay?: string;
    bookTimeForDisplay?: string;
    chargeStationAddressForDisplay?: string;
    chargeStationNameForDisplay?: string;
    carNameForDisplay?: string;
}

interface BookingStore extends BookingInfo {
    setBookingInfo: (info: Partial<BookingInfo>) => void;
    resetBookingInfo: () => void;
}

const initialState: BookingInfo = {
    bookTime: '',
    carID: '',
    date: '',
    chargingWatt: '',
    connectorID: '',
    price: '',
    stationID: '',
    user: '',
    paymentFee: '',
    carCapacitance: '',
    bookDateForDisplay: '',
    bookTimeForDisplay: '',
    chargeStationAddressForDisplay: '',
    chargeStationNameForDisplay: '',
    carNameForDisplay: ''
};

const useBookingStore = create<BookingStore>((set) => ({
    ...initialState,
    setBookingInfo: (info) => set((state) => ({ ...state, ...info })),
    resetBookingInfo: () => set(initialState)
}));

export default useBookingStore;
