import { createTypedReducerWithImmer } from "@insite/client-framework/Common/CreateTypedReducer";
import { ProductRecommendationWidgetModel } from "@insite/client-framework/Services/ProductRecommendationsService";
import ProductRecommendationsState from "@insite/client-framework/Store/Components/ProductRecommendations/ProductRecommendationsState";
import { Draft } from "immer";

const initialState: ProductRecommendationsState = {
    isPeeriusLoaded: false,
};

const reducer = {
    "Components/ProductRecommendations/SetIsPeeriusLoaded": (draft: Draft<ProductRecommendationsState>) => {
        draft.isPeeriusLoaded = true;
    },
    "Components/ProductRecommendations/SetWidgets": (
        draft: Draft<ProductRecommendationsState>,
        action: { widgets: ProductRecommendationWidgetModel[] },
    ) => {
        draft.widgets = action.widgets;
    },
};

export default createTypedReducerWithImmer(initialState, reducer);
