Skip to content

Commit a436f98

Browse files
Merge branch 'development' into post-integrations
2 parents de8adc4 + 1f48f6a commit a436f98

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+793
-481
lines changed

src/actions/eventAction.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,20 @@ import { errorHandler } from '../utils/errorHandler';
33
import { setRequestStatus } from '../utils/setRequestStatus';
44
import { GET_ALL_EVENTS, GET_EVENT_BY_ID } from './types';
55
import { BASE_URL } from './baseApi'
6+
import { customErrorHandler } from '../utils/customErrorHandler';
67

78
// DELETE EVENT REQUEST
89
export const deleteEvent = (eventId) => async (dispatch) => {
910
try {
1011
const res = await axios.delete(`${BASE_URL}/event/${eventId}`)
11-
dispatch(setRequestStatus(false));
1212
if(res.status === 200){
13-
dispatch(setRequestStatus(true));
1413
dispatch(getAllEvents())
1514
}
1615
} catch(error) {
17-
dispatch(errorHandler(error))
16+
const msg = {
17+
error: error?.response?.msg
18+
}
19+
dispatch(customErrorHandler(msg))
1820
}
1921
}
2022

@@ -47,7 +49,7 @@ export const createEvent = (eventInfo, history) => async (dispatch) => {
4749
}
4850

4951
// GET ALL EVENTS
50-
export const getAllEvents = (pagination = 10, page = 1) => async (dispatch) => {
52+
export const getAllEvents = (pagination = 6, page = 1) => async (dispatch) => {
5153
try {
5254
const res = await axios.get(`${BASE_URL}/event/all?pagination=${pagination}&page=${page}`)
5355
dispatch(setRequestStatus(false))

src/actions/orgAction.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import {
66
UPDATE_ORG_PROFILE,
77
DEACTIVATE_ORG,
88
GET_ALL_MEMBERS,
9-
TRIGGER_MAINTENANCE
9+
TRIGGER_MAINTENANCE,
10+
GET_LOGIN_OPTIONS
1011
} from './types'
1112

1213
import { BASE_URL } from './baseApi'
@@ -149,4 +150,20 @@ export const TriggerMaintenance = () => async (dispatch) => {
149150
} catch (error) {
150151
dispatch(errorHandler(error))
151152
}
153+
}
154+
155+
// GET LOGIN OPTIONS
156+
export const getLoginOptions = () => async (dispatch) => {
157+
try {
158+
const res = await axios.get(`${BASE_URL}/org/login/options`)
159+
if(res.status === 200) {
160+
console.log('fetched login options ', res.data)
161+
dispatch({
162+
type: GET_LOGIN_OPTIONS,
163+
payload: res.data.methods
164+
})
165+
}
166+
} catch(error) {
167+
dispatch(errorHandler(error))
168+
}
152169
}

src/actions/postAction.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,16 @@ export const removeReaction = (postId, type) => async (dispatch) => {
114114
dispatch(errorHandler(error));
115115
}
116116
};
117+
118+
// PIN POST BY ID
119+
export const pinPost = (postId) => async (dispatch) => {
120+
try {
121+
const res = await axios.patch(`${BASE_URL}/post/pin/${postId}`)
122+
if (res.status === 200) {
123+
console.log('post pinned ', res.data.post)
124+
dispatch(getAllPinnedPosts(10, 1));
125+
}
126+
} catch(error) {
127+
dispatch(errorHandler(error))
128+
}
129+
}

src/actions/projectAction.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const createProject = (projectInfo) => async (dispatch) => {
2020
}
2121

2222
// GET ALL PROJECTS
23-
export const getAllProjects = (pagination = 10, page = 1) => async (dispatch) => {
23+
export const getAllProjects = (pagination = 6, page = 1) => async (dispatch) => {
2424
try {
2525
const res = await axios.get(`${BASE_URL}/project/?pagination=${pagination}&page=${page}`)
2626
dispatch(setRequestStatus(false))

src/actions/types.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,5 @@ export const GET_DEVICE_ANALYTICS ="GET_DEVICE_ANALYTICS"
5353
export const GET_MOSTVIEWED_ANALYTICS ="GET_MOSTVIEWED_ANALYTICS"
5454
export const GET_PROPOSALVIEW_ANALYTICS="GET_PROPOSALVIEW_ANALYTICS"
5555
export const ACTIVATE_DEACTIVATE_ACCOUNT_TOGGLER = "ACTIVATE_DEACTIVATE_ACCOUNT_TOGGLER";
56-
export const CLEAR_INVITE_LINK = "CLEAR_INVITE_LINK"
56+
export const CLEAR_INVITE_LINK = "CLEAR_INVITE_LINK";
57+
export const GET_LOGIN_OPTIONS = "GET_LOGIN_OPTIONS";

src/actions/usersAction.js

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { errorHandler } from '../utils/errorHandler'
33
import axios from 'axios'
44
import { setRequestStatus } from '../utils/setRequestStatus'
55
import { BASE_URL } from './baseApi'
6+
const userId = localStorage.getItem('userId')
67

78
// GET USER PROFILE
89
export const getProfile = (id) => async (dispatch)=> {
@@ -31,15 +32,12 @@ export const getProfile = (id) => async (dispatch)=> {
3132
// FOLLOW USER
3233
export 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
5452
export 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
175170
export 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));
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)