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
51 changes: 38 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"react-cookies": "^0.1.1",
"react-dom": "^16.12.0",
"react-dropzone": "^11.0.1",
"react-icons": "^3.9.0",
"react-icons": "^3.10.0",
"react-images": "^1.1.7",
"react-lottie": "^1.2.3",
"react-markdown-editor-lite": "^1.1.4",
Expand All @@ -32,6 +32,7 @@
"react-router-dom": "^5.1.2",
"react-scripts": "^3.4.0",
"react-spinners": "^0.8.3",
"react-switch": "^5.0.1",
"react-toastify": "^6.0.5",
"redux": "^4.0.5",
"redux-thunk": "^2.3.0",
Expand Down
3 changes: 3 additions & 0 deletions src/actions/adminAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ export const loginAdmin = (adminInfo, history) => async (dispatch) => {
localStorage.setItem('userId', decodedData._id)
dispatch(setCurrentUser(decodedData));

// update localStorage with admin status
localStorage.setItem('admin', true)

dispatch({
type: SET_ADMIN,
payload: true
Expand Down
23 changes: 17 additions & 6 deletions src/actions/authAction.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SET_CURRENT_USER, GET_USER_PROFILE, PASSWORD_SUCCESSFULLY_CHANGED, PASSWORD_CHANGE_REQUEST_SUCCESS } from './types';
import { SET_CURRENT_USER, GET_USER_PROFILE, PASSWORD_SUCCESSFULLY_CHANGED, PASSWORD_CHANGE_REQUEST_SUCCESS, SET_ADMIN } from './types';
import axios from 'axios';
import { setAuthToken } from '../utils/setAuthToken';
import jwt_decode from 'jwt-decode';
Expand Down Expand Up @@ -46,8 +46,19 @@ export const loginUser = (userInfo, history) => async (dispatch) => {
const decodedData = await jwt_decode(token);
localStorage.setItem('userId', decodedData._id)
dispatch(setCurrentUser(decodedData));
history.push("/dashboard");

// update user role in localStorage
localStorage.setItem('admin', res.data.user.isAdmin)

// store orgId in localStorage
localStorage.setItem('orgId', res.data.user.orgId);

// if user is admin update admin in store
dispatch({
type: SET_ADMIN,
payload: res.data.user.isAdmin
})
history.push("/dashboard");
}
} catch(error) {
dispatch(errorHandler(error));
Expand Down Expand Up @@ -104,10 +115,10 @@ export const logoutUser = () => async (dispatch) => {
// clear token from backend
const res = await axios.post('/user/logout')
if (res.status === 200) {
// remove token from the localStorage
localStorage.removeItem('jwtToken');
// remove userID
localStorage.removeItem('userId')
// remove all keys from the localStorage except the orgId
const orgId = localStorage.getItem('orgId');
localStorage.clear()
localStorage.setItem('orgId', orgId)
// delete authorization from the header
setAuthToken(false);
// set user to {}
Expand Down
15 changes: 15 additions & 0 deletions src/actions/eventAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,19 @@ export const getEventById = (eventId) => async (dispatch) => {
} catch(error) {
dispatch(errorHandler(error))
}
}

// RSVP FOR EVENT SECTION
export const rsvpYes = (eventId, info) => async (dispatch) => {
try {
const res = await axios.patch(`/event/rsvp/${eventId}`, info);
dispatch(setRequestStatus(false))
if(res.status === 200) {
dispatch(setRequestStatus(true));
console.log('Doing rsvp for the event', res.data);
dispatch(getAllEvents());
}
} catch (error) {
dispatch(errorHandler(error))
}
}
22 changes: 21 additions & 1 deletion src/actions/orgAction.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import axios from 'axios'
import { setRequestStatus } from '../utils/setRequestStatus'
import { errorHandler } from '../utils/errorHandler'
import { GET_ORG_PROFILE, UPDATE_ORG_PROFILE, DEACTIVATE_ORG, GET_ALL_MEMBERS } from './types'
import { GET_ORG_PROFILE, UPDATE_ORG_PROFILE, DEACTIVATE_ORG, GET_ALL_MEMBERS, TRIGGER_MAINTENANCE } from './types'

// CREATE COMMUNITY
export const registerCommunity = (orgInfo) => async (dispatch) => {
Expand Down Expand Up @@ -120,4 +120,24 @@ export const deactivateOrg = () => async (dispatch) => {
} catch(error) {
dispatch(errorHandler(error))
}
}

// TRIGGER MAINTENANCE MODE
export const TriggerMaintenance = () => async (dispatch) => {
try {
const orgId = localStorage.getItem('orgId')
const res = await axios.patch(`/org/${orgId}/maintenance`);
dispatch(setRequestStatus(false))
if(res.status === 200) {
dispatch(setRequestStatus(true))
// set maintenance to true in localStorage
localStorage.setItem('isMaintenance', res.data.maintenance);
dispatch({
type: TRIGGER_MAINTENANCE,
payload: res.data.maintenance
})
}
} catch (error) {
dispatch(errorHandler(error))
}
}
17 changes: 16 additions & 1 deletion src/actions/postAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,19 @@ export const getAllPinnedPosts = (pagination = 10, page = 1) => async (dispatch)
} catch(error) {
dispatch(errorHandler(error))
}
}
}

