import { SET_DIAG_TO_MAINSUIT } from '@store/types/diagnosticList';
import { SAVE_FREE } from '@store/types/mainSuit';
import {ISREAD} from "../types/homePage";
export const isAddMainSuit = () =>{
    return (dispatch, getState) => {
        const state = getState();
        if(state.diagnosticList.diagnosticList.length === 1 && state.diagnosticList.diagnosticList[0].type === 2) {
            
            if(state.mainSuit.data && state.mainSuit.data.length === 0 && state.mainSuit.saveText && (state.mainSuit.saveText.length === 0 || state.mainSuit.saveText.length === 1 &&  state.mainSuit.saveText[0] === '')) {
              dispatch({
                type:ISREAD
              });
                dispatch({
                    type: SET_DIAG_TO_MAINSUIT,
                    data: state.diagnosticList.diagnosticStr
                })
                dispatch({
                    type: SAVE_FREE,
                    data:state.diagnosticList.diagnosticStr
                })
            }
        }
        
    }
}

