Skip to content

Commit afe593e

Browse files
AuraOfDivinityRupeshiya
authored andcommitted
Fixing proposal functionality issues (#553)
1 parent 8b3ac65 commit afe593e

File tree

12 files changed

+82
-31
lines changed

12 files changed

+82
-31
lines changed

src/actions/eventAction.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export const createEvent = (eventInfo, history) => async (dispatch) => {
4747
}
4848

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

src/actions/notificationAction.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export const getProposalNotifications = () => async (dispatch) => {
5252
dispatch(setRequestStatus(false));
5353
if (res.status === 200) {
5454
dispatch(setRequestStatus(true));
55-
console.log("Proposal notification ", res.data.notifications);
55+
console.log("Proposal notification ", res.data?.notifications);
5656
dispatch({
5757
type: GET_PROPOSAL_NOTIFICATIONS,
5858
payload: res.data.notifications,

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/usersAction.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ export const getPostsCreatedByUser = (pagination = 10, page = 1) => async (dispa
170170
// GET INVITE LINK
171171
export const getInviteLink = (role) => async (dispatch) => {
172172
try {
173-
const res = await axios.get(`${BASE_URL}/user/invite?role=${role}`)
173+
const res = await axios.get(`${BASE_URL}/user/link/invite?role=${role}`)
174174
dispatch(setRequestStatus(false));
175175
if(res.status === 200) {
176176
dispatch(setRequestStatus(true));

src/user/events/events.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { connect } from 'react-redux'
1010
import { getAllEvents } from '../../actions/eventAction'
1111
import { checkDeleteRights } from '../dashboard/utils/checkDeleteRights'
1212
import { getOrgProfile } from '../../actions/orgAction'
13+
import { Pagination } from 'antd'
1314
import Moment from 'react-moment'
1415
import { canEditCheck } from '../projects/Utils/CanEdit'
1516

@@ -32,7 +33,7 @@ class Events extends Component {
3233

3334
componentDidMount() {
3435
setTimeout(() => {
35-
this.props.getAllEvents()
36+
this.props.getAllEvents() // by default 6 events per page
3637
this.props.getOrgProfile()
3738
})
3839
}
@@ -50,6 +51,16 @@ class Events extends Component {
5051
})
5152
}
5253

54+
onShowSizeChange = (currentPage, pageSize) => {
55+
console.log('currentPage pageSize ', currentPage, pageSize)
56+
this.props.getAllEvents(pageSize, currentPage)
57+
}
58+
59+
handlePagination = (pageNumber) => {
60+
console.log('page number ', pageNumber);
61+
this.props.getAllEvents(6, pageNumber)
62+
}
63+
5364

5465
render() {
5566
const { allEvents, editingLimit } = this.state
@@ -266,6 +277,15 @@ class Events extends Component {
266277
{Events}
267278
</Grid>
268279
</div>
280+
<div className="event__pagination__container">
281+
<Pagination
282+
showSizeChanger
283+
onShowSizeChange={this.onShowSizeChange}
284+
defaultCurrent={1}
285+
total={100}
286+
onChange={this.handlePagination}
287+
/>
288+
</div>
269289
</div>
270290
<Popups
271291
option={this.state.option}

src/user/events/events.scss

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
height: auto;
55
font-family: Muli, sans-serif;
66
.events {
7-
margin-top: 2vh;
7+
margin-top: 1vh;
88
.container {
99
.event_header {
1010
font-family: Inter;
@@ -22,6 +22,13 @@
2222
height: 42vh;
2323
}
2424
}
25+
.event__pagination__container {
26+
display: flex;
27+
flex-direction: row;
28+
justify-content: center;
29+
align-items: center;
30+
padding-top: 29px;
31+
}
2532
}
2633
}
2734

src/user/projects/projects.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { Button } from "react-bootstrap";
66
import { connect } from 'react-redux'
77
import { createProject, getAllProjects } from '../../actions/projectAction'
88
import projectImage from '../../images/project.png'
9+
import { Pagination } from 'antd'
910
import { withRouter } from "react-router-dom";
1011

1112
class Projects extends Component {
@@ -19,7 +20,7 @@ class Projects extends Component {
1920
}
2021
componentDidMount() {
2122
setTimeout(() => {
22-
this.props.getAllProjects();
23+
this.props.getAllProjects(); // by default 6 projects per page
2324
})
2425
}
2526

@@ -31,6 +32,16 @@ class Projects extends Component {
3132
})
3233
}
3334

35+
onShowSizeChange = (currentPage, pageSize) => {
36+
console.log('currentPage pageSize ', currentPage, pageSize)
37+
this.props.getAllProjects(pageSize, currentPage)
38+
}
39+
40+
handlePagination = (pageNumber) => {
41+
console.log('page number ', pageNumber);
42+
this.props.getAllProjects(6, pageNumber)
43+
}
44+
3445
render() {
3546
const { allProjects } = this.state
3647
const useStyles = makeStyles((theme) => ({
@@ -94,6 +105,15 @@ class Projects extends Component {
94105
{Projects}
95106
</Grid>
96107
</div>
108+
<div className="project__pagination__container">
109+
<Pagination
110+
showSizeChanger
111+
onShowSizeChange={this.onShowSizeChange}
112+
defaultCurrent={1}
113+
total={100}
114+
onChange={this.handlePagination}
115+
/>
116+
</div>
97117
</div>
98118
</div>
99119
);

src/user/projects/projects.scss

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
}
99

1010
.projects {
11-
margin-top: 5vh;
11+
margin-top: 1vh;
1212
margin-left: 4vw;
1313
margin-right: 6vw;
1414
p {
@@ -70,5 +70,13 @@
7070
-webkit-box-orient: vertical;
7171
}
7272

73+
.project__pagination__container {
74+
display: flex;
75+
padding-top: 20px;
76+
flex-direction: row;
77+
justify-content: center;
78+
align-items: center;
79+
}
80+
7381
}
7482
}

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

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,29 +36,23 @@ function StyledDropzone(props) {
3636
const [proposalId, setProposalId] = useState(props.idContent);
3737

3838
const onDrop = useCallback((acceptedFiles) => {
39-
if (proposalId === "new") {
40-
toast.error(
41-
"Please save the proposal as a draft before attaching images"
42-
);
43-
} else {
44-
let formData = new FormData();
45-
formData.append("file", acceptedFiles[0]);
46-
const URL = `http://localhost:5000/proposal/attach/${props.idContent}`;
39+
let formData = new FormData();
40+
formData.append("file", acceptedFiles[0]);
41+
const URL = `http://localhost:5000/proposal/attach/${props.idContent}`;
4742

48-
fetch(URL, {
49-
method: "POST",
50-
body: formData,
51-
headers: {
52-
Authorization: localStorage.getItem("jwtToken"),
53-
},
43+
fetch(URL, {
44+
method: "POST",
45+
body: formData,
46+
headers: {
47+
Authorization: localStorage.getItem("jwtToken"),
48+
},
49+
})
50+
.then((res) => {
51+
toast.success("Image successfully attached to proposal!");
5452
})
55-
.then((res) => {
56-
toast.success("Image successfully attached to proposal!");
57-
})
58-
.catch((err) => {
59-
console.log(err);
60-
});
61-
}
53+
.catch((err) => {
54+
console.log(err);
55+
});
6256
}, []);
6357

6458
const {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class EditorContent extends Component {
5050
proposalStatus: fetchedProposal.proposalStatus,
5151
});
5252
}
53-
if (Object.keys(createProposal).length !== 0) {
53+
if (Object.keys(createdProposal).length !== 0) {
5454
this.setState(
5555
{
5656
isSaving: false,

0 commit comments

Comments
 (0)