import produce from 'immer';
import { Fragment } from 'react';

export const initialState = {
    prompt: {
      show: false,
      title: '',
      message: '',
      defaultValue: '',
      component: null,
      inputStyle: {},
      onConfirm: (text) => {},
      onCancel: () => {},
    },
};

export default function reducer(state = initialState, action = {}) {
    return produce(state, draft => {
        switch (action.type) {
            case PROMPT_OPEN:
                draft.prompt = action.payload;
                break;
        }
    });
}

export const PROMPT_OPEN = 'GLOBAL_PROMPT/OPEN';
export const promptOpenAction = payload => ({ type: PROMPT_OPEN, payload });
