Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
631 changes: 631 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,28 @@
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.4.0",
"@testing-library/user-event": "^7.2.1",
"@tinymce/tinymce-react": "^3.6.0",
"axios": "^0.19.1",
"boostrap": "^2.0.0",
"html-react-parser": "^0.13.0",
"jwt-decode": "^2.2.0",
"markdown-it": "^11.0.0",
"node-sass": "^4.13.0",
"react": "^16.12.0",
"react-bootstrap": "^1.0.0-beta.16",
"react-content-loader": "^5.0.4",
"react-cookies": "^0.1.1",
"react-dom": "^16.12.0",
"react-dropzone": "^11.0.1",
"react-icons": "^3.9.0",
"react-images": "^1.1.7",
"react-lottie": "^1.2.3",
"react-markdown-editor-lite": "^1.1.4",
"react-redux": "^7.2.0",
"react-responsive": "^8.0.3",
"react-router-dom": "^5.1.2",
"react-scripts": "^3.4.0",
"react-spinners": "^0.8.3",
"react-toastify": "^6.0.5",
"redux": "^4.0.5",
"redux-thunk": "^2.3.0",
Expand Down
62 changes: 42 additions & 20 deletions src/actions/notificationAction.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,63 @@
import { GET_PLATFORM_NOTIFICATIONS, GET_USER_NOTIFICATIONS } from './types'
import axios from 'axios'
import { errorHandler } from '../utils/errorHandler';
import { setRequestStatus } from '../utils/setRequestStatus';
import {
GET_PLATFORM_NOTIFICATIONS,
GET_USER_NOTIFICATIONS,
GET_PROPOSAL_NOTIFICATIONS,
} from "./types";
import axios from "axios";
import { errorHandler } from "../utils/errorHandler";
import { setRequestStatus } from "../utils/setRequestStatus";

// GET NOTIFICATIONS FOR WHOLE PLATFORM AS WELL AS FOR A USER
export const getAllNotifications = () => async (dispatch) => {
try {
const res = await axios.get('/notification/org/all')
dispatch(setRequestStatus(false))
const res = await axios.get("/notification/org/all");
dispatch(setRequestStatus(false));
if (res.status === 200) {
dispatch(setRequestStatus(true))
console.log('Whole platform notification ', res.data.notifications)
dispatch(setRequestStatus(true));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these formatting changes or code changes by linter did you make these?

Copy link
Member

@Rupeshiya Rupeshiya Jul 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vaibhavdaren These are either due to the extensions he is using or due to his vs code settings.
I have already mentioned that

console.log("Whole platform notification ", res.data.notifications);

dispatch({
type: GET_PLATFORM_NOTIFICATIONS,
payload: res.data.notifications
})
payload: res.data.notifications,
});
}
} catch (error) {
dispatch(errorHandler(error))
dispatch(errorHandler(error));
}
}
};

// GET NOTIFICATIONS FOR A USER
export const getUserNotification = () => async (dispatch) => {
try {
const res = await axios.get('/notification/user/all')
dispatch(setRequestStatus(false))
const res = await axios.get("/notification/user/all");
dispatch(setRequestStatus(false));
if (res.status === 200) {
dispatch(setRequestStatus(true))
console.log('User notification ', res.data.notifications)
dispatch(setRequestStatus(true));
console.log("User notification ", res.data.notifications);
dispatch({
type: GET_USER_NOTIFICATIONS,
payload: res.data.notifications
})
payload: res.data.notifications,
});
}
} catch (error) {
dispatch(errorHandler(error))
dispatch(errorHandler(error));
}
}
};

// GET PROPOSAL NOTIFICATIONS
export const getProposalNotifications = () => async (dispatch) => {
try {
const res = await axios.get("/notification/proposal/all");
dispatch(setRequestStatus(false));
if (res.status === 200) {
dispatch(setRequestStatus(true));
console.log("Proposal notification ", res.data.notifications);
dispatch({
type: GET_PROPOSAL_NOTIFICATIONS,
payload: res.data.notifications,
});
}
} catch (error) {
dispatch(errorHandler(error));
}
};
159 changes: 159 additions & 0 deletions src/actions/proposalActions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
import axios from "axios";
import { errorHandler } from "../utils/errorHandler";
import { setRequestStatus } from "../utils/setRequestStatus";
import {
CREATE_PROPOSAL,
GET_PROPOSAL,
GET_USER_PROPOSAL_NOTIFICATIONS,
GET_ALL_PROPOSALS,
GET_USER_PROPOSALS,
} from "../actions/types";

