import {actionPromise} from "./actionPromise";
import {actionAuthLogin} from "./actionAuthLogin";
import {log} from "./gqlRequests";

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

/*const actionFullLogin = (login,password) =>
	async function i(dispatch){
		let token = await dispatch(actionLogin(login,password));
		console.log(token);
		if(token){
			dispatch(actionAuthLogin(token));
		}
	}*/
