Skip to content

Commit f1c6b72

Browse files
Fixing conflicts
2 parents b05a9ae + 8ee2387 commit f1c6b72

File tree

22 files changed

+263
-102
lines changed

22 files changed

+263
-102
lines changed

src/actions/eventAction.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,20 @@ import { errorHandler } from '../utils/errorHandler';
33
import { setRequestStatus } from '../utils/setRequestStatus';
44
import { GET_ALL_EVENTS, GET_EVENT_BY_ID } from './types';
55
import { BASE_URL } from './baseApi'
6+
import { customErrorHandler } from '../utils/customErrorHandler';
67

78
// DELETE EVENT REQUEST
89
export const deleteEvent = (eventId) => async (dispatch) => {
910
try {
1011
const res = await axios.delete(`${BASE_URL}/event/${eventId}`)
11-
dispatch(setRequestStatus(false));
1212
if(res.status === 200){
13-
dispatch(setRequestStatus(true));
1413
dispatch(getAllEvents())
1514
}
1615
} catch(error) {
17-
dispatch(errorHandler(error))
16+
const msg = {
17+
error: error?.response?.msg
18+
}
19+
dispatch(customErrorHandler(msg))
1820
}
1921
}
2022

@@ -47,7 +49,7 @@ export const createEvent = (eventInfo, history) => async (dispatch) => {
4749
}
4850

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

src/actions/orgAction.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import {
66
UPDATE_ORG_PROFILE,
77
DEACTIVATE_ORG,
88
GET_ALL_MEMBERS,
9-
TRIGGER_MAINTENANCE
9+
TRIGGER_MAINTENANCE,
10+
GET_LOGIN_OPTIONS
1011
} from './types'
1112

1213
import { BASE_URL } from './baseApi'
@@ -149,4 +150,20 @@ export const TriggerMaintenance = () => async (dispatch) => {
149150
} catch (error) {
150151
dispatch(errorHandler(error))
151152
}
153+
}
154+
155+
// GET LOGIN OPTIONS
156+
export const getLoginOptions = () => async (dispatch) => {
157+
try {
158+
const res = await axios.get(`${BASE_URL}/org/login/options`)
159+
if(res.status === 200) {
160+
console.log('fetched login options ', res.data)
161+
dispatch({
162+
type: GET_LOGIN_OPTIONS,
163+
payload: res.data.methods
164+
})
165+
}
166+
} catch(error) {
167+
dispatch(errorHandler(error))
168+
}
152169
}

