Skip to content

Commit 9e4df8f

Browse files
committed
Merge branch 'development' of https://github.com/codeuino/social-platform-donut-frontend into pagination
2 parents b73a906 + 22f0316 commit 9e4df8f

Some content is hidden

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

44 files changed

+2988
-487
lines changed

package-lock.json

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

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"chart.js": "^2.9.3",
1818
"dotenv": "^8.2.0",
1919
"env-cmd": "^10.1.0",
20+
"framer-motion": "^2.3.0",
2021
"html-react-parser": "^0.13.0",
2122
"http-proxy-middleware": "^1.0.5",
2223
"jwt-decode": "^2.2.0",
@@ -41,6 +42,7 @@
4142
"react-responsive": "^8.0.3",
4243
"react-router-dom": "^5.1.2",
4344
"react-scripts": "^3.4.0",
45+
"react-shapes": "^0.1.0",
4446
"react-spinners": "^0.8.3",
4547
"react-switch": "^5.0.1",
4648
"react-toastify": "^6.0.5",

src/actions/commentAction.js

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { GET_COMMENTS_OF_A_POST } from './types'
2-
import { errorHandler } from '../utils/errorHandler'
3-
import axios from 'axios'
4-
import { setRequestStatus } from '../utils/setRequestStatus'
1+
import { GET_COMMENTS_OF_A_POST, RESET_COMMENTS } from "./types";
2+
import { errorHandler } from "../utils/errorHandler";
3+
import axios from "axios";
4+
import { setRequestStatus } from "../utils/setRequestStatus";
55
import { BASE_URL } from './baseApi'
66

7-
// CREATE COMMENT ON A PARTICULAR POST
7+
// CREATE COMMENT ON A PARTICULAR POST
88
export const createComment = (postId, comment) => async (dispatch) => {
99
try {
1010
const res = await axios.post(`${BASE_URL}/comment/${postId}`, comment)
@@ -14,10 +14,10 @@ export const createComment = (postId, comment) => async (dispatch) => {
1414
console.log('created comment ', res.data.comment)
1515
dispatch(getAllCommentsOfPost(postId));
1616
}
17-
} catch(error) {
18-
dispatch(errorHandler(error))
17+
} catch (error) {
18+
dispatch(errorHandler(error));
1919
}
20-
}
20+
};
2121

2222
// GET ALL COMMENTS OF A POST
2323
export const getAllCommentsOfPost = (postId) => async (dispatch) => {
@@ -26,19 +26,21 @@ export const getAllCommentsOfPost = (postId) => async (dispatch) => {
2626
dispatch(setRequestStatus(false))
2727
if(res.status === 200) {
2828
dispatch(setRequestStatus(true));
29-
console.log('fetching comments of ', postId, res.data.comments);
29+
console.log("fetching comments of ", postId, res.data.comments);
3030
dispatch({
3131
type: GET_COMMENTS_OF_A_POST,
32-
payload: res.data.comments
33-
})
32+
payload: res.data.comments,
33+
});
3434
}
35-
} catch(error) {
36-
dispatch(errorHandler(error))
35+
} catch (error) {
36+
dispatch(errorHandler(error));
3737
}
38-
}
38+
};
3939

4040
// UPDATE COMMENT OF A POST
41-
export const updateComment = (commentId, updatedComment) => async (dispatch) => {
41+
export const updateComment = (commentId, updatedComment) => async (
42+
dispatch
43+
) => {
4244
try {
4345
const res = await axios.patch(`${BASE_URL}/comment/${commentId}`, updatedComment)
4446
dispatch(setRequestStatus(false))
@@ -47,10 +49,10 @@ export const updateComment = (commentId, updatedComment) => async (dispatch) =>
4749
console.log('comment updated ', res.data.comment)
4850
dispatch(getAllCommentsOfPost())
4951
}
50-
} catch(error) {
51-
errorHandler(error)
52+
} catch (error) {
53+
errorHandler(error);
5254
}
53-
}
55+
};
5456

