Skip to content

Commit dbd2b4c

Browse files
committed
integrated notification, events, projects, Followers, followings, admins, setup, insight
1 parent 52de8fb commit dbd2b4c

38 files changed

+4680
-4614
lines changed

package-lock.json

Lines changed: 3704 additions & 4364 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"react-redux": "^7.2.0",
2525
"react-responsive": "^8.0.3",
2626
"react-router-dom": "^5.1.2",
27-
"react-scripts": "3.3.0",
27+
"react-scripts": "^3.4.0",
2828
"react-toastify": "^6.0.5",
2929
"redux": "^4.0.5",
3030
"redux-thunk": "^2.3.0",

src/actions/adminAction.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import axios from 'axios'
2+
import { errorHandler } from '../utils/errorHandler'
3+
import { setRequestStatus } from '../utils/setRequestStatus'
4+
import { SET_ADMIN } from './types'
5+
6+
export const createAdmin = (adminInfo) => async (dispatch) => {
7+
try {
8+
const res = await axios.post('/user/', adminInfo)
9+
setRequestStatus(false)
10+
if (res.status === 201) {
11+
setRequestStatus(true)
12+
}
13+
} catch (error) {
14+
dispatch(errorHandler(error))
15+
}
16+
}
17+
18+
export const loginAdmin = (adminInfo) => async (dispatch) => {
19+
try {
20+
const res = await axios.post('/auth/login/', adminInfo)
21+
dispatch(setRequestStatus(false))
22+
if (res.status === 200) {
23+
dispatch(setRequestStatus(true))
24+
localStorage.setItem('admin', true)
25+
dispatch({
26+
type: SET_ADMIN,
27+
payload: true
28+
})
29+
}
30+
} catch (error) {
31+
dispatch(errorHandler(error))
32+
}
33+
}