// CREATE PROPOSAL
export const createProposal = (proposalInfo) => async (dispatch) => {
try {
const res = await axios.post("/proposal", proposalInfo);
dispatch(setRequestStatus(false));
if (res.status === 201) {
dispatch(setRequestStatus(true));
console.log("proposal created in ACTION", res.data);
dispatch({
type: CREATE_PROPOSAL,
payload: res.data.proposal || res.data.msg,
});
}
} catch (error) {
dispatch(errorHandler(error));
}
};

// GET PROPOSAL DATA
export const getProposal = (proposalId) => async (dispatch) => {
try {
const res = await axios.get("/proposal/" + proposalId);
dispatch(setRequestStatus(false));
if (res.status === 200) {
dispatch(setRequestStatus(true));
console.log("proposal data fetched in action", res.data);
dispatch({
type: GET_PROPOSAL,
payload: res.data.proposal || res.data.msg,
});
}
} catch (error) {
dispatch(errorHandler(error));
}
};

// SAVE PROPOSAL DATA
export const saveProposal = (proposalData) => async (dispatch) => {
try {
const res = await axios.patch(
"/proposal/" + proposalData.proposalId,
proposalData
);
dispatch(setRequestStatus(false));
if (res.status === 200) {
dispatch(setRequestStatus(true));
}
} catch (error) {
dispatch(errorHandler(error));
}
};

// SUBMIT PROPOSAL
export const submitProposal = (proposalData) => async (dispatch) => {
console.log(proposalData);
try {
const res = await axios.patch(
"/proposal/change/" + proposalData.proposalId,
proposalData
);
dispatch(setRequestStatus(false));
if (res.status === 200) {
dispatch(setRequestStatus(true));
}
} catch (error) {
dispatch(errorHandler(error));
}
};

// DELETE PROPOSAL
export const deleteProposal = (proposalId) => async (dispatch) => {
try {
const res = await axios.delete("/proposal", {
headers: {},
data: { proposalId: proposalId },
});
dispatch(setRequestStatus(false));
if (res.status === 200) {
dispatch(setRequestStatus(true));
}
} catch (error) {
dispatch(errorHandler(error));
}
};

// COMMENT ON PROPOSAL
export const commentProposal = (commentData) => async (dispatch) => {
try {
const res = await axios.post("/proposal/comment", commentData);
dispatch(setRequestStatus(false));
if (res.status === 200) {
dispatch(setRequestStatus(true));
}
} catch (error) {
dispatch(errorHandler(error));
}
};

// GET USER RELATED PROPOSAL NOTIFICATIONS
export const getUserProposalNotifications = (data) => async (dispatch) => {
try {
const res = await axios.post("/proposal/notifications", data);
console.log(res);
if (res.status === 200) {
dispatch(setRequestStatus(true));
dispatch({
type: GET_USER_PROPOSAL_NOTIFICATIONS,
payload: res.data.proposal || res.data.msg,
});
}
} catch (error) {
dispatch(errorHandler(error));
}
};

// GET ALL PROPOSALS
export const getAllProposals = () => async (dispatch) => {
try {
const res = await axios.post("/proposal/all");
dispatch(setRequestStatus(false));
if (res.status === 200) {
dispatch(setRequestStatus(true));
dispatch({
type: GET_ALL_PROPOSALS,
payload: res.data.proposals || res.data.msg,
});
}
} catch (error) {
dispatch(errorHandler(error));
}
};

