import {actionPromise} from "./actionPromise";
import {log} from "./requests";
import {actionAuthLogin} from "./actionAuthLogin";
import {actionFindUser} from "./actionFindUser";

export const actionFullLogin = (login, password) => async (dispatch) => {
	  let result = await dispatch(actionPromise("login", log(login, password)));
	  if (result?.data?.login !== null) {
		  	console.log(result);
		    dispatch(actionAuthLogin(result.data.login));
	  } else {
	    	alert("Такого пользователя не существует!");
	  }
	  await dispatch(actionFindUser());
};