// UPVOTE POST
export const upVotePost = (postId) => async (dispatch) => {
try {
const res = await axios.patch(`/post/upvote/${postId}`)
dispatch(setRequestStatus(false));
if(res.status === 200) {
dispatch(setRequestStatus(true));
console.log('successfully upvoted post ', res.data)
dispatch(getAllPosts());
}
} catch (error) {
dispatch(errorHandler(error))
}
}
4 changes: 2 additions & 2 deletions src/actions/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ 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 TRIGGER_MAINTENANCE = "TRIGGER_MAINTENANCE";
15 changes: 11 additions & 4 deletions src/actions/usersAction.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GET_USER_PROFILE, GET_ALL_MEMBERS, UPDATE_USER_PROFILE, GET_USER_EVENTS, GET_USER_PROJECTS, GET_USER_POSTS, GET_INVITE_LINK, PROCESS_INVITE_LINK } from './types'
import { GET_USER_PROFILE, GET_ALL_MEMBERS, UPDATE_USER_PROFILE, GET_USER_EVENTS, GET_USER_PROJECTS, GET_USER_POSTS, GET_INVITE_LINK, PROCESS_INVITE_LINK, SET_ADMIN } from './types'
import { errorHandler } from '../utils/errorHandler'
import axios from 'axios'
import { setRequestStatus } from '../utils/setRequestStatus'
Expand All @@ -15,6 +15,13 @@ export const getProfile = () => async (dispatch)=> {
type: GET_USER_PROFILE,
payload: res.data.user
})
// if user is admin
if(res.data.user.isAdmin === true) {
dispatch({
type: SET_ADMIN,
payload: true
})
}
}
} catch(error) {
dispatch(errorHandler(error))
Expand Down Expand Up @@ -160,9 +167,9 @@ export const getPostsCreatedByUser = (pagination = 10, page = 1) => async (dispa
}

// GET INVITE LINK
export const getInviteLink = () => async (dispatch) => {
export const getInviteLink = (role) => async (dispatch) => {
try {
const res = await axios.get('/user/invite')
const res = await axios.get(`/user/invite?role=${role}`)
dispatch(setRequestStatus(false));
if(res.status === 200) {
dispatch(setRequestStatus(true));
Expand All @@ -187,7 +194,7 @@ export const processInviteToken = (token) => async (dispatch) => {
console.log('Processing the invite link ', res.data);
dispatch({
type: PROCESS_INVITE_LINK,
payload: res.data.success || res.data.msg
payload: res.data.redirectTo || res.data.msg
})
}
} catch(error) {
Expand Down
11 changes: 7 additions & 4 deletions src/auth/login-form/login-form.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
padding: 15px 0;
.form-group {
label {
color: #00abff;
color: #1a73e8;
font-family: Inter;
}
}
.cta-login {
Expand All @@ -11,8 +12,9 @@
justify-content: center;
margin-top: 30px;
button {
padding: 8px 10px;
border-radius: 30px;
width: 104px;
background-color: #1a73e8;
// border-radius: 30px;
}
}
}
Expand All @@ -22,6 +24,7 @@
align-items: center;
justify-content: center;
margin-top: 10px;
color: #1a73e8;
}
#validation_msg {
color: rgb(247, 134, 134);
Expand All @@ -30,7 +33,7 @@

.loginbtn {
border: 1px solid rgb(211, 220, 228);
border-radius: 3px;
// border-radius: 3px;
width: 45%;
}

Expand Down
38 changes: 12 additions & 26 deletions src/auth/login/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import LoginForm from "../login-form/login-form";
import SignUpForm from "../signup-form/signup-form";
import { DonutTitle } from "../../donutTitle/donutTitle";
import multipleDonuts from "../../images/extra-donuts.png";
import GoogleLogin from '../../images/icons8-google-48.png'
import { FaGoogle, FaGithub } from 'react-icons/fa'
import "./login.scss";

class Login extends Component {
Expand Down Expand Up @@ -55,40 +57,24 @@ class Login extends Component {
? "Or Sign In with"
: "Or SignUp with"}
</p>
<Row>
<Col className="button-column">
<div className="login__options">
<div className="">
<a
href="http://localhost:4000/auth/google"
href="http://localhost:5000/auth/google"
style={{ padding: "1vh" }}
>
<Button
className="selectorbtn"
type="submit"
variant="primary"
color="primary"
size="sm"
>
<span className="selectorbtn-content">Google</span>
</Button>
<img src={GoogleLogin} alt="Google" className="google__login"/>
</a>
</Col>
<Col className="button-column">
</div>
<div className="" >
<a
href="http://localhost:4000/auth/github"
href="http://localhost:5000/auth/github"
Copy link
Member

Choose a reason for hiding this comment

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

.

Copy link
Member Author

Choose a reason for hiding this comment

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

@vaibhavdaren As the GitHub and google login is not implemented yet, so it's there from the initial phase.
When I will implement the google and GitHub login then will integrate that.

style={{ padding: "1vh" }}
>
<Button
className="selectorbtn"
type="submit"
variant="primary"
color="primary"
size="sm"
>
<span className="selectorbtn-content">Github</span>
</Button>
<FaGithub color="#24292e" className="github__login"/>
</a>
</Col>
</Row>
</div>
</div>
<p className="login-text-selector">
{this.state.activeForm === "login"
? "Don't have an account? "
Expand Down
Loading