@@ -3,6 +3,7 @@ import { errorHandler } from '../utils/errorHandler'
33import axios from 'axios'
44import { setRequestStatus } from '../utils/setRequestStatus'
55import { BASE_URL } from './baseApi'
6+ const userId = localStorage . getItem ( 'userId' )
67
78// GET USER PROFILE
89export const getProfile = ( id ) => async ( dispatch ) => {
@@ -31,15 +32,12 @@ export const getProfile = (id) => async (dispatch)=> {
3132// FOLLOW USER
3233export const followUser = ( userId ) => async ( dispatch ) => {
3334 try {
34- let followObj = {
35- followId : userId
36- }
37- console . log ( 'followObj ' , followObj )
38- const res = await axios . patch ( `${ BASE_URL } /user/follow` , followObj )
35+ console . log ( 'followuser ' , userId )
36+ const res = await axios . patch ( `${ BASE_URL } /user/follow/${ userId } ` )
3937 dispatch ( setRequestStatus ( false ) )
4038 if ( res . status === 200 ) {
4139 dispatch ( setRequestStatus ( true ) )
42- console . log ( 'started following ' , followObj )
40+ console . log ( 'started following ' , userId )
4341 dispatch ( {
4442 type : GET_USER_PROFILE ,
4543 payload : res . data . user ,
@@ -53,15 +51,12 @@ export const followUser = (userId) => async (dispatch) => {
5351// UnFOLLOW USER
5452export const unFollowUser = ( userId ) => async ( dispatch ) => {
5553 try {
56- let unFollowObj = {
57- followId : userId
58- }
59- console . log ( 'unfollowObj ' , unFollowObj )
60- const res = await axios . patch ( `${ BASE_URL } /user/unfollow` , unFollowObj )
54+ console . log ( 'unfollowObj ' , userId )
55+ const res = await axios . patch ( `${ BASE_URL } /user/unfollow/${ userId } ` )
6156 dispatch ( setRequestStatus ( false ) )
6257 if ( res . status === 200 ) {
6358 dispatch ( setRequestStatus ( true ) )
64- console . log ( 'unfollowed ' , unFollowObj )
59+ console . log ( 'unfollowed ' , userId )
6560 dispatch ( {
6661 type : GET_USER_PROFILE ,
6762 payload : res . data . user ,
@@ -112,11 +107,11 @@ export const updateProfile = (userId, updatedInfo) => async (dispatch) => {
112107}
113108
114109// GET EVENTS CREATED BY USER
115- export const getEventsCreatedByUser = ( userId , pagination = 10 , page = 1 ) => async ( dispatch ) => {
110+ export const getEventsCreatedByUser = ( id = userId , pagination = 10 , page = 1 ) => async ( dispatch ) => {
116111 try {
117- console . log ( 'getEvents userId ' , userId )
112+ console . log ( 'getEvents userId ' , id )
118113 const res = await axios
119- . get ( `${ BASE_URL } /event/${ userId } /all?pagination=${ pagination } &page=${ page } ` ) ;
114+ . get ( `${ BASE_URL } /event/${ id } /all?pagination=${ pagination } &page=${ page } ` ) ;
120115 dispatch ( setRequestStatus ( false ) )
121116 if ( res . status === 200 ) {
122117 dispatch ( setRequestStatus ( true ) )
@@ -132,11 +127,11 @@ export const getEventsCreatedByUser = (userId, pagination = 10, page = 1) => asy
132127}
133128
134129// GET ALL PROJECT CREATED BY A USER
135- export const getProjectCreatedByUser = ( userId , pagination = 10 , page = 1 ) => async ( dispatch ) => {
130+ export const getProjectCreatedByUser = ( id = userId , pagination = 10 , page = 1 ) => async ( dispatch ) => {
136131 try {
137- console . log ( 'getProjects userId ' , userId )
132+ console . log ( 'getProjects userId ' , id )
138133 const res = await axios
139- . get ( `${ BASE_URL } /project/${ userId } /all?pagination=${ pagination } &page=${ page } ` ) ;
134+ . get ( `${ BASE_URL } /project/${ id } /all?pagination=${ pagination } &page=${ page } ` ) ;
140135 dispatch ( setRequestStatus ( false ) )
141136 if ( res . status === 200 ) {
142137 dispatch ( setRequestStatus ( true ) )
@@ -152,11 +147,11 @@ export const getProjectCreatedByUser = (userId, pagination = 10, page = 1) => as
152147}
153148
154149// GET POSTS CREATED BY USER
155- export const getPostsCreatedByUser = ( userId , pagination = 10 , page = 1 ) => async ( dispatch ) => {
150+ export const getPostsCreatedByUser = ( id = userId , pagination = 10 , page = 1 ) => async ( dispatch ) => {
156151 try {
157- console . log ( 'getPosts userId ' , userId )
152+ console . log ( 'getPosts userId ' , id )
158153 const res = await axios
159- . get ( `${ BASE_URL } /post/${ userId } /all?pagination=${ pagination } &page=${ page } ` ) ;
154+ . get ( `${ BASE_URL } /post/${ id } /all?pagination=${ pagination } &page=${ page } ` ) ;
160155 dispatch ( setRequestStatus ( false ) )
161156 if ( res . status === 200 ) {
162157 dispatch ( setRequestStatus ( true ) )
@@ -174,7 +169,7 @@ export const getPostsCreatedByUser = (userId, pagination = 10, page = 1) => asyn
174169// GET INVITE LINK
175170export const getInviteLink = ( role ) => async ( dispatch ) => {
176171 try {
177- const res = await axios . get ( `${ BASE_URL } /user/invite?role=${ role } ` )
172+ const res = await axios . get ( `${ BASE_URL } /user/link/ invite?role=${ role } ` )
178173 dispatch ( setRequestStatus ( false ) ) ;
179174 if ( res . status === 200 ) {
180175 dispatch ( setRequestStatus ( true ) ) ;
@@ -221,9 +216,11 @@ export const activateDeactivateToggler = () => async (dispatch) => {
221216 const res = await axios . patch ( `${ BASE_URL } /user/deactivate/toggler` )
222217 if ( res . status === 200 ) {
223218 console . log ( 'Deactivation toggler' , res . data ) ;
224- dispatch ( getProfile ( ) ) ;
219+ dispatch ( getProfile ( userId ) ) ;
225220 }
226221 } catch ( error ) {
227222 dispatch ( errorHandler ( error ) )
228223 }
229- }
224+ }
225+
226+ // GET USER'S ACTIVITY
0 commit comments