src/actions/postAction.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,16 @@ export const removeReaction = (postId, type) => async (dispatch) => {
111111
dispatch(errorHandler(error));
112112
}
113113
};
114+
115+
// PIN POST BY ID
116+
export const pinPost = (postId) => async (dispatch) => {
117+
try {
118+
const res = await axios.patch(`${BASE_URL}/post/pin/${postId}`)
119+
if (res.status === 200) {
120+
console.log('post pinned ', res.data.post)
121+
dispatch(getAllPinnedPosts(10, 1));
122+
}
123+
} catch(error) {
124+
dispatch(errorHandler(error))
125+
}
126+
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,5 @@ export const GET_DEVICE_ANALYTICS ="GET_DEVICE_ANALYTICS"
5353
export const GET_MOSTVIEWED_ANALYTICS ="GET_MOSTVIEWED_ANALYTICS"
5454
export const GET_PROPOSALVIEW_ANALYTICS="GET_PROPOSALVIEW_ANALYTICS"
5555
export const ACTIVATE_DEACTIVATE_ACCOUNT_TOGGLER = "ACTIVATE_DEACTIVATE_ACCOUNT_TOGGLER";
56-
export const CLEAR_INVITE_LINK = "CLEAR_INVITE_LINK"
56+
export const CLEAR_INVITE_LINK = "CLEAR_INVITE_LINK";
57+
export const GET_LOGIN_OPTIONS = "GET_LOGIN_OPTIONS";

src/actions/usersAction.js

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { errorHandler } from '../utils/errorHandler'
33
import axios from 'axios'
44
import { setRequestStatus } from '../utils/setRequestStatus'
55
import { BASE_URL } from './baseApi'
6+
const userId = localStorage.getItem('userId')
67

78
// GET USER PROFILE
89
export const getProfile = (id) => async (dispatch)=> {
@@ -31,15 +32,12 @@ export const getProfile = (id) => async (dispatch)=> {
3132
// FOLLOW USER
3233
export const followUser = (userId) => async (dispatch) => {
3334
try {
34-
let followObj = {
35-
followId: userId
36-
}
37-
console.log('followObj ', followObj)
38-
const res = await axios.patch(`${BASE_URL}/user/follow`, followObj)
35+
console.log('followuser ', userId)
36+
const res = await axios.patch(`${BASE_URL}/user/follow/${userId}`)
3937
dispatch(setRequestStatus(false))
4038
if (res.status === 200) {
4139
dispatch(setRequestStatus(true))
42-
console.log('started following ', followObj)
40+
console.log('started following ', userId)
4341
dispatch({
4442
type: GET_USER_PROFILE,
4543
payload: res.data.user,
@@ -53,15 +51,12 @@ export const followUser = (userId) => async (dispatch) => {
5351
// UnFOLLOW USER
5452
export const unFollowUser = (userId) => async (dispatch) => {
5553
try {
56-
let unFollowObj = {
57-
followId: userId
58-
}
59-
console.log('unfollowObj ', unFollowObj)
60-
const res = await axios.patch(`${BASE_URL}/user/unfollow`, unFollowObj)
54+
console.log('unfollowObj ', userId)
55+
const res = await axios.patch(`${BASE_URL}/user/unfollow/${userId}`)
6156
dispatch(setRequestStatus(false))
6257
if (res.status === 200) {
6358
dispatch(setRequestStatus(true))
64-
console.log('unfollowed ', unFollowObj)
59+
console.log('unfollowed ', userId)
6560
dispatch({
6661
type: GET_USER_PROFILE,
6762
payload: res.data.user,
@@ -112,11 +107,11 @@ export const updateProfile = (userId, updatedInfo) => async (dispatch) => {
112107
}
113108

114109
// GET EVENTS CREATED BY USER
115-
export const getEventsCreatedByUser = (userId, pagination = 10, page = 1) => async (dispatch) => {
110+
export const getEventsCreatedByUser = (id = userId, pagination = 10, page = 1) => async (dispatch) => {
116111
try {
117-
console.log('getEvents userId ', userId)
112+
console.log('getEvents userId ', id)
118113
const res = await axios
119-
.get(`${BASE_URL}/event/${userId}/all?pagination=${pagination}&page=${page}`);
114+
.get(`${BASE_URL}/event/${id}/all?pagination=${pagination}&page=${page}`);
120115
dispatch(setRequestStatus(false))
121116
if(res.status === 200) {
122117
dispatch(setRequestStatus(true))
@@ -132,11 +127,11 @@ export const getEventsCreatedByUser = (userId, pagination = 10, page = 1) => asy
132127
}
133128

134129
// GET ALL PROJECT CREATED BY A USER
135-
export const getProjectCreatedByUser = (userId, pagination = 10, page = 1) => async (dispatch) => {
130+
export const getProjectCreatedByUser = (id = userId, pagination = 10, page = 1) => async (dispatch) => {
136131
try {
137-
console.log('getProjects userId ', userId)
132+
console.log('getProjects userId ', id)
138133
const res = await axios
139-
.get(`${BASE_URL}/project/${userId}/all?pagination=${pagination}&page=${page}`);
134+
.get(`${BASE_URL}/project/${id}/all?pagination=${pagination}&page=${page}`);
140135
dispatch(setRequestStatus(false))
141136
if(res.status === 200) {
142137
dispatch(setRequestStatus(true))
@@ -152,11 +147,11 @@ export const getProjectCreatedByUser = (userId, pagination = 10, page = 1) => as
152147
}
153148

154149
// GET POSTS CREATED BY USER
155-
export const getPostsCreatedByUser = (userId, pagination = 10, page = 1) => async (dispatch) => {
150+
export const getPostsCreatedByUser = (id = userId, pagination = 10, page = 1) => async (dispatch) => {
156151
try {
157-
console.log('getPosts userId ', userId)
152+
console.log('getPosts userId ', id)
158153
const res = await axios
159-
.get(`${BASE_URL}/post/${userId}/all?pagination=${pagination}&page=${page}`);
154+
.get(`${BASE_URL}/post/${id}/all?pagination=${pagination}&page=${page}`);
160155
dispatch(setRequestStatus(false))
161156
if(res.status === 200) {
162157
dispatch(setRequestStatus(true))
@@ -174,7 +169,7 @@ export const getPostsCreatedByUser = (userId, pagination = 10, page = 1) => asyn
174169
// GET INVITE LINK
175170
export const getInviteLink = (role) => async (dispatch) => {
176171
try {
177-
const res = await axios.get(`${BASE_URL}/user/invite?role=${role}`)
172+
const res = await axios.get(`${BASE_URL}/user/link/invite?role=${role}`)
178173
dispatch(setRequestStatus(false));
179174
if(res.status === 200) {
180175
dispatch(setRequestStatus(true));

src/reducers/orgReducer.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import { GET_ORG_PROFILE, UPDATE_ORG_PROFILE, DEACTIVATE_ORG, TRIGGER_MAINTENANCE } from '../actions/types'
1+
import { GET_ORG_PROFILE, UPDATE_ORG_PROFILE, DEACTIVATE_ORG, TRIGGER_MAINTENANCE, GET_LOGIN_OPTIONS } from '../actions/types'
22
const initialState = {
33
isDeactivated: false,
44
isMaintenance: false,
5-
org: {}
5+
org: {},
6+
loginOptions: {}
67
}
78

89
export default (state = initialState, action) => {
@@ -31,6 +32,12 @@ export default (state = initialState, action) => {
3132
isDeactivated: action.payload
3233
}
3334
}
35+
case GET_LOGIN_OPTIONS: {
36+
return {
37+
...state,
38+
loginOptions: action.payload
39+
}
40+
}
3441
default: {
3542
return state
3643
}

src/user/Activity/Users.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { connect } from 'react-redux';
77
import Moment from 'react-moment'
88
import { Pagination } from 'antd'
99
import { withRouter } from 'react-router-dom'
10+
import Img from '../../assets/images/userIcon2.jpg'
1011

1112
class Users extends Component {
1213
constructor(props) {
@@ -55,13 +56,18 @@ class Users extends Component {
5556
key={index}
5657
onClick={() => this.props.history.push(`/activity/${user._id}`)}
5758
>
58-
<p className="activity__link">
59-
{user.name.firstName + " " + user.name.lastName}
60-
</p>
61-
<p className="joined__on">
62-
Joined on:{" "}
63-
<Moment format="DD MMM YYYY">{user.createdAt}</Moment>
64-
</p>
59+
<div className="user__wrapper">
60+
<img src={Img} alt="user_image" className="user__image mr-2"/>
61+
<div className="name_wrapper">
62+
<p className="activity__link">
63+
{user.name.firstName + " " + user.name.lastName}
64+
</p>
65+
<p className="joined__on">
66+
Joined on:{" "}
67+
<Moment format="DD MMM YYYY">{user.createdAt}</Moment>
68+
</p>
69+
</div>
70+
</div>
6571
</Timeline.Item>
6672
))}
6773
</Timeline>

src/user/Activity/users.scss

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,37 @@
2929
display: flex;
3030
flex-direction: row;
3131
flex-wrap: wrap;
32-
.activity__link {
33-
color: #1a73ed;
34-
font-family: "Inter";
35-
font-size: 14px;
36-
cursor: pointer;
37-
&:hover {
38-
text-decoration: underline;
39-
}
40-
}
41-
.joined__on {
42-
margin-top: -14px;
43-
color: #cccccc;
44-
}
4532
.pagination__container {
4633
position: fixed;
4734
margin-top: 78vh;
4835
}
36+
.user__wrapper {
37+
display: flex;
38+
flex-direction: row;
39+
max-height: 52px;
40+
.user__image {
41+
border-radius: 50%;
42+
height: 37px;
43+
width: 36px;
44+
}
45+
.name_wrapper {
46+
.activity__link {
47+
color: #1a73ed;
48+
font-family: "Inter";
49+
font-size: 14px;
50+
cursor: pointer;
51+
52+
&:hover {
53+
text-decoration: underline;
54+
}
55+
}
56+
.joined__on {
57+
color: #cccccc;
58+
margin-top: -15px;
59+
&:hover {
60+
text-decoration: underline;
61+
}
62+
}
63+
}
64+
}
4965
}

src/user/auth/login/login.js

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,40 @@ import { DonutTitle } from "../../../donutTitle/donutTitle";
66
import multipleDonuts from "../../../assets/images/extra-donuts.png";
77
import GoogleLogin from "../../../assets/images/icons8-google-48.png";
88
import { FaGithub } from 'react-icons/fa'
9+
import { connect } from 'react-redux';
10+
import { getLoginOptions } from '../../../actions/orgAction'
911
import "./login.scss";
1012

1113
class Login extends Component {
1214
constructor(props) {
1315
super(props);
1416
this.state = {
1517
activeForm: "login",
18+
loginOptions: {}
1619
};
1720
}
21+
22+
// get login options
23+
componentDidMount() {
24+
this.props.getLoginOptions()
25+
}
26+
27+
componentDidUpdate(prevProps, prevState) {
28+
if(prevState.loginOptions != this.props.org?.loginOptions){
29+
this.setState({
30+
loginOptions: this.props.org?.loginOptions
31+
})
32+
}
33+
}
34+
1835
handleSelectorClick = (formItem) => {
1936
this.setState({
2037
activeForm: formItem,
2138
});
2239
};
2340

2441
render() {
42+
const { loginOptions } = this.state
2543
return (
2644
<div className="login-page">
2745
<div className="welcome-text">
@@ -58,7 +76,8 @@ class Login extends Component {
5876
: "Or SignUp with"}
5977
</p>
6078
<Row>
61-
<Col className = "button-column">
79+
{Boolean(loginOptions?.google === true) ? (
80+
<Col className = "button-column">
6281
<a
6382
href="http://localhost:5000/auth/google"
6483
style={{ padding: "1vh" }}
@@ -76,7 +95,9 @@ class Login extends Component {
7695
</Button>
7796
</a>
7897
</Col>
79-
<Col className="button-column" >
98+
) : null }
99+
{Boolean(loginOptions?.github === true) ? (
100+
<Col className="button-column" >
80101
<a
81102
href="http://localhost:5000/auth/google"
82103
style={{ padding: "1vh" }}
@@ -94,6 +115,7 @@ class Login extends Component {
94115
</Button>
95116
</a>
96117
</Col>
118+
) : null }
97119
</Row>
98120
<p className="login-text-selector">
99121
{this.state.activeForm === "login"
@@ -123,4 +145,9 @@ class Login extends Component {
123145
}
124146
}
125147

126-
export default Login;
148+
// map state to props
149+
const mapStateToProps = (state) => ({
150+
org: state.org
151+
})
152+
153+
export default connect(mapStateToProps, { getLoginOptions })(Login);

0 commit comments

Comments
 (0)