import { createTypedReducerWithImmer } from "@insite/client-framework/Common/CreateTypedReducer";
import { WidgetPropsWithChildren } from "@insite/client-framework/Types/WidgetProps";
import { ClipboardState } from "@insite/shell/Store/Clipboard/ClipboardState";
import { Draft } from "immer";

const initialState: ClipboardState = {};

const reducer = {
    "Clipboard/CopyWidget": (
        draft: Draft<ClipboardState>,
        action: {
            widget: WidgetPropsWithChildren;
        },
    ) => {
        draft.widget = action.widget;
    },
    "Clipboard/ClearWidget": (draft: Draft<ClipboardState>) => {
        delete draft.widget;
    },
};

export default createTypedReducerWithImmer(initialState, reducer);