src/actions/authAction.js

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export const registerUser = (userInfo, history) => async (dispatch) => {
1414

1515
if(res.status === 201) {
1616
dispatch(setRequestStatus(true));
17-
history.push('/dashboard');
17+
history.push('/');
1818
}
1919

2020
} catch(error) {
@@ -86,15 +86,26 @@ export const changePassword = (passObj) => async (dispatch) => {
8686

8787

8888
// to logout user
89-
export const logoutUser = () => {
90-
// remove token from the localStorage
91-
localStorage.removeItem('jwtToken');
92-
// delete authorization from the header
93-
setAuthToken(false);
94-
// set user to {}
95-
setCurrentUser({});
96-
// move to home
97-
window.location.href = "/";
89+
export const logoutUser = () => async (dispatch) => {
90+
try {
91+
console.log('Logging out!!')
92+
// clear token from backend
93+
const res = await axios.post('/user/logout')
94+
if (res.status === 200) {
95+
// remove token from the localStorage
96+
localStorage.removeItem('jwtToken');
97+
// remove userID
98+
localStorage.removeItem('userId')
99+
// delete authorization from the header
100+
setAuthToken(false);
101+
// set user to {}
102+
setCurrentUser({});
103+
// move to home
104+
window.location.href = "/";
105+
}
106+
} catch (error) {
107+
dispatch(errorHandler(error))
108+
}
98109
}
99110

100111
export const setCurrentUser = (decodedData) => {

src/actions/dashboardAction.js

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import axios from 'axios'
2+
import { setRequestStatus } from '../utils/setRequestStatus'
3+
import { errorHandler } from '../utils/errorHandler'
4+
import { GET_ALL_UPCOMING_EVENTS } from './types'
5+
6+
// GET UPCOMING EVENTS
7+
export const upcomingEvents = () => async (dispatch) => {
8+
try {
9+
const res = await axios.get('/event/upcoming')
10+
dispatch(setRequestStatus(false))
11+
if (res.status === 200) {
12+
dispatch(setRequestStatus(true))
13+
console.log('upcoming events called!', res.data)
14+
dispatch({
15+
type: GET_ALL_UPCOMING_EVENTS,
16+
payload: res.data.events || res.data.msg
17+
})
18+
}
19+
} catch (error) {
20+
dispatch(errorHandler(error))
21+
}
22+
}
23+
24+
// CREATE POST
25+
export const createPost = (postInfo) => async (dispatch) => {
26+
try {
27+
const res = await axios.post('/post/', postInfo)
28+
dispatch(setRequestStatus(false))
29+
if (res.status === 201) {
30+
dispatch(setRequestStatus(true))
31+
console.log('post created ', res.data)
32+
}
33+
} catch (error) {
34+
dispatch(errorHandler(error))
35+
}
36+
}
37+
38+
// CREATE EVENT
39+
export const createEvent = (eventInfo) => async (dispatch) => {
40+
try {
41+
const res = await axios.post('/event/', eventInfo)
42+
dispatch(setRequestStatus(false))
43+
if (res.status === 201) {
44+
dispatch(setRequestStatus(true))
45+
console.log('event created ', res.data)
46+
}
47+
} catch (error) {
48+
dispatch(errorHandler(error))
49+
}
50+
}
51+
52+
// CREATE PROJECT
53+
export const createProject = (projectInfo) => async (dispatch) => {
54+
try {
55+
console.log('projectInfo ', projectInfo)
56+
const res = await axios.post('/project/', projectInfo)
57+
dispatch(setRequestStatus(false))
58+
if (res.status === 201) {
59+
dispatch(setRequestStatus(true))
60+
console.log('project created ', res.data)
61+
}
62+
} catch (error) {
63+
dispatch(errorHandler(error))
64+
}
65+
}

src/actions/insightAction.js

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
import { GET_ALL_MEMBERS, GET_ORG_OVERVIEW, GET_PERSONAL_OVERVIEW, SEARCH_MEMBER, BLOCK_USER, UNBLOCK_USER } from './types'
2+
import axios from 'axios'
3+
import { errorHandler } from '../utils/errorHandler'
4+
import { setRequestStatus } from '../utils/setRequestStatus'
5+
6+
// GET ORGANIZATIONAL OVERVIEW
7+
export const getOrgOverview = () => async (dispatch) => {
8+
try {
9+
const res = await axios.get('/org/overview/all')
10+
dispatch(setRequestStatus(false))
11+
if (res.status === 200) {
12+
dispatch(setRequestStatus(true))
13+
console.log('getOrgOverview ', res.data)
14+
dispatch({
15+
type: GET_ORG_OVERVIEW,
16+
payload: res.data.orgOverView
17+
})
18+
}
19+
} catch (error) {
20+
dispatch(errorHandler(error))
21+
}
22+
}
23+
24+
// GET PERSONAL OVERVIEW
25+
export const getPersonalOverview = () => async (dispatch) => {
26+
try {
27+
const res = await axios.get('/user/overview')
28+
dispatch(setRequestStatus(false))
29+
if (res.status === 200) {
30+
dispatch(setRequestStatus(true))
31+
console.log('getPersonalOverview ', res.data)
32+
dispatch({
33+
type: GET_PERSONAL_OVERVIEW,
34+
payload: res.data.personalOverview
35+
})
36+
}
37+
} catch (error) {
38+
dispatch(errorHandler(error))
39+
}
40+
}
41+
42+
// GET ALL MEMBERS
43+
export const getMembers = () => async (dispatch) => {
44+
try {
45+
const res = await axios.get('/org/members/all')
46+
dispatch(setRequestStatus(false))
47+
if (res.status === 200) {
48+
dispatch(setRequestStatus(true))
49+
console.log('getMembers ', res.data)
50+
dispatch({
51+
type: GET_ALL_MEMBERS,
52+
payload: res.data.members
53+
})
54+
}
55+
} catch (error) {
56+
dispatch(errorHandler(error))
57+
}
58+
}
59+
60+
// SEARCH MEMBER BY FIRST NAME, LAST NAME, FULL NAME
61+
export const getMember = (query) => async (dispatch) => {
62+
try {
63+
console.log('Looking for member ', query)
64+
const res = await axios.get(`/org/members/all?search=${query}`)
65+
dispatch(setRequestStatus(false))
66+
if (res.status === 200) {
67+
dispatch(setRequestStatus(true))
68+
console.log('getMember by name ', res.data)
69+
dispatch({
70+
type: SEARCH_MEMBER,
71+
payload: res.data.member
72+
})
73+
}
74+
} catch (error) {
75+
dispatch(errorHandler(error))
76+
}
77+
}
78+
79+
// BLOCK A USER (BY ADMIN)
80+
export const blockUser = (userId) => async (dispatch) => {
81+
try {
82+
const res = await axios.patch(`/user/block/${userId}`)
83+
dispatch(setRequestStatus(false))
84+
if (res.status === 200) {
85+
dispatch(setRequestStatus(true))
86+
console.log('user blocked!', res.data)
87+
dispatch({
88+
type: BLOCK_USER,
89+
payload: true
90+
})
91+
}
92+
} catch (error) {
93+
dispatch(errorHandler(error))
94+
}
95+
}
96+
97+
// UNBLOCK A USER (BY ADMIN)
98+
export const unBlockUser = (userId) => async (dispatch) => {
99+
try {
100+
const res = await axios.patch(`/user/unblock/${userId}`)
101+
dispatch(setRequestStatus(false))
102+
if (res.status === 200) {
103+
dispatch(setRequestStatus(true))
104+
console.log('user unblocked!', res.data)
105+
dispatch({
106+
type: UNBLOCK_USER,
107+
payload: false // isBlocked = false
108+
})
109+
}
110+
} catch (error) {
111+
dispatch(errorHandler(error))
112+
}
113+
}

src/actions/orgAction.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import axios from 'axios'
2+
import { setRequestStatus } from '../utils/setRequestStatus'
3+
import { errorHandler } from '../utils/errorHandler'
4+
5+
// CREATE COMMUNITY
6+
export const registerCommunity = (orgInfo) => async (dispatch) => {
7+
try {
8+
const res = await axios.post('/org/', orgInfo)
9+
dispatch(setRequestStatus(false))
10+
if (res.status === 201) {
11+
dispatch(setRequestStatus(true))
12+
}
13+
} catch (error) {
14+
dispatch(errorHandler(error))
15+
}
16+
}

src/actions/types.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,14 @@ export const SET_ERROR = "SET_ERROR";
66
export const SET_STATUS = "SET_STATUS";
77
export const GET_PLATFORM_NOTIFICATIONS = "GET_PLATFORM_NOTIFICATIONS";
88
export const GET_USER_NOTIFICATIONS = "GET_USER_NOTIFICATIONS";
9-
export const GET_ALL_NOTIFICATIONS = "GET_ALL_NOTIFICATIONS";
9+
export const GET_ALL_NOTIFICATIONS = "GET_ALL_NOTIFICATIONS";
10+
export const SET_ADMIN = "SET_ADMIN";
11+
export const GET_ALL_UPCOMING_EVENTS = "GET_ALL_UPCOMING_EVENTS";
12+
export const GET_ALL_MEMBERS = "GET_ALL_MEMBERS";
13+
export const GET_PERSONAL_OVERVIEW = "GET_PERSONAL_OVERVIEW";
14+
export const GET_ORG_OVERVIEW = "GET_ORG_OVERVIEW";
15+
export const SEARCH_MEMBER = "SEARCH_MEMBER";
16+
export const BLOCK_USER = "BLOCK_USER";
17+
export const UNBLOCK_USER = "UNBLOCK_USER";
18+
export const REMOVE_USER = "REMOVE_USER";
19+
export const GET_USER_PROFILE = "GET_USER_PROFILE";

src/actions/usersAction.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { GET_USER_PROFILE } from './types'
2+
import { errorHandler } from '../utils/errorHandler'
3+
import axios from 'axios'
4+
import { setRequestStatus } from '../utils/setRequestStatus'
5+
6+
export const getProfile = () => async (dispatch)=> {
7+
try {
8+
const res = await axios.get('/user/me')
9+
dispatch(setRequestStatus(false))
10+
if (res.status === 200) {
11+
setRequestStatus(true)
12+
console.log('user profile ', res.data)
13+
dispatch({
14+
type: GET_USER_PROFILE,
15+
payload: res.data.user
16+
})
17+
}
18+
} catch(error) {
19+
dispatch(errorHandler(error))
20+
}
21+
}

src/auth/signup-form/signup-form.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ class SignUpForm extends Component {
187187
<Form.Control
188188
value={firstName}
189189
type="text"
190-
placeholder=""
190+
placeholder = "First Name"
191191
name="firstName"
192192
onChange={this.onChange}
193193
required
@@ -200,7 +200,7 @@ class SignUpForm extends Component {
200200
<Form.Control
201201
value={lastName}
202202
type="text"
203-
placeholder=""
203+
placeholder="Last Name"
204204
name="lastName"
205205
onChange={this.onChange}
206206
required
@@ -215,7 +215,7 @@ class SignUpForm extends Component {
215215
<Form.Control
216216
value={email}
217217
type="email"
218-
placeholder=""
218+
placeholder="Email"
219219
name="email"
220220
onChange={this.onChange}
221221
required
@@ -232,7 +232,7 @@ class SignUpForm extends Component {
232232
<Form.Label>Phone Number</Form.Label>
233233
<Form.Control
234234
type="number"
235-
placeholder=""
235+
placeholder="Phone"
236236
name="phone"
237237
value={phone}
238238
onChange={this.onChange}
@@ -250,7 +250,7 @@ class SignUpForm extends Component {
250250
<Form.Label>Description</Form.Label>
251251
<Form.Control
252252
type="text"
253-
placeholder=""
253+
placeholder="Short bio"
254254
name="shortDescription"
255255
value={shortDescription}
256256
onChange={this.onChange}
@@ -270,7 +270,7 @@ class SignUpForm extends Component {
270270
<Form.Control
271271
value={password}
272272
type="password"
273-
placeholder=""
273+
placeholder="*******"
274274
name="password"
275275
onChange={this.onChange}
276276
required
@@ -289,7 +289,7 @@ class SignUpForm extends Component {
289289
<Form.Label>Confirm Password</Form.Label>
290290
<Form.Control
291291
type="password"
292-
placeholder=""
292+
placeholder="*******"
293293
name="cnfPassword"
294294
value={cnfPassword}
295295
onChange={this.onChange}
@@ -298,7 +298,7 @@ class SignUpForm extends Component {
298298
</Form.Group>
299299
<ul className="list-unstyled">
300300
<li id="validation_msg">
301-
{error?.msg.length > 0 ? error.msg : null}
301+
{/* {error?.msg.length > 0 ? error.msg : null} */}
302302
</li>
303303
</ul>
304304
</Col>

0 commit comments

Comments
 (0)