Skip to content

Commit f421b31

Browse files
Integration of notifications and minor improvements
1 parent f7eb4e2 commit f421b31

File tree

12 files changed

+676
-217
lines changed

12 files changed

+676
-217
lines changed

package-lock.json

Lines changed: 405 additions & 27 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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,15 @@
2424
"react-dom": "^16.12.0",
2525
"react-dropzone": "^11.0.1",
2626
"react-icons": "^3.9.0",
27+
"react-images": "^1.1.7",
2728
"react-lottie": "^1.2.3",
2829
"react-markdown-editor-lite": "^1.1.4",
2930
"react-redux": "^7.2.0",
3031
"react-responsive": "^8.0.3",
3132
"react-router-dom": "^5.1.2",
3233
"react-scripts": "^3.4.0",
33-
"react-toastify": "^6.0.5",
3434
"react-spinners": "^0.8.3",
35+
"react-toastify": "^6.0.5",
3536
"redux": "^4.0.5",
3637
"redux-thunk": "^2.3.0",
3738
"socket.io-client": "^2.3.0"

src/user/proposals/ProposalDiscussion/DiscussionContent/DiscussionComments/DiscussionComments.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class DiscussionComments extends Component {
1212
};
1313
}
1414

15-
handleComment = () => {
15+
handleComment = (text) => {
1616
fetch("http://localhost:5000/proposal/comment", {
1717
method: "POST",
1818
headers: {
@@ -23,9 +23,13 @@ class DiscussionComments extends Component {
2323
userId: this.props.userId,
2424
proposalId: this.props.proposalId,
2525
comment: this.state.commentContent,
26+
isAuthor: this.props.isAuthor,
27+
author: this.props.author,
2628
}),
2729
});
2830

31+
this.props.handleComment(this.state.commentContent);
32+
2933
this.setState({
3034
commentContent: "",
3135
});

src/user/proposals/ProposalDiscussion/DiscussionContent/DiscussionContent.js

Lines changed: 100 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,13 @@
11
import React, { Component } from "react";
22
import "./DiscussionContent.scss";
3-
import { Button, Container, Row, Col, Image, ListGroup } from "react-bootstrap";
3+
import { Button, Badge, Image, ListGroup } from "react-bootstrap";
44
import DiscussionComments from "./DiscussionComments/DiscussionComments";
55
import eventImg from "../../../../svgs/event-img-1.svg";
66
import userIcon2 from "../../../../images/userIcon2.jpg";
77
import RequestChanges from "../DiscussionPopups/RequestChanges";
8-
import { withRouter } from "react-router-dom";
9-
import { Remarkable } from "remarkable";
10-
import parse from "html-react-parser";
8+
import { withRouter, Link } from "react-router-dom";
119
import { Editor } from "@tinymce/tinymce-react";
12-
13-
const md = new Remarkable({
14-
html: true, // Enable HTML tags in source
15-
xhtmlOut: false, // Use '/' to close single tags (<br />)
16-
breaks: false, // Convert '\n' in paragraphs into <br>
17-
langPrefix: "language-", // CSS language prefix for fenced blocks
18-
19-
// Enable some language-neutral replacement + quotes beautification
20-
typographer: false,
21-
22-
// Double + single quotes replacement pairs, when typographer enabled,
23-
// and smartquotes on. Set doubles to '«»' for Russian, '„“' for German.
24-
quotes: "“”‘’",
25-
26-
// Highlighter function. Should return escaped HTML,
27-
// or '' if the source string is not changed
28-
highlight: function (/*str, lang*/) {
29-
return "";
30-
},
31-
});
10+
import Carousel, { Modal, ModalGateway } from "react-images";
3211

3312
class DiscussionContent extends Component {
3413
constructor(props) {
@@ -43,6 +22,11 @@ class DiscussionContent extends Component {
4322
markdownString: "",
4423
proposalDescription: "",
4524
commentList: [],
25+
author: "",
26+
images: [{ source: "../../../../images/userIcon2.jpg" }],
27+
imageModalOpen: false,
28+
proposalState: "",
29+
variant: "danger",
4630
};
4731
}
4832

@@ -77,13 +61,32 @@ class DiscussionContent extends Component {
7761
return res.json();
7862
})
7963
.then((resData) => {
80-
console.log(resData);
64+
const images = [];
65+
resData.proposal.attachments.forEach((item, index) => {
66+
images.push({ source: item.fileLink });
67+
});
68+
69+
let variant;
70+
71+
switch (resData.proposal.proposalStatus) {
72+
case "DRAFT":
73+
variant = "danger";
74+
break;
75+
case "SUBMITTED":
76+
variant = "secondary";
77+
break;
78+
}
79+
8180
this.setState(
8281
{
8382
proposalTitle: resData.proposal.title,
8483
markdownString: resData.proposal.content,
8584
proposalDescription: resData.proposal.proposalDescription,
8685
commentList: resData.proposal.comments,
86+
author: resData.proposal.creator,
87+
proposalState: resData.proposal.proposalStatus,
88+
variant: variant,
89+
images: images,
8790
},
8891
() => {
8992
this.processComments();
@@ -120,7 +123,12 @@ class DiscussionContent extends Component {
120123
});
121124
};
122125

126+
toggleModal = () => {
127+
this.setState((state) => ({ imageModalOpen: !state.imageModalOpen }));
128+
};
129+
123130
handleTextSelction = () => {
131+
console.log("text selection called");
124132
if (window.getSelection().toString().length > 0) {
125133
this.setState(
126134
{
@@ -166,28 +174,44 @@ class DiscussionContent extends Component {
166174
};
167175

168176
render() {
177+
const { imageModalOpen, images } = this.state;
169178
return (
170179
<div className="discussion-content">
171180
<div className="discussion-toppanel">
172181
<div className="discussion-title">
173-
<span className="title-text">{this.state.proposalTitle}</span>
182+
<span className="title-text">
183+
{this.state.proposalTitle}{" "}
184+
<h5>
185+
<Badge variant={this.state.variant}>
186+
{this.state.proposalState}
187+
</Badge>
188+
</h5>
189+
</span>
174190
</div>
191+
<div></div>
175192
<div className="discussion-desc"></div>
176193
<div className="discussion-buttons">
177-
<Button variant="primary" className="option-btn" size="sm" active>
178-
<span className="option-text">Edit</span>
179-
</Button>
194+
<Link
195+
to={{
196+
pathname: "/proposaleditor",
197+
state: {
198+
proposalId: this.state.proposalId,
199+
},
200+
}}
201+
>
202+
<Button variant="primary" className="option-btn" size="sm" active>
203+
<span className="option-text">Edit</span>
204+
</Button>
205+
</Link>
180206
</div>
181207
</div>
182208
<div className="discussion-bottompanel">
183209
<div className="proposal-preview">
184210
<div className="proposal-text" onMouseUp={this.handleTextSelction}>
185-
{/* <p>{parse(md.render(this.state.markdownString))}</p> */}
186211
<Editor
187212
value={this.state.markdownString}
188213
disabled={true}
189214
apiKey="lvp9xf6bvvm3nkaupm67ffzf50ve8femuaztgg7rkgkmsws3"
190-
initialValue="<p>This is the initial content of the editor</p>"
191215
init={{
192216
height: "100%",
193217
width: "100%",
@@ -204,10 +228,48 @@ class DiscussionContent extends Component {
204228
</div>
205229
<div className="attached-images">
206230
<div className="images-title">Attached Images</div>
207-
<Row>
208-
<Image src={eventImg} rounded className="image-item" />
209-
<Image src={eventImg} rounded className="image-item" />
210-
</Row>
231+
<div
232+
style={{
233+
overflow: "hidden",
234+
marginLeft: "2",
235+
marginRight: "2",
236+
}}
237+
>
238+
{images.map((item, index) => {
239+
return (
240+
<div
241+
style={{
242+
boxSizing: "border-box",
243+
float: "left",
244+
margin: "2px",
245+
marginRight: "10px",
246+
overflow: "hidden",
247+
paddingBottom: "16%",
248+
position: "relative",
249+
width: `calc(25% - ${2 * 2}px)`,
250+
251+
"&:hover": {
252+
opacity: 0.9,
253+
},
254+
}}
255+
>
256+
<img
257+
onClick={this.toggleModal}
258+
src={item.source}
259+
style={{ maxWidth: "100%", position: "absolute" }}
260+
/>
261+
</div>
262+
);
263+
})}
264+
</div>
265+
266+
<ModalGateway>
267+
{imageModalOpen ? (
268+
<Modal onClose={this.toggleModal}>
269+
<Carousel views={this.state.images} />
270+
</Modal>
271+
) : null}
272+
</ModalGateway>
211273
</div>
212274
</div>
213275
<div className="comments">
@@ -217,6 +279,9 @@ class DiscussionContent extends Component {
217279
userId={this.state.userId}
218280
token={this.state.token}
219281
getData={this.getData}
282+
isAuthor={this.state.author === this.state.userId}
283+
author={this.state.author}
284+
handleComment={this.handleComment}
220285
/>
221286
</div>
222287
<RequestChanges

src/user/proposals/ProposalEditor/EditorContent/EditorContent.js

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { Component } from "react";
2-
import { Button, Form } from "react-bootstrap";
2+
import { Button, Form, Badge } from "react-bootstrap";
33
import "./EditorContent.scss";
44
import MdEditor from "react-markdown-editor-lite";
55
import MarkdownIt from "markdown-it";
@@ -135,7 +135,7 @@ class EditorContent extends Component {
135135
Authorization: this.state.token,
136136
},
137137
body: JSON.stringify({
138-
title: this.state.title,
138+
title: this.state.proposalTitle,
139139
content: this.state.currentText,
140140
proposalStatus: "DRAFT",
141141
creator: this.state.userId,
@@ -233,8 +233,6 @@ class EditorContent extends Component {
233233
clearInterval(this.state.idVar);
234234
}
235235
handleTinyEditorChange = (content, editor) => {
236-
console.log("Content was updated:", content);
237-
238236
this.setState({
239237
draftEnabled: true,
240238
currentText: content,
@@ -327,7 +325,7 @@ class EditorContent extends Component {
327325
initialValue="<p>This is the initial content of the editor</p>"
328326
init={{
329327
height: "100%",
330-
width: "50%",
328+
width: "100%",
331329
menubar: false,
332330
plugins: [
333331
"advlist autolink lists link image charmap print preview anchor",
@@ -382,23 +380,6 @@ class EditorContent extends Component {
382380
}}
383381
onEditorChange={this.handleTinyEditorChange}
384382
/>
385-
<Editor
386-
disabled={true}
387-
apiKey="lvp9xf6bvvm3nkaupm67ffzf50ve8femuaztgg7rkgkmsws3"
388-
initialValue="<p>This is the initial content of the editor</p>"
389-
init={{
390-
height: "100%",
391-
width: "50%",
392-
menubar: false,
393-
plugins: [
394-
"advlist autolink lists link image charmap print preview anchor",
395-
"searchreplace visualblocks code fullscreen",
396-
"insertdatetime media table paste code help wordcount",
397-
],
398-
toolbar: false,
399-
}}
400-
onEditorChange={this.handleTinyEditorChange}
401-
/>
402383
</div>
403384
{this.state.startSave ? (
404385
<div className="save-container">

src/user/proposals/UserProposalDashboard/DashboardRightPanel/DashboardRightPanel.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { Component } from "react";
22
import "./DashboardRightPanel.scss";
33
import Comments from "./Comments/Comments";
4-
import OtherIdeas from "./OtherIdeas/OtherIdeas";
4+
import Notifications from "./Notifications/Notifications";
55

66
class DashboardRightPanel extends Component {
77
constructor(props) {
@@ -11,11 +11,8 @@ class DashboardRightPanel extends Component {
1111
render() {
1212
return (
1313
<div className="panel">
14-
<div className="panel-comments">
15-
<Comments />
16-
</div>
1714
<div className="panel-ideas">
18-
<OtherIdeas />
15+
<Notifications />
1916
</div>
2017
</div>
2118
);
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
.panel {
22
display: flex;
3-
flex-direction: column;
43

5-
.panel-comments {
6-
flex-grow: 1;
7-
}
84
.panel-ideas {
95
margin-top: 10px;
10-
flex-grow: 1;
6+
height: 100%;
117
}
128
}

0 commit comments

Comments
 (0)