import { createTypedReducerWithImmer } from "@insite/client-framework/Common/CreateTypedReducer";
import AddressBookOverlayState from "@insite/client-framework/Store/Components/AddressBookOverlay/AddressBookOverlayState";
import { Draft } from "immer";

const initialState: AddressBookOverlayState = {
    isOpen: false,
    isBillTo: false,
};

const reducer = {
    "Components/AddressBookOverlay/SetAddressBookOverlayIsOpen": (
        draft: Draft<AddressBookOverlayState>,
        action: { isOpen: boolean; isBillTo?: boolean },
    ) => {
        draft.isOpen = action.isOpen;
        draft.isBillTo = action.isBillTo;
    },
};

export default createTypedReducerWithImmer(initialState, reducer);