5557
// DELETE COMMENT
5658
export const deleteComment = (commentId) => async (dispatch) => {
@@ -59,10 +61,14 @@ export const deleteComment = (commentId) => async (dispatch) => {
5961
dispatch(setRequestStatus(false))
6062
if(res.status === 200) {
6163
dispatch(setRequestStatus(true));
62-
console.log('comment deleted ', res.data)
63-
dispatch(getAllCommentsOfPost())
64+
console.log("comment deleted ", res.data);
65+
dispatch(getAllCommentsOfPost());
6466
}
65-
} catch(error) {
66-
dispatch(errorHandler(error))
67+
} catch (error) {
68+
dispatch(errorHandler(error));
6769
}
68-
}
70+
};
71+
72+
export const resetComments = () => async (dispatch) => {
73+
dispatch({ type: RESET_COMMENTS });
74+
};

src/actions/postAction.js

Lines changed: 69 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,113 @@
1-
import axios from 'axios';
2-
import { errorHandler } from '../utils/errorHandler';
3-
import { setRequestStatus } from '../utils/setRequestStatus';
4-
import { GET_ALL_POSTS, GET_ALL_PINNED_POSTS, GET_SINGLE_POST } from './types';
5-
import { BASE_URL } from './baseApi'
1+
import axios from "axios";
2+
import { errorHandler } from "../utils/errorHandler";
3+
import { setRequestStatus } from "../utils/setRequestStatus";
4+
import { GET_ALL_POSTS, GET_ALL_PINNED_POSTS, GET_SINGLE_POST } from "./types";
5+
import { BASE_URL } from "./baseApi";
66

77
// GET ALL POSTS
88
export const getAllPosts = (pagination = 10, page = 1) => async (dispatch) => {
99
try {
10-
const res = await axios.get(`${BASE_URL}/post/all_posts?pagination=${pagination}&page=${page}`)
11-
dispatch(setRequestStatus(false))
12-
if(res.status === 200) {
13-
dispatch(setRequestStatus(true))
14-
console.log('all posts ', res.data.posts)
10+
const res = await axios.get(
11+
`${BASE_URL}/post/all_posts?pagination=${pagination}&page=${page}`
12+
);
13+
dispatch(setRequestStatus(false));
14+
if (res.status === 200) {
15+
dispatch(setRequestStatus(true));
16+
console.log("all posts ", res.data.posts);
1517
dispatch({
1618
type: GET_ALL_POSTS,
17-
payload: res.data.posts
18-
})
19+
payload: res.data.posts,
20+
});
1921
}
20-
} catch(error) {
21-
dispatch(errorHandler(error))
22+
} catch (error) {
23+
dispatch(errorHandler(error));
2224
}
23-
}
25+
};
2426

25-
// GET ALL PINNED POSTS
26-
export const getAllPinnedPosts = (pagination = 10, page = 1) => async (dispatch) => {
27+
// GET ALL PINNED POSTS
28+
export const getAllPinnedPosts = (pagination = 10, page = 1) => async (
29+
dispatch
30+
) => {
2731
try {
28-
const res = await axios.get(`${BASE_URL}/post/all/pinned?pagination=${pagination}&page=${page}`)
29-
dispatch(setRequestStatus(false))
30-
if(res.status === 200){
31-
dispatch(setRequestStatus(true))
32-
console.log('fetching all pinned posts ', res.data.pinnedPost)
32+
const res = await axios.get(
33+
`${BASE_URL}/post/all/pinned?pagination=${pagination}&page=${page}`
34+
);
35+
dispatch(setRequestStatus(false));
36+
if (res.status === 200) {
37+
dispatch(setRequestStatus(true));
38+
console.log("fetching all pinned posts ", res.data.pinnedPost);
3339
dispatch({
3440
type: GET_ALL_PINNED_POSTS,
35-
payload: res.data.pinnedPost
36-
})
41+
payload: res.data.pinnedPost,
42+
});
3743
}
38-
} catch(error) {
39-
dispatch(errorHandler(error))
44+
} catch (error) {
45+
dispatch(errorHandler(error));
4046
}
41-
}
47+
};
4248

