|
@@ -1,3 +1,4 @@
|
|
|
|
+import { actionAuthLogin } from '../Redux/auth_reducer';
|
|
import {actionPromise, store} from '../Redux/promise_reducer';
|
|
import {actionPromise, store} from '../Redux/promise_reducer';
|
|
|
|
|
|
const urlConst = '/graphql';
|
|
const urlConst = '/graphql';
|
|
@@ -16,15 +17,33 @@ const getGQL = (url) => (query, variables = {}) => {
|
|
|
|
|
|
export const gql = getGQL(urlConst);
|
|
export const gql = getGQL(urlConst);
|
|
|
|
|
|
-export const actionLogin = async (login, password) => {
|
|
|
|
- store.dispatch(actionPromise('Login', gql(`query Login($loginStr: String!, $passwordStr: String!){
|
|
|
|
|
|
+// export const actionLogin = async (login, password) => {
|
|
|
|
+// store.dispatch(actionPromise('Login', gql(`query Login($loginStr: String!, $passwordStr: String!){
|
|
|
|
+// login(login: $loginStr, password: $passwordStr)
|
|
|
|
+// }`,
|
|
|
|
+// {
|
|
|
|
+// "loginStr": "Pocu46",
|
|
|
|
+// "passwordStr": "a190689"
|
|
|
|
+// })
|
|
|
|
+// )
|
|
|
|
+// )
|
|
|
|
+// // console.log(resLogin)
|
|
|
|
+// }
|
|
|
|
+export const actionLogin = (login, password) => async (dispatch) => {
|
|
|
|
+ console.log(login, password)
|
|
|
|
+ let result = await dispatch(actionPromise('Login', gql(`query Login($loginStr: String!, $passwordStr: String!){
|
|
login(login: $loginStr, password: $passwordStr)
|
|
login(login: $loginStr, password: $passwordStr)
|
|
}`,
|
|
}`,
|
|
{
|
|
{
|
|
- "loginStr": "Pocu46",
|
|
|
|
- "passwordStr": "a190689"
|
|
|
|
|
|
+ "loginStr": login,
|
|
|
|
+ "passwordStr": password
|
|
})
|
|
})
|
|
)
|
|
)
|
|
)
|
|
)
|
|
- // console.log(resLogin)
|
|
|
|
|
|
+ // console.log(result)
|
|
|
|
+ if(result?.data?.login) {
|
|
|
|
+ dispatch(actionAuthLogin(result.data.login))
|
|
|
|
+ } else {
|
|
|
|
+ alert("Authorization failed")
|
|
|
|
+ }
|
|
}
|
|
}
|