import { create } from 'zustand';

interface ChargingStore {
    stationID: string;
    connector: string;
    scanned_qr_code: string;
    user: string;
    book_time: Date;
    end_time: Date;
    total_power: any;
    total_fee: any;
    current_price_store: number | null | undefined;
    promotion_code: string[];
    car: string;
    type: string;
    is_ic_call: boolean;
    coupon_detail: any;
    sum_of_coupon: string | number;
    processed_coupon_store: Array<{
        coupon_detail: {
            amount: number;
            expire_date: string;
        };
        frequency: number;
    }>;
    setProcessedCouponStore: (
        coupons: Array<{
            coupon_detail: {
                amount: number;
                expire_date: string;
            };
            frequency: number;
        }>
    ) => void;
    setScannedQrCode: (qrCode: string) => void;
    setSumOfCoupon: (sum: string | number) => void;
    setStationId: (id: string) => void;
    setConnector: (connector: string) => void;
    setUser: (user: string) => void;
    setBookTime: (time: Date) => void;
    setEndTime: (time: Date) => void;
    setCurrentPriceStore: (price: number | null | undefined) => void;
    setTotalPower: (power: any) => void;
    setTotalFee: (fee: any) => void;
    setPromotionCode: (code: string[]) => void;
    setCar: (car: string) => void;
    setType: (type: string) => void;
    setIsIcCall: (isIcCall: boolean) => void;
    setCouponDetail: (detail: any) => void;
}

export const useChargingStore = create<ChargingStore>((set) => ({
    stationID: '',
    connector: '',
    processed_coupon_store: [],
    user: '',
    book_time: new Date(),
    end_time: new Date(),
    current_price_store: null,
    total_power: null,
    total_fee: null,
    promotion_code: [],
    coupon_detail: [],
    scanned_qr_code: '',
    car: '',
    type: '',
    is_ic_call: false,
    sum_of_coupon: 0,
    setProcessedCouponStore: (coupons) => set({ processed_coupon_store: coupons }),
    setSumOfCoupon: (sum: string | number) => set({ sum_of_coupon: sum }),
    setStationId: (id) => set({ stationID: id }),
    setConnector: (connector) => set({ connector }),
    setUser: (user) => set({ user }),
    setCurrentPriceStore: (price) => set({ current_price_store: price }),
    setBookTime: (time) => set({ book_time: time }),
    setEndTime: (time) => set({ end_time: time }),
    setTotalPower: (power) => set({ total_power: power }),
    setTotalFee: (fee) => set({ total_fee: fee }),
    setPromotionCode: (code) => set({ promotion_code: code }),
    setCar: (car) => set({ car }),
    setType: (type) => set({ type }),
    setIsIcCall: (isIcCall) => set({ is_ic_call: isIcCall }),
    setCouponDetail: (detail) => set({ coupon_detail: detail }),
    setScannedQrCode: (qrCode) => set({ scanned_qr_code: qrCode })
}));
