action-aboutMe.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import actionPromise from "./action-promise";
  2. import { gql } from '../../graphQl/getGQL'
  3. import jwtDecode from '../../helpers/jwt-decode'
  4. export const actionAboutMe = () => {
  5. let _id = jwtDecode(localStorage.authToken).sub.id
  6. return (
  7. actionPromise('userData', gql(`
  8. query($userId: String!) {
  9. UserFindOne(query: $userId){
  10. login, _id, avatar {_id, url, originalFileName}, chats{
  11. members {
  12. _id
  13. createdAt
  14. login
  15. nick
  16. }
  17. messages {
  18. _id
  19. createdAt
  20. text
  21. owner {
  22. _id
  23. createdAt
  24. login
  25. nick
  26. }
  27. media {
  28. _id
  29. createdAt
  30. text
  31. url
  32. originalFileName
  33. type
  34. }
  35. }
  36. _id
  37. createdAt
  38. title
  39. lastMessage {
  40. _id
  41. createdAt
  42. text
  43. }
  44. }
  45. }
  46. }
  47. `, { userId: JSON.stringify([{ _id }]) }))
  48. )
  49. }