4349
// UPVOTE POST
44-
export const upVotePost = (postId) => async (dispatch) => {
50+
export const upVotePost = (postId, type) => async (dispatch) => {
4551
try {
46-
const res = await axios.patch(`${BASE_URL}/post/upvote/${postId}`)
47-
if(res.status === 200) {
48-
console.log('successfully upvoted post ', res.data)
52+
const res = await axios.patch(`${BASE_URL}/post/upvote/${postId}`, type);
53+
if (res.status === 200) {
54+
console.log("successfully upvoted post ", res.data);
4955
dispatch(getAllPosts());
5056
}
5157
} catch (error) {
52-
dispatch(errorHandler(error))
58+
dispatch(errorHandler(error));
5359
}
54-
}
60+
};
5561

56-
// GET POST BY ID
62+
// GET POST BY ID
5763
export const getPostById = (postId) => async (dispatch) => {
5864
try {
59-
console.log('postId from action ', postId)
65+
console.log("postId from action ", postId);
6066
const res = await axios.get(`${BASE_URL}/post/${postId}`);
6167
if (res.status === 200) {
6268
dispatch({
6369
type: GET_SINGLE_POST,
64-
payload: res.data.post
65-
})
70+
payload: res.data.post,
71+
});
6672
}
6773
} catch (error) {
68-
dispatch(errorHandler(error))
74+
dispatch(errorHandler(error));
6975
}
70-
}
76+
};
7177

72-
// UPDATE POST
78+
// UPDATE POST
7379
export const updatePost = (postId, updatedInfo) => async (dispatch) => {
7480
try {
75-
console.log('updatedPostInfo ', updatedInfo)
76-
const res = await axios.patch(`${BASE_URL}/post/${postId}`, updatedInfo)
81+
console.log("updatedPostInfo ", updatedInfo);
82+
const res = await axios.patch(`${BASE_URL}/post/${postId}`, updatedInfo);
7783
if (res.status === 200) {
78-
dispatch(getPostById(postId))
84+
dispatch(getPostById(postId));
7985
}
8086
} catch (error) {
81-
dispatch(errorHandler(error))
87+
dispatch(errorHandler(error));
8288
}
83-
}
89+
};
8490

85-
// DELETE POST
91+
// DELETE POST
8692
export const deletePost = (postId) => async (dispatch) => {
8793
try {
88-
const res = await axios.delete(`${BASE_URL}/post/${postId}`)
89-
if(res.status === 200) {
90-
dispatch(getAllPosts())
94+
const res = await axios.delete(`${BASE_URL}/post/${postId}`);
95+
if (res.status === 200) {
96+
dispatch(getAllPosts());
97+
}
98+
} catch (error) {
99+
dispatch(errorHandler(error));
100+
}
101+
};
102+
103+
// REMOVE REACTION
104+
export const removeReaction = (postId, type) => async (dispatch) => {
105+
try {
106+
const res = await axios.patch(`${BASE_URL}/post/removereaction/${postId}`, type);
107+
if (res.status === 200) {
108+
dispatch(getAllPosts());
91109
}
92110
} catch (error) {
93-
dispatch(errorHandler(error))
111+
dispatch(errorHandler(error));
94112
}
95-
}
113+
};

src/actions/types.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ export const GET_ALL_PINNED_POSTS = "GET_ALL_PINNED_POSTS";
3838
export const GET_EVENT_BY_ID = "GET_EVENT_BY_ID";
3939
export const GET_ADMIN = "GET_ADMIN";
4040
export const GET_COMMENTS_OF_A_POST = "GET_COMMENTS_OF_A_POST";
41+
export const RESET_COMMENTS = "RESET_COMMENTS";
4142
export const GET_SINGLE_PROJECT = "GET_SINGLE_PROJECT";
42-
export const PASSWORD_CHANGE_REQUEST_SUCCESS = "PASSWORD_CHANGE_REQUEST_SUCCESS";
43+
export const PASSWORD_CHANGE_REQUEST_SUCCESS =
44+
"PASSWORD_CHANGE_REQUEST_SUCCESS";
4345
export const PASSWORD_SUCCESSFULLY_CHANGED = "PASSWORD_SUCCESSFULLY_CHANGED";
4446
export const GET_INVITE_LINK = "GET_INVITE_LINK";
4547
export const PROCESS_INVITE_LINK = "PROCESS_INVITE_LINK";
18 KB
Loading

src/assets/integrations/Drive.png

46.4 KB
Loading

src/assets/integrations/Github.png

6.76 KB
Loading

src/assets/integrations/Jitsi.png

91.7 KB
Loading
5.43 KB
Loading

0 commit comments

Comments
 (0)