|
@@ -41,7 +41,7 @@ let reg = async(login, password) => {
|
|
|
return res
|
|
|
}
|
|
|
|
|
|
-let changePass = async(login, password, newPassword) => {
|
|
|
+let ChangePass = async(login, password, newPassword) => {
|
|
|
let query = `mutation changePass($login:String!, $password:String!, $newPassword:String!) {
|
|
|
changePassword(
|
|
|
login: $login,
|
|
@@ -58,6 +58,33 @@ let changePass = async(login, password, newPassword) => {
|
|
|
return res
|
|
|
}
|
|
|
|
|
|
+let SnippetUpsert = async (title, description, files , id) => {
|
|
|
+ let query = `mutation SnippetUpsert($snippet:SnippetInput) {
|
|
|
+ SnippetUpsert(snippet:$snippet){
|
|
|
+ _id
|
|
|
+ }
|
|
|
+ }`
|
|
|
+
|
|
|
+ let variables = { snippet: { title, description, files } ,_id: id };
|
|
|
+
|
|
|
+ let res = await gql(query, variables)
|
|
|
+ return res
|
|
|
+}
|
|
|
+
|
|
|
+const UserFind = async (_id) => {
|
|
|
+ let query = `UserFind(query:'[{}])' {
|
|
|
+ UserFind(query:$query) {
|
|
|
+ _id login nick avatar{
|
|
|
+ url
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }`
|
|
|
+ let variables = { query: JSON.stringify([{ _id }])}
|
|
|
+
|
|
|
+ let res = await gql(query, variables)
|
|
|
+ return res
|
|
|
+}
|
|
|
+
|
|
|
// actions
|
|
|
|
|
|
const actionPending = name => ({type: 'PROMISE', status: 'PENDING', name})
|
|
@@ -77,12 +104,15 @@ const actionPromise = (name, promise) =>
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// export const actionchangePass = (login, password, newPassword) => actionPromise("changePass", changePass(login, password, newPassword))
|
|
|
+export const actionchangePass = (login, password, newPassword) => actionPromise("changePass", ChangePass(login, password, newPassword))
|
|
|
const actionAuthLogin = token => ({type: 'LOGIN', token})
|
|
|
-// const actionAuthLogout = () => ({type: 'LOGOUT'})
|
|
|
+export const actionAuthLogout = () => ({type: 'LOGOUT'})
|
|
|
const actionLogin = (login, password) => actionPromise("login", log(login, password))
|
|
|
const actionReg = (login, password) => actionPromise("reg", reg(login, password))
|
|
|
|
|
|
+export const actionUserFind = (_id) => actionPromise("UserFind", UserFind(_id))
|
|
|
+export const actionSnippetUpsert = (title, description, files , id) => actionPromise("UserFind", SnippetUpsert(title, description, files , id))
|
|
|
+
|
|
|
export const actionFullLogin = (login, password) => async(dispatch) => {
|
|
|
let result = await dispatch(actionLogin(login, password))
|
|
|
if (result !== null){
|