import { produce } from "immer";
import { WorkspaceActions } from "../actions/workspaceActions";
export const initialState = {
    activeWorkspace: {
        name: "",
    },
    workspaces: [],
    promptOnSave: false,
};
export const workspaceReducer = produce((state, action) => {
    WorkspaceActions.match(action, {
        UPDATE_ALL_WORKSPACES: ({ activeWorkspace, workspaces }) => {
            state.activeWorkspace = activeWorkspace;
            if (workspaces) {
                // We only care about the name returned by the workspaceService updates
                state.workspaces = workspaces.map(({ name }) => {
                    return { name };
                });
            }
        },
        UPDATE_PROMPT_ON_SAVE_WORKSPACE_PREFERENCE: (promptOnSave) => {
            state.promptOnSave = promptOnSave;
        },
        default: () => state,
    });
}, initialState);
//# sourceMappingURL=workspaceReducer.js.map