// GET PROPOSALS BY USER ID
export const getProposalsByUser = (userId) => async (dispatch) => {
try {
const res = await axios.get(`/proposal/user/${userId}`);
dispatch(setRequestStatus(false));
if (res.status === 200) {
dispatch(setRequestStatus(true));
dispatch({
type: GET_USER_PROPOSALS,
payload: res.data.proposal || res.data.msg,
});
}
} catch (error) {
dispatch(errorHandler(error));
}
};
20 changes: 14 additions & 6 deletions src/actions/types.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
export const GET_CURRENT_USER = "GET_CURRENT_USER";
export const SET_CURRENT_USER = "SET_CURRENT_USER";
export const RESPONSE_MSG = "RESPONSE_MSG";
export const GET_CURRENT_USER = "GET_CURRENT_USER";
export const SET_CURRENT_USER = "SET_CURRENT_USER";
export const RESPONSE_MSG = "RESPONSE_MSG";
export const GET_ERRORS = "GET_ERRORS";
export const SET_ERROR = "SET_ERROR";
export const SET_STATUS = "SET_STATUS";
export const GET_PLATFORM_NOTIFICATIONS = "GET_PLATFORM_NOTIFICATIONS";
export const GET_USER_NOTIFICATIONS = "GET_USER_NOTIFICATIONS";
export const GET_ALL_NOTIFICATIONS = "GET_ALL_NOTIFICATIONS";
export const GET_PROPOSAL_NOTIFICATIONS = "GET_PROPOSAL_NOTIFICATIONS";
export const GET_USER_PROPOSAL_NOTIFICATIONS =
"GET_USER_PROPOSAL_NOTIFICATIONS";
export const SET_ADMIN = "SET_ADMIN";
export const GET_ALL_UPCOMING_EVENTS = "GET_ALL_UPCOMING_EVENTS";
export const GET_ALL_MEMBERS = "GET_ALL_MEMBERS";
Expand All @@ -27,12 +29,18 @@ export const GET_ALL_EVENTS = "GET_ALL_EVENTS";
export const GET_ALL_PROJECTS = "GET_ALL_PROJECTS";
export const GET_ALL_POSTS = "GET_ALL_POSTS";
export const GET_USER_POSTS = "GET_USER_POSTS";
export const CREATE_PROPOSAL = "CREATE_PROPOSAL";
export const GET_PROPOSAL = "GET_PROPOSAL";
export const GET_ALL_PROPOSALS = "GET_ALL_PROPOSALS";
export const EXIT = "EXIT";
export const GET_USER_PROPOSALS = "GET USER PROPOSALS";
export const GET_ALL_PINNED_POSTS = "GET_ALL_PINNED_POSTS";
export const GET_EVENT_BY_ID = "GET_EVENT_BY_ID";
export const GET_ADMIN = "GET_ADMIN";
export const GET_COMMENTS_OF_A_POST = "GET_COMMENTS_OF_A_POST";
export const GET_SINGLE_PROJECT = "GET_SINGLE_PROJECT";
export const PASSWORD_CHANGE_REQUEST_SUCCESS = "PASSWORD_CHANGE_REQUEST_SUCCESS";
export const PASSWORD_CHANGE_REQUEST_SUCCESS =
"PASSWORD_CHANGE_REQUEST_SUCCESS";
export const PASSWORD_SUCCESSFULLY_CHANGED = "PASSWORD_SUCCESSFULLY_CHANGED";
export const GET_INVITE_LINK = "GET_INVITE_LINK";
export const PROCESS_INVITE_LINK = "PROCESS_INVITE_LINK";
export const PROCESS_INVITE_LINK = "PROCESS_INVITE_LINK";
34 changes: 18 additions & 16 deletions src/reducers/index.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import { combineReducers } from 'redux';
import authReducers from './authReducer';
import postReducers from './postReducer';
import userReducers from './userReducer';
import errorReducer from './errorReducer';
import requestStatus from './requestStatus';
import notificationReducer from './notificationReducer'
import dashboardReducer from './dashboardReducer'
import insightReducer from './insightReducer';
import orgReducer from './orgReducer';
import eventReducer from './eventReducer';
import projectReducer from './projectReducer';
import adminReducers from './adminReducers';
import commentReducer from './commentReducer';
import { combineReducers } from "redux";
import authReducers from "./authReducer";
import postReducers from "./postReducer";
import userReducers from "./userReducer";
import errorReducer from "./errorReducer";
import requestStatus from "./requestStatus";
import notificationReducer from "./notificationReducer";
import dashboardReducer from "./dashboardReducer";
import insightReducer from "./insightReducer";
import orgReducer from "./orgReducer";
import eventReducer from "./eventReducer";
import projectReducer from "./projectReducer";
import proposalReducer from "./proposalReducer";
import adminReducers from "./adminReducers";
import commentReducer from "./commentReducer";

const rootReducer = combineReducers({
auth: authReducers,
Expand All @@ -24,9 +25,10 @@ const rootReducer = combineReducers({
org: orgReducer,
event: eventReducer,
project: projectReducer,
status: requestStatus,
proposal: proposalReducer,
admin: adminReducers,
comment: commentReducer,
status: requestStatus
});

export default rootReducer;
export default rootReducer;
Loading