Skip to content

Commit 5092626

Browse files
committed
Reverted changes to user.js, MyStories.js, Profile.js
1 parent ca7dc53 commit 5092626

File tree

8 files changed

+206
-171
lines changed

8 files changed

+206
-171
lines changed

src/pages/Home.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,14 @@ const Home = () => {
103103

104104
useEffect(() => {
105105
const fetchStories = async () => {
106-
const response = await userStory.getStories({
107-
limit: 5,
106+
const response = await userStory.getStories(
108107
page,
109108
currentStateSelected,
110109
authorQuery,
111110
categoryQuery,
112111
productQuery,
113112
searchQuery
114-
})
113+
)
115114
setStories(response.data.data.userStories)
116115
}
117116
trackPromise(fetchStories())

src/pages/MyProfile.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import Navigation from '../components/Navigation'
77
import Context from '../modules/Context'
88
import Login from './Login'
99
import UserProfile from '../components/UserProfile'
10-
import User from '../services/user'
10+
import userStory from '../services/user_story'
1111

1212
const MyProfile = () => {
1313
const userId = localStorage.getItem('id')
@@ -28,15 +28,15 @@ const MyProfile = () => {
2828
}
2929

3030
const updateProfile = async () => {
31-
const response = await User.updateUser({ id: userId, ...user })
31+
const response = await userStory.updateUser({ id: userId, ...user })
3232
if (response) {
3333
setUpdated(true)
3434
}
3535
}
3636

3737
useEffect(() => {
3838
const fetchUserInfo = async () => {
39-
const response = await User.getInfo(userId)
39+
const response = await userStory.getUserDetails(userId)
4040
setUser(response.data.data.user)
4141
}
4242
if (userId) {

src/pages/MyStories.js

Lines changed: 67 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import React, { useState, useEffect, useRef, useContext } from 'react'
2+
import { apiURL } from '../config.json'
23
import { trackPromise, usePromiseTracker } from 'react-promise-tracker'
34
import { Helmet } from 'react-helmet'
45

6+
import axios from 'axios'
7+
58
import LoadingIndicator from '../modules/LoadingIndicator'
69
import Button from '../components/Button'
710
import StoriesList from '../components/StoriesList'
@@ -62,15 +65,73 @@ const MyStories = () => {
6265

6366
useEffect(() => {
6467
const fetchMyStories = async () => {
65-
const response = await userStory.getStories({
66-
authorId: id
67-
})
68+
const response = await axios.post(
69+
`${apiURL}/graphql`,
70+
{
71+
query: `query {
72+
userStories(where: { author: "${id}" }) {
73+
id
74+
Title
75+
Description
76+
followers {
77+
id
78+
username
79+
}
80+
user_story_comments {
81+
Comments
82+
}
83+
product {
84+
Name
85+
}
86+
author {
87+
id
88+
username
89+
}
90+
user_story_status {
91+
Status
92+
}
93+
Category
94+
}
95+
}`
96+
},
97+
{
98+
withCredentials: true
99+
}
100+
)
68101
setStories(response.data.data.userStories)
69102
}
70103
const fetchFollowingStories = async () => {
71-
const response = await userStory.getStories({
72-
followers: id
73-
})
104+
const response = await axios.post(
105+
`${apiURL}/graphql`,
106+
{
107+
query: `query {
108+
userStories(where: { followers: "${id}" }) {
109+
id
110+
Title
111+
Description
112+
followers {
113+
id
114+
}
115+
user_story_comments {
116+
Comments
117+
}
118+
product {
119+
Name
120+
}
121+
author {
122+
id
123+
username
124+
}
125+
user_story_status {
126+
Status
127+
}
128+
}
129+
}`
130+
},
131+
{
132+
withCredentials: true
133+
}
134+
)
74135
setStories(response.data.data.userStories)
75136
}
76137
if (currentStateSelected === 'My Submissions')

src/pages/Profile.js

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import React, { useState, useEffect, useRef } from 'react'
2+
import axios from 'axios'
3+
import { apiURL } from '../config.json'
24
import { trackPromise, usePromiseTracker } from 'react-promise-tracker'
35
import { Helmet } from 'react-helmet'
46
import { navigate } from '@reach/router'
@@ -12,7 +14,6 @@ import UserProfile from '../components/UserProfile'
1214
import Lists from '../utils/Lists'
1315

1416
import userStory from '../services/user_story'
15-
import User from '../services/user'
1617

1718
const Profile = (props) => {
1819
const { profileId } = props
@@ -63,7 +64,7 @@ const Profile = (props) => {
6364

6465
useEffect(() => {
6566
const fetchUserInfo = async () => {
66-
const response = await User.getInfo(profileId)
67+
const response = await userStory.getUserDetails(profileId)
6768
setUser(response.data.data.user)
6869
}
6970
if (profileId) {
@@ -73,7 +74,40 @@ const Profile = (props) => {
7374

7475
useEffect(() => {
7576
const fetchMyStories = async () => {
76-
const response = await User.getUserStoriesByUser(profileId)
77+
const response = await axios.post(
78+
`${apiURL}/graphql`,
79+
{
80+
query: `query {
81+
user(id: "${profileId}") {
82+
user_stories {
83+
id
84+
Title
85+
Description
86+
user_story_status {
87+
Status
88+
}
89+
followers {
90+
username
91+
}
92+
product {
93+
Name
94+
}
95+
author {
96+
id
97+
username
98+
}
99+
user_story_comments {
100+
Comments
101+
}
102+
Category
103+
}
104+
}
105+
}`
106+
},
107+
{
108+
withCredentials: true
109+
}
110+
)
77111
setStories(response.data.data.user.user_stories)
78112
}
79113
trackPromise(fetchMyStories())
File renamed without changes.

src/services/user.js

Lines changed: 0 additions & 81 deletions
This file was deleted.

0 commit comments

Comments
 (0)