Skip to content

Commit 446a765

Browse files
authored
Merge branch 'development' into reactions
2 parents eac6a39 + 9bc2ca6 commit 446a765

File tree

20 files changed

+1759
-130
lines changed

20 files changed

+1759
-130
lines changed

package-lock.json

Lines changed: 475 additions & 0 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 & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"react-responsive": "^8.0.3",
4343
"react-router-dom": "^5.1.2",
4444
"react-scripts": "^3.4.0",
45+
"react-shapes": "^0.1.0",
4546
"react-spinners": "^0.8.3",
4647
"react-switch": "^5.0.1",
4748
"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/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";

src/reducers/commentReducer.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
1-
import { GET_COMMENTS_OF_A_POST } from '../actions/types'
1+
import { GET_COMMENTS_OF_A_POST, RESET_COMMENTS } from "../actions/types";
22

33
const initialState = {
4-
allComments: []
5-
}
4+
allComments: [],
5+
};
66

77
export default (state = initialState, action) => {
8-
switch(action.type) {
8+
switch (action.type) {
99
case GET_COMMENTS_OF_A_POST: {
1010
return {
1111
...state,
12-
allComments: action.payload
13-
}
12+
allComments: action.payload,
13+
};
14+
}
15+
case RESET_COMMENTS: {
16+
return {
17+
allComments: [],
18+
};
1419
}
1520
default: {
16-
return state
21+
return state;
1722
}
1823
}
19-
}
24+
};

src/user/dashboard/news-feed/news-feed.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
IconButton,
1414
CardMedia,
1515
} from "@material-ui/core";
16+
1617
import { makeStyles } from "@material-ui/core/styles";
1718
import { Button, Dropdown, FormControl } from "react-bootstrap";
1819
import AddEventModal from "./popups/AddEventModal";
@@ -289,9 +290,10 @@ function NewsFeed(props) {
289290
<div className="post-details2">{parse(post?.content)}</div>
290291
<ListItem>
291292
{/* <IconButton
293+
<IconButton
292294
className={classes.vote}
293295
onClick={() => onUpvote(post._id)}
294-
>
296+
>
295297
<ArrowDropUpIcon className="up-vote" />
296298
</IconButton>
297299
<span className="up-vote">{post?.votes?.upVotes?.user.length}</span>
@@ -310,6 +312,7 @@ function NewsFeed(props) {
310312
>
311313
{post?.votes?.upVotes?.user.length}
312314
</span> */}
315+
313316
<span className="com-btn">
314317
<ChatBubbleIcon className={classes.chat} />
315318
<Button

src/user/profile/ReadMe.js

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
import React, { Component } from "react";
2+
import { Card, Button } from "react-bootstrap";
3+
import "./ReadMe.scss";
4+
import { updateProfile, getProfile } from "../../actions/usersAction";
5+
import { connect } from "react-redux";
6+
import ReadMeEditor from './ReadMeEditor'
7+
import ReadMePreview from './ReadMePreview'
8+
9+
class ReadMe extends Component {
10+
constructor(props) {
11+
super(props);
12+
const userProfile = this.props.userProfile;
13+
const about = userProfile.info?.about;
14+
let longDescription = true;
15+
if (!about.hasOwnProperty("longDescription")) {
16+
longDescription = false;
17+
}
18+
19+
this.state = {
20+
longDescription: true,
21+
displayEditor: false,
22+
currentText: "",
23+
firstName: userProfile.name?.firstName,
24+
lastName: userProfile.name?.lastName,
25+
website: about?.website,
26+
designation: about?.designation,
27+
longDesc: about?.longDescription,
28+
shortDesc: about?.shortDescription,
29+
location: about?.location,
30+
longDescription: longDescription,
31+
};
32+
}
33+
34+
handleCreateReadMe = () => {
35+
this.setState({
36+
displayEditor: true,
37+
});
38+
};
39+
40+
handleEditorChange = (content, editor) => {
41+
this.setState({
42+
currentText: content,
43+
});
44+
};
45+
46+
handleSave = () => {
47+
const {
48+
firstName,
49+
lastName,
50+
designation,
51+
location,
52+
website,
53+
shortDesc,
54+
currentText,
55+
} = this.state;
56+
const info = {
57+
name: {
58+
firstName,
59+
lastName,
60+
},
61+
info: {
62+
about: {
63+
shortDescription: shortDesc,
64+
longDescription: currentText,
65+
designation,
66+
location,
67+
website,
68+
},
69+
},
70+
};
71+
72+
this.props.updateProfile(info);
73+
this.setState(
74+
{
75+
displayEditor: false,
76+
},
77+
() => {
78+
this.setState({ longDescription: true });
79+
}
80+
);
81+
};
82+
83+
handleEdit = () => {
84+
this.setState(
85+
{
86+
longDescription: false,
87+
},
88+
() => {
89+
this.setState({
90+
displayEditor: true,
91+
});
92+
}
93+
);
94+
};
95+
96+
render() {
97+
const { displayEditor, longDescription } = this.state;
98+
99+
return (
100+
<div>
101+
{longDescription ? (
102+
<div className="editorContainer">
103+
<Card className="readmeCard" style={{ backgroundColor: "#E8F1FD" }}>
104+
<Card.Body>
105+
ReadMe available.
106+
<Button
107+
variant="primary"
108+
className="readmeCard__button"
109+
onClick={this.handleEdit}
110+
>
111+
Edit
112+
</Button>
113+
</Card.Body>
114+
</Card>
115+
<ReadMePreview longDesc={this.state.longDesc} />
116+
</div>
117+
) : displayEditor ? (
118+
<div className="editorContainer">
119+
<Card className="readmeCard" style={{ backgroundColor: "#E8F1FD" }}>
120+
<Card.Body>
121+
Editing ReadMe.
122+
<Button
123+
variant="primary"
124+
className="readmeCard__button"
125+
onClick={this.handleSave}
126+
>
127+
Save
128+
</Button>
129+
</Card.Body>
130+
</Card>
131+
<ReadMeEditor longDesc={this.state.longDesc} onEditorChange={this.handleEditorChange}/>
132+
</div>
133+
) : (
134+
<Card className="readmeCard" style={{ backgroundColor: "#E8F1FD" }}>
135+
<Card.Body>
136+
There doesn't appear to be a read me for this profile.
137+
<Button
138+
variant="primary"
139+
className="readmeCard__button"
140+
onClick={this.handleCreateReadMe}
141+
>
142+
Create ReadMe
143+
</Button>
144+
</Card.Body>
145+
</Card>
146+
)}
147+
</div>
148+
);
149+
}
150+
}
151+
152+
const mapStateToProps = (state) => ({
153+
user: state.user,
154+
});
155+
156+
export default connect(mapStateToProps, { updateProfile, getProfile })(ReadMe);

src/user/profile/ReadMe.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.readmeCard{
2+
.readmeCard__button{
3+
float: right;
4+
font-size: 14px;
5+
}
6+
7+
}
8+
.editorContainer{
9+
height: 48vh;
10+
}

0 commit comments

Comments
 (0)