import { create } from 'zustand';
import { immer } from 'zustand/middleware/immer';

interface BuilderState {
    aisleType: AisleTypes;
    aisleWidth: number;
    aisleColor: AisleColors;
    setAisleType: (type: AisleTypes) => void;
    setAisleWidth: (width: number) => void;
    setAisleColor: (color: AisleColors) => void;
    setAisleProperties: (type: AisleTypes, width: number, color: AisleColors) => void;
}

export const useBuilderStore = create<BuilderState>()(
    immer((set) => ({
        aisleType: 'solid-aisle',
        aisleWidth: 0.1,
        aisleColor: 'gray',
        setAisleType: (type) => {
            set((state) => {
                state.aisleType = type;
            });
        },
        setAisleWidth: (width) => {
            set((state) => {
                state.aisleWidth = width;
            });
        },
        setAisleColor: (color) => {
            set((state) => {
                state.aisleColor = color;
            });
        },
        setAisleProperties: (type, width, color) => {
            set((state) => {
                state.aisleType = type;
                state.aisleWidth = width;
                state.aisleColor = color;
            });
        }
    }))
);