import actionPromise from "./action-promise";
import { gql } from '../../graphQl/getGQL'
import jwtDecode from '../../helpers/jwt-decode'

// export const actionSearchUser = (login, _id) => async (dispatch) => {
//     // let _id = jwtDecode(localStorage.authToken).sub.id
//     return(
//         actionPromise('searchUs', gql(`
//         query($userLogin: String!){
//             UserFindOne(query: $userLogin){
//                 login, _id
//             }
//         }`, { userLogin: JSON.stringify([{ login }]) }))
//     )
// }

export const actionSearchUser = (login) => {
    let _id = jwtDecode(localStorage.authToken).sub.id
    return(
        actionPromise('searchUs', gql(`
        query($userLogin: String!){
            UserFindOne(query: $userLogin){
                login, _id
            }
        }`, { userLogin: JSON.stringify([{ login }]) }))
    )
}