diff --git a/src/actions/adminAction.js b/src/actions/adminAction.js index 8a97b2fc..1504e9eb 100644 --- a/src/actions/adminAction.js +++ b/src/actions/adminAction.js @@ -1,7 +1,11 @@ import axios from 'axios' import { errorHandler } from '../utils/errorHandler' import { setRequestStatus } from '../utils/setRequestStatus' -import { SET_ADMIN } from './types' +import { SET_ADMIN, GET_ADMIN } from './types' +import { setAuthToken } from '../utils/setAuthToken' +import jwt_decode from 'jwt-decode'; +import { setCurrentUser } from './authAction' + export const createAdmin = (adminInfo) => async (dispatch) => { try { @@ -9,24 +13,40 @@ export const createAdmin = (adminInfo) => async (dispatch) => { setRequestStatus(false) if (res.status === 201) { setRequestStatus(true) + dispatch({ + type: GET_ADMIN, + payload: res.data.user + }) } } catch (error) { dispatch(errorHandler(error)) } } -export const loginAdmin = (adminInfo) => async (dispatch) => { +export const loginAdmin = (adminInfo, history) => async (dispatch) => { try { const res = await axios.post('/auth/login/', adminInfo) - dispatch(setRequestStatus(false)) - if (res.status === 200) { - dispatch(setRequestStatus(true)) - localStorage.setItem('admin', true) - dispatch({ - type: SET_ADMIN, - payload: true - }) - } + dispatch(setRequestStatus(false)); + if (res.status === 200) { + + const token = res.data.token; + dispatch(setRequestStatus(true)); + + localStorage.setItem("jwtToken", JSON.stringify(token)); + setAuthToken(token); + + // update state with user + const decodedData = await jwt_decode(token); + localStorage.setItem('userId', decodedData._id) + dispatch(setCurrentUser(decodedData)); + + dispatch({ + type: SET_ADMIN, + payload: true + }) + + history.push("/dashboard"); + } } catch (error) { dispatch(errorHandler(error)) } diff --git a/src/actions/authAction.js b/src/actions/authAction.js index 270d7b6e..543bb639 100644 --- a/src/actions/authAction.js +++ b/src/actions/authAction.js @@ -1,4 +1,4 @@ -import { SET_CURRENT_USER } from './types'; +import { SET_CURRENT_USER, GET_USER_PROFILE, PASSWORD_SUCCESSFULLY_CHANGED, PASSWORD_CHANGE_REQUEST_SUCCESS } from './types'; import axios from 'axios'; import { setAuthToken } from '../utils/setAuthToken'; import jwt_decode from 'jwt-decode'; @@ -14,6 +14,10 @@ export const registerUser = (userInfo, history) => async (dispatch) => { if(res.status === 201) { dispatch(setRequestStatus(true)); + dispatch({ + type: GET_USER_PROFILE, + payload: res.data.user + }) history.push('/'); } @@ -53,13 +57,17 @@ export const loginUser = (userInfo, history) => async (dispatch) => { // forgot password export const forgotPassword = (email) => async (dispatch) => { try { - const res = await axios.post('/user/password_reset', email); + const res = await axios.patch('/user/password_reset/request/', email); dispatch(setRequestStatus(false)); if(res.status === 200){ dispatch(setRequestStatus(true)); console.log("Forgot password request sent!!"); forgotPasswordToken = res.data.token; + dispatch({ + type: PASSWORD_CHANGE_REQUEST_SUCCESS, + payload: res.data.token + }) } } catch (error) { @@ -70,13 +78,17 @@ export const forgotPassword = (email) => async (dispatch) => { // update password export const changePassword = (passObj) => async (dispatch) => { try { - const res = await axios.post(`/user/password_reset/${forgotPasswordToken}`, passObj); + const res = await axios.patch(`/user/password_reset/${forgotPasswordToken}`, passObj); dispatch(setRequestStatus(false)); if(res.status === 200){ dispatch(setRequestStatus(true)); console.log("Password updated!", res.data); // show password updated notification from here + dispatch({ + type: PASSWORD_SUCCESSFULLY_CHANGED, + payload: res.data.updated + }) } } catch(error) { diff --git a/src/actions/commentAction.js b/src/actions/commentAction.js new file mode 100644 index 00000000..94e9fe99 --- /dev/null +++ b/src/actions/commentAction.js @@ -0,0 +1,67 @@ +import { GET_COMMENTS_OF_A_POST } from './types' +import { errorHandler } from '../utils/errorHandler' +import axios from 'axios' +import { setRequestStatus } from '../utils/setRequestStatus' + +// CREATE COMMENT ON A PARTICULAR POST +export const createComment = (postId, comment) => async (dispatch) => { + try { + const res = await axios.post(`/comment/${postId}`, comment) + dispatch(setRequestStatus(false)); + if(res.status === 201) { + dispatch(setRequestStatus(true)) + console.log('created comment ', res.data.comment) + dispatch(getAllCommentsOfPost()); + } + } catch(error) { + dispatch(errorHandler(error)) + } +} + +// GET ALL COMMENTS OF A POST +export const getAllCommentsOfPost = (postId) => async (dispatch) => { + try { + const res = await axios.get(`/comment/${postId}`) + dispatch(setRequestStatus(false)) + if(res.status === 200) { + dispatch(setRequestStatus(true)); + console.log('fetching comments of ', postId, res.data.comments); + dispatch({ + type: GET_COMMENTS_OF_A_POST, + payload: res.data.comments + }) + } + } catch(error) { + dispatch(errorHandler(error)) + } +} + +// UPDATE COMMENT OF A POST +export const updateComment = (commentId, updatedComment) => async (dispatch) => { + try { + const res = await axios.patch(`/comment/${commentId}`, updatedComment) + dispatch(setRequestStatus(false)) + if(res.status === 200) { + dispatch(setRequestStatus(true)) + console.log('comment updated ', res.data.comment) + dispatch(getAllCommentsOfPost()) + } + } catch(error) { + errorHandler(error) + } +} + +// DELETE COMMENT +export const deleteComment = (commentId) => async (dispatch) => { + try { + const res = await axios.delete(`/comment/${commentId}`) + dispatch(setRequestStatus(false)) + if(res.status === 200) { + dispatch(setRequestStatus(true)); + console.log('comment deleted ', res.data) + dispatch(getAllCommentsOfPost()) + } + } catch(error) { + dispatch(errorHandler(error)) + } +} \ No newline at end of file diff --git a/src/actions/dashboardAction.js b/src/actions/dashboardAction.js index 8076881f..d47cb95d 100644 --- a/src/actions/dashboardAction.js +++ b/src/actions/dashboardAction.js @@ -2,6 +2,9 @@ import axios from 'axios' import { setRequestStatus } from '../utils/setRequestStatus' import { errorHandler } from '../utils/errorHandler' import { GET_ALL_UPCOMING_EVENTS } from './types' +import { getAllEvents } from './eventAction' +import { getAllPosts } from './postAction' +import { getAllProjects } from './projectAction' // GET UPCOMING EVENTS export const upcomingEvents = () => async (dispatch) => { @@ -29,6 +32,7 @@ export const createPost = (postInfo) => async (dispatch) => { if (res.status === 201) { dispatch(setRequestStatus(true)) console.log('post created ', res.data) + dispatch(getAllPosts()) } } catch (error) { dispatch(errorHandler(error)) @@ -43,6 +47,7 @@ export const createEvent = (eventInfo) => async (dispatch) => { if (res.status === 201) { dispatch(setRequestStatus(true)) console.log('event created ', res.data) + dispatch(getAllEvents()) } } catch (error) { dispatch(errorHandler(error)) @@ -58,6 +63,7 @@ export const createProject = (projectInfo) => async (dispatch) => { if (res.status === 201) { dispatch(setRequestStatus(true)) console.log('project created ', res.data) + dispatch(getAllProjects()) } } catch (error) { dispatch(errorHandler(error)) diff --git a/src/actions/eventAction.js b/src/actions/eventAction.js index 72ac4069..5aa603a6 100644 --- a/src/actions/eventAction.js +++ b/src/actions/eventAction.js @@ -1,7 +1,7 @@ import axios from 'axios'; import { errorHandler } from '../utils/errorHandler'; import { setRequestStatus } from '../utils/setRequestStatus'; -import { GET_ALL_EVENTS } from './types'; +import { GET_ALL_EVENTS, GET_EVENT_BY_ID } from './types'; // DELETE EVENT REQUEST export const deleteEvent = (eventId) => async (dispatch) => { @@ -10,6 +10,7 @@ export const deleteEvent = (eventId) => async (dispatch) => { dispatch(setRequestStatus(false)); if(res.status === 200){ dispatch(setRequestStatus(true)); + dispatch(getAllEvents()) } } catch(error) { dispatch(errorHandler(error)) @@ -23,6 +24,7 @@ export const updateEvent = (eventId, updatedInfo) => async (dispatch) => { dispatch(setRequestStatus(false)); if(res.status === 200){ dispatch(setRequestStatus(true)); + dispatch(getAllEvents()) } } catch(error) { dispatch(errorHandler(error)) @@ -60,3 +62,22 @@ export const getAllEvents = (pagination = 10, page = 1) => async (dispatch) => { dispatch(errorHandler(error)) } } + +// GET EVENT BY ID +export const getEventById = (eventId) => async (dispatch) => { + try { + console.log('fetching event ', eventId) + const res = await axios.get(`/event/${eventId}`) + dispatch(setRequestStatus(false)) + if(res.status === 200){ + dispatch(setRequestStatus(true)) + console.log('fetching event by id ', res.data.event) + dispatch({ + type: GET_EVENT_BY_ID, + payload: res.data.event + }) + } + } catch(error) { + dispatch(errorHandler(error)) + } +} \ No newline at end of file diff --git a/src/actions/orgAction.js b/src/actions/orgAction.js index b46aa774..15a44800 100644 --- a/src/actions/orgAction.js +++ b/src/actions/orgAction.js @@ -11,6 +11,7 @@ export const registerCommunity = (orgInfo) => async (dispatch) => { if (res.status === 201) { dispatch(setRequestStatus(true)) localStorage.setItem('orgId', JSON.stringify(res.data.org._id)) + dispatch(getOrgProfile()) } } catch (error) { dispatch(errorHandler(error)) @@ -61,15 +62,17 @@ export const getOrgProfile = () => async (dispatch) => { export const updateOrgProfile = (updatedInfo) => async (dispatch) => { try { let orgId = localStorage.getItem('orgId') + console.log('updatedInfo ', updatedInfo); const res = await axios.patch(`/org/${orgId}`, updatedInfo) dispatch(setRequestStatus(false)); if(res.status === 200) { dispatch(setRequestStatus(true)) console.log('org profile updated!', res.data) - dispatch({ - type: UPDATE_ORG_PROFILE, - payload: res.data.organization - }) + dispatch(getOrgProfile()); + // dispatch({ + // type: UPDATE_ORG_PROFILE, + // payload: res.data.organization + // }) } } catch(error) { dispatch(errorHandler(error)) diff --git a/src/actions/postAction.js b/src/actions/postAction.js index 6ca6e777..f5b56f8c 100644 --- a/src/actions/postAction.js +++ b/src/actions/postAction.js @@ -1,7 +1,7 @@ import axios from 'axios'; import { errorHandler } from '../utils/errorHandler'; import { setRequestStatus } from '../utils/setRequestStatus'; -import { GET_ALL_POSTS } from './types'; +import { GET_ALL_POSTS, GET_ALL_PINNED_POSTS } from './types'; // GET ALL POSTS export const getAllPosts = (pagination = 10, page = 1) => async (dispatch) => { @@ -21,3 +21,20 @@ export const getAllPosts = (pagination = 10, page = 1) => async (dispatch) => { } } +// GET ALL PINNED POSTS +export const getAllPinnedPosts = (pagination = 10, page = 1) => async (dispatch) => { + try { + const res = await axios.get(`/post/all/pinned?pagination=${pagination}&page=${page}`) + dispatch(setRequestStatus(false)) + if(res.status === 200){ + dispatch(setRequestStatus(true)) + console.log('fetching all pinned posts ', res.data.pinnedPost) + dispatch({ + type: GET_ALL_PINNED_POSTS, + payload: res.data.pinnedPost + }) + } + } catch(error) { + dispatch(errorHandler(error)) + } +} \ No newline at end of file diff --git a/src/actions/projectAction.js b/src/actions/projectAction.js index f21d3c34..ffa6594b 100644 --- a/src/actions/projectAction.js +++ b/src/actions/projectAction.js @@ -1,7 +1,7 @@ import axios from 'axios'; import { errorHandler } from '../utils/errorHandler'; import { setRequestStatus } from '../utils/setRequestStatus'; -import { GET_ALL_PROJECTS } from './types'; +import { GET_ALL_PROJECTS, GET_SINGLE_PROJECT } from './types'; // CREATE PROJECT export const createProject = (projectInfo) => async (dispatch) => { @@ -34,4 +34,56 @@ export const getAllProjects = (pagination = 10, page = 1) => async (dispatch) => } catch(error) { dispatch(errorHandler(error)) } -} \ No newline at end of file +} + +// GET PROJECT BY ID +export const getProjectById = (projectId) => async (dispatch) => { + try { + const res = await axios.get(`/project/${projectId}`) + dispatch(setRequestStatus(false)) + if(res.status === 200) { + dispatch(setRequestStatus(true)); + dispatch({ + type: GET_SINGLE_PROJECT, + payload: res.data.project + }) + } + } catch(error) { + dispatch(errorHandler(error)) + } +} + +// UPDATE PROJECT +export const updateProject = (projectId, updatedInfo) => async (dispatch) => { + try { + const res = await axios.patch(`/project/${projectId}`, updatedInfo) + dispatch(setRequestStatus(false)) + if(res.status === 200) { + dispatch(setRequestStatus(true)); + console.log('updated project info ', res.data) + dispatch({ + type: GET_SINGLE_PROJECT, + payload: res.data.project + }) + } + } catch(error) { + dispatch(errorHandler(error)) + } +} + +// DELETE PROJECT BY ID +export const deleteProjectById = (projectId, history) => async (dispatch) => { + try { + const res = await axios.delete(`/project/${projectId}`) + dispatch(setRequestStatus(false)) + if(res.status === 200) { + dispatch(setRequestStatus(true)) + console.log('Project deleted', res.data.msg); + // window.location.href = '/projects' + // dispatch(getAllProjects()) + history.push('/projects'); + } + } catch(error) { + dispatch(errorHandler(error)) + } +} diff --git a/src/actions/types.js b/src/actions/types.js index ca25eeac..cdcbc38d 100644 --- a/src/actions/types.js +++ b/src/actions/types.js @@ -26,4 +26,13 @@ export const GET_USER_PROJECTS = "GET_USER_PROJECTS"; 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"; \ No newline at end of file +export const GET_USER_POSTS = "GET_USER_POSTS"; +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_SUCCESSFULLY_CHANGED = "PASSWORD_SUCCESSFULLY_CHANGED"; +export const GET_INVITE_LINK = "GET_INVITE_LINK"; +export const PROCESS_INVITE_LINK = "PROCESS_INVITE_LINK"; \ No newline at end of file diff --git a/src/actions/usersAction.js b/src/actions/usersAction.js index 149456e0..14fbe450 100644 --- a/src/actions/usersAction.js +++ b/src/actions/usersAction.js @@ -1,4 +1,4 @@ -import { GET_USER_PROFILE, GET_ALL_MEMBERS, UPDATE_USER_PROFILE, GET_USER_EVENTS, GET_USER_PROJECTS, GET_USER_POSTS } 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 } from './types' import { errorHandler } from '../utils/errorHandler' import axios from 'axios' import { setRequestStatus } from '../utils/setRequestStatus' @@ -158,3 +158,39 @@ export const getPostsCreatedByUser = (pagination = 10, page = 1) => async (dispa dispatch(errorHandler(error)) } } + +// GET INVITE LINK +export const getInviteLink = () => async (dispatch) => { + try { + const res = await axios.get('/user/invite') + dispatch(setRequestStatus(false)); + if(res.status === 200) { + dispatch(setRequestStatus(true)); + console.log('Fetching invite link ', res.data.inviteLink) + dispatch({ + type: GET_INVITE_LINK, + payload: res.data.inviteLink + }) + } + } catch (error) { + dispatch(errorHandler(error)) + } +} + +// PROCESS INVITE LINK +export const processInviteToken = (token) => async (dispatch) => { + try { + const res = await axios.get(`/user/invite/${token}`) + dispatch(setRequestStatus(false)); + if(res.status === 200) { + dispatch(setRequestStatus(true)) + console.log('Processing the invite link ', res.data); + dispatch({ + type: PROCESS_INVITE_LINK, + payload: res.data.success || res.data.msg + }) + } + } catch(error) { + dispatch(errorHandler(error)); + } +} \ No newline at end of file diff --git a/src/auth/login-form/login-form.js b/src/auth/login-form/login-form.js index 317d817f..f6cea6f4 100644 --- a/src/auth/login-form/login-form.js +++ b/src/auth/login-form/login-form.js @@ -68,8 +68,6 @@ class LoginForm extends Component { }; render() { - const { email, password, error, isValidForm, isValidEmail } = this.state; - const handleToggle = (e) => { const targetName = e.target.name; this.setState({ diff --git a/src/auth/signup-form/signup-form.js b/src/auth/signup-form/signup-form.js index bdcd1758..85843061 100644 --- a/src/auth/signup-form/signup-form.js +++ b/src/auth/signup-form/signup-form.js @@ -1,8 +1,6 @@ import React, { Component } from "react"; import { Form, Button, Row, Col } from "react-bootstrap"; -import { TextField } from "@material-ui/core"; import "./signup-form.scss"; -import Grid from "@material-ui/core/Grid"; import { makeStyles } from "@material-ui/core/styles"; import { connect } from "react-redux"; import { registerUser } from "../../actions/authAction"; @@ -172,9 +170,9 @@ class SignUpForm extends Component { isValidEmail, isValidPhone, isValidDesc, - isMatched, - isValidForm, - error, + // isMatched, + // isValidForm, + // error, } = this.state; return ( diff --git a/src/common/Popups.js b/src/common/Popups.js index 89c950ab..b23399ed 100644 --- a/src/common/Popups.js +++ b/src/common/Popups.js @@ -5,6 +5,8 @@ import { MdVerifiedUser } from 'react-icons/md'; import { FaUserSlash } from 'react-icons/fa'; import { connect } from 'react-redux'; import { forgotPassword, changePassword } from '../actions/authAction'; +import { ToastContainer, toast } from "react-toastify"; +import "react-toastify/dist/ReactToastify.css"; class Popups extends Component { constructor(props){ @@ -20,16 +22,26 @@ class Popups extends Component { option: "", optionValue: "", newPass: "", - cnfPass: "" + cnfPass: "", + requested: false } } componentWillReceiveProps(nextProps){ + console.log('nextProps in common ', nextProps) this.setState({ show: nextProps.modalShow, option: nextProps.option, optionValue: nextProps.optionValue }); + const { currentStep, requested } = this.state + if (nextProps.auth.resetPassReq !== null && requested) { + toast.success('Link sent to your registered email!') + let step = currentStep >= 2 ? 2 : currentStep + 1 + this.setState({ + currentStep: step + }) + } } handleClose = () => { @@ -54,8 +66,8 @@ class Popups extends Component { changePassword = (e) => { e.preventDefault(); - const { newPass } = this.state; - const { auth, changePassword, status } = this.props; + const { newPass, success } = this.state; + const { auth, changePassword } = this.props; const passObj = { password: newPass, @@ -66,30 +78,21 @@ class Popups extends Component { changePassword(passObj); // show notification on sidebar if done successfully - if(status.success) { + if(success) { console.log("Successfully changed the password!"); } } forgotPasswordRequest = () => { const { email } = this.state; - const { forgotPassword, status } = this.props; + const { forgotPassword } = this.props; console.log("forgot password request sending...") - forgotPassword(email); - - let { currentStep } = this.state; - // move to next step if forgot password request successful - if(status.success){ - currentStep = currentStep >= 2 ? 2 : currentStep + 1 - this.setState({ - currentStep: currentStep - }) - } else { - // show error message in popup - console.log("Something went wrong!!"); + const emailObj = { + email: email } - + this.setState({ requested: true }) + forgotPassword(emailObj); } @@ -305,12 +308,25 @@ function Step2(props) { if (props.currentStep !== 2) { return null } - return( + return ( -
- - -
+ +
+ +
); } diff --git a/src/css/components/_modals.scss b/src/css/components/_modals.scss index 3892bb60..47702b99 100644 --- a/src/css/components/_modals.scss +++ b/src/css/components/_modals.scss @@ -30,9 +30,18 @@ letter-spacing: 0.2em; padding-top: 5px; } + .search_btn { + width: 6vw; + height: 5vh; + background: rgb(250, 251, 252); + border-radius: 100px; + color: #1A73E8; + padding: 0.3em; + margin-left: 1em; + } } .modal__search { - width: 100%; + width: 50%; border: 1px solid #cccccc; box-sizing: border-box; border-radius: 5px; @@ -201,7 +210,7 @@ border-radius: 20px; margin-top: 15px; margin-bottom: 10px; - justify-content: center; + margin-left: 10px; align-items: center; .member__image { border: 1px solid #e6e6e5; @@ -214,6 +223,7 @@ .member__content { padding-left: 10px; padding-right: 10px; + margin-right: 40px; width: 50%; } diff --git a/src/reducers/adminReducers.js b/src/reducers/adminReducers.js new file mode 100644 index 00000000..e015d7ce --- /dev/null +++ b/src/reducers/adminReducers.js @@ -0,0 +1,19 @@ +import { SET_ADMIN } from '../actions/types' +const initialState = { + isAdmin: false, + admin: {} +} + +export default (state = initialState, action) => { + switch(action.type) { + case SET_ADMIN: { + return { + ...state, + isAdmin: action.payload + } + } + default: { + return state + } + } +} \ No newline at end of file diff --git a/src/reducers/authReducer.js b/src/reducers/authReducer.js index 7320b181..5a4b7b16 100644 --- a/src/reducers/authReducer.js +++ b/src/reducers/authReducer.js @@ -1,4 +1,4 @@ -import { SET_CURRENT_USER, RESPONSE_MSG, SET_ADMIN, BLOCK_USER, UNBLOCK_USER, REMOVE_USER } from "../actions/types" +import { SET_CURRENT_USER, RESPONSE_MSG, SET_ADMIN, BLOCK_USER, UNBLOCK_USER, REMOVE_USER, PASSWORD_CHANGE_REQUEST_SUCCESS, PASSWORD_SUCCESSFULLY_CHANGED } from "../actions/types" const initialState = { // make it false later, default is set to true so that contributors don't need to login for test @@ -6,6 +6,8 @@ const initialState = { isAdmin: false, isBlocked: false, isRemoved: false, + resetPassReq: null, + passUpdated: false, user: {}, response_msg: "" } @@ -19,6 +21,18 @@ export default (state = initialState, action) => { user: action.payload } } + case PASSWORD_CHANGE_REQUEST_SUCCESS: { + return { + ...state, + resetPassReq: action.payload + } + } + case PASSWORD_SUCCESSFULLY_CHANGED: { + return { + ...state, + passUpdated: action.payload + } + } case BLOCK_USER: { return { ...state, diff --git a/src/reducers/commentReducer.js b/src/reducers/commentReducer.js new file mode 100644 index 00000000..db8cd306 --- /dev/null +++ b/src/reducers/commentReducer.js @@ -0,0 +1,19 @@ +import { GET_COMMENTS_OF_A_POST } from '../actions/types' + +const initialState = { + allComments: [] +} + +export default (state = initialState, action) => { + switch(action.type) { + case GET_COMMENTS_OF_A_POST: { + return { + ...state, + allComments: action.payload + } + } + default: { + return state + } + } +} \ No newline at end of file diff --git a/src/reducers/eventReducer.js b/src/reducers/eventReducer.js index e4873061..cab7f108 100644 --- a/src/reducers/eventReducer.js +++ b/src/reducers/eventReducer.js @@ -1,6 +1,7 @@ -import { GET_ALL_EVENTS } from '../actions/types' +import { GET_ALL_EVENTS, GET_EVENT_BY_ID } from '../actions/types' const initialState = { - allEvents: [] + allEvents: [], + event: {} } export default (state = initialState, action) => { @@ -11,6 +12,12 @@ export default (state = initialState, action) => { allEvents: action.payload } } + case GET_EVENT_BY_ID: { + return { + ...state, + event: action.payload + } + } default:{ return state } diff --git a/src/reducers/index.js b/src/reducers/index.js index 360c5d2b..250d51d9 100644 --- a/src/reducers/index.js +++ b/src/reducers/index.js @@ -10,6 +10,8 @@ import insightReducer from './insightReducer'; import orgReducer from './orgReducer'; import eventReducer from './eventReducer'; import projectReducer from './projectReducer'; +import adminReducers from './adminReducers'; +import commentReducer from './commentReducer'; const rootReducer = combineReducers({ auth: authReducers, @@ -22,6 +24,8 @@ const rootReducer = combineReducers({ org: orgReducer, event: eventReducer, project: projectReducer, + admin: adminReducers, + comment: commentReducer, status: requestStatus }); diff --git a/src/reducers/postReducer.js b/src/reducers/postReducer.js index 0975ac3a..aa70b762 100644 --- a/src/reducers/postReducer.js +++ b/src/reducers/postReducer.js @@ -1,6 +1,7 @@ -import { GET_ALL_POSTS } from '../actions/types' +import { GET_ALL_POSTS, GET_ALL_PINNED_POSTS } from '../actions/types' const initialState = { - allPosts: [] + allPosts: [], + pinnedPosts: [] } export default (state = initialState, action) => { @@ -11,6 +12,12 @@ export default (state = initialState, action) => { allPosts: action.payload } } + case GET_ALL_PINNED_POSTS: { + return { + ...state, + pinnedPosts: action.payload + } + } default:{ return state } diff --git a/src/reducers/projectReducer.js b/src/reducers/projectReducer.js index 73b37577..790b563b 100644 --- a/src/reducers/projectReducer.js +++ b/src/reducers/projectReducer.js @@ -1,6 +1,7 @@ -import { GET_ALL_PROJECTS } from '../actions/types' +import { GET_ALL_PROJECTS, GET_SINGLE_PROJECT } from '../actions/types' const initialState = { - allProjects: [] + allProjects: [], + singleProject: {} } export default (state = initialState, action) => { @@ -11,6 +12,12 @@ export default (state = initialState, action) => { allProjects: action.payload } } + case GET_SINGLE_PROJECT: { + return { + ...state, + singleProject: action.payload + } + } default:{ return state } diff --git a/src/reducers/userReducer.js b/src/reducers/userReducer.js index 1448b093..0bbf1ed0 100644 --- a/src/reducers/userReducer.js +++ b/src/reducers/userReducer.js @@ -1,9 +1,10 @@ -import { GET_USER_PROFILE, UPDATE_USER_PROFILE, GET_USER_EVENTS, GET_USER_PROJECTS, GET_USER_POSTS } from '../actions/types' +import { GET_USER_PROFILE, UPDATE_USER_PROFILE, GET_USER_EVENTS, GET_USER_PROJECTS, GET_USER_POSTS, GET_INVITE_LINK } from '../actions/types' const initialState = { userProfile: {}, userEvents: [], userProjects: [], - userPosts: [] + userPosts: [], + inviteLink: '' } export default (state = initialState, action) => { @@ -38,6 +39,12 @@ export default (state = initialState, action) => { userProfile: action.payload } } + case GET_INVITE_LINK: { + return { + ...state, + inviteLink: action.payload + } + } default: { return state } diff --git a/src/user/Admin/Admin.js b/src/user/Admin/Admin.js index 166af92d..ede675bf 100644 --- a/src/user/Admin/Admin.js +++ b/src/user/Admin/Admin.js @@ -1,11 +1,12 @@ import React, { Component } from 'react' -import { Form, Button, Col, Row } from 'react-bootstrap' +import { Button } from 'react-bootstrap' import './register.scss' import SmallDonut from '../../images/small_donut.png' import ExtraDonuts from '../../images/extra-donuts.png' import DonutShadow from '../../images/shadow.png' import Register from './components/Register' import Login from './components/Login' +import { connect } from 'react-redux' class Admin extends Component { constructor(props) { @@ -20,11 +21,13 @@ class Admin extends Component { view: 'register' } } + toggleView = (name) => { this.setState({ view: name }) } + render() { - const { email, name, password, cnfPass, register, setup, activate, login, view } = this.state; + const { view } = this.state; let adminEmailVerification = (
@@ -100,4 +103,11 @@ class Admin extends Component { ); } } -export default Admin; \ No newline at end of file +// map state to props +const mapStateToProps = (state) => ({ + auth: state.auth, + error: state.error, + admin: state.admin +}) + +export default connect(mapStateToProps)(Admin); \ No newline at end of file diff --git a/src/user/Admin/components/Login.js b/src/user/Admin/components/Login.js index 28031778..ddf47610 100644 --- a/src/user/Admin/components/Login.js +++ b/src/user/Admin/components/Login.js @@ -1,14 +1,44 @@ import React, { Component } from 'react' import { Form, Button } from 'react-bootstrap' +import { connect } from 'react-redux'; +import { loginAdmin } from '../../../actions/adminAction' +import { withRouter } from 'react-router-dom' class Login extends Component { constructor(props) { super(props); this.state = { register: false, + email: '', + password: '' }; } + + componentWillReceiveProps(nextProps) { + console.log('login nextProps', nextProps) + } + + loginAdmin = (e) => { + e.preventDefault() + const { email, password } = this.state + const info = { + email: email, + password: password + } + console.log('admin login', info) + this.props.loginAdmin(info, this.props.history) + if(this.props.status.success) { + this.props.toggle('setup') + } + } + + onChange = (e) => { + const { name, value } = e.target + this.setState({ [name]: value }) + } + render() { + const { email, password } = this.state return (
@@ -28,6 +58,7 @@ class Login extends Component { type="email" placeholder="abc@gmail.com" name="email" + defaultValue={email} onChange={this.onChange} /> @@ -38,6 +69,7 @@ class Login extends Component { type="password" placeholder="***********" name="password" + defaultValue={password} onChange={this.onChange} /> @@ -48,7 +80,7 @@ class Login extends Component { type="submit" variant="primary" color="primary" - onClick={() => this.props.toggle('setup')} + onClick={this.loginAdmin} > Login as an Admin @@ -64,4 +96,12 @@ class Login extends Component { } } -export default Login; \ No newline at end of file +// map state to props +const mapStateToProps = (state) => ({ + auth: state.auth, + error: state.error, + admin: state.admin, + status: state.status +}) + +export default connect(mapStateToProps, { loginAdmin })(withRouter(Login)); \ No newline at end of file diff --git a/src/user/Admin/components/Register.js b/src/user/Admin/components/Register.js index 076ff758..4bc96569 100644 --- a/src/user/Admin/components/Register.js +++ b/src/user/Admin/components/Register.js @@ -1,17 +1,51 @@ import React, { Component } from 'react' -import { Form, Button} from 'react-bootstrap' +import { Form, Button, Row, Col } from 'react-bootstrap' +import { connect } from 'react-redux'; +import { createAdmin } from '../../../actions/adminAction' class Register extends Component { constructor(props) { super(props); this.state = { - login: false - } + login: false, + firstName: "", + lastName: "", + email: "", + password: "", + cnfPass: "", + }; } - gotoLogin = () => { + componentWillReceiveProps(nextProps) { + console.log("Register admin nextProps ", nextProps); } + + onChange = (e) => { + const { name, value } = e.target; + this.setState({ [name]: value }); + }; + + registerAdmin = (e) => { + e.preventDefault(); + const { firstName, lastName, email, password } = this.state; + const info = { + name: { + firstName: firstName, + lastName: lastName, + }, + email: email, + password: password, + isAdmin: true, + }; + console.log("registering admin", info); + this.props.createAdmin(info) + if (this.props.status.success) { + this.props.toggle("activate"); + } + }; + render() { + const { firstName, lastName, email, password, cnfPass } = this.state; return (
@@ -31,21 +65,38 @@ class Register extends Component { type="email" placeholder="abc@gmail.com" name="email" + defaultValue={email} onChange={this.onChange} /> - - - Admin Name - - - + + + + First Name + + + + + + Last Name + + + + Password @@ -65,6 +117,7 @@ class Register extends Component { type="password" placeholder="***********" name="cnfPass" + defaultValue={cnfPass} onChange={this.onChange} /> @@ -75,13 +128,16 @@ class Register extends Component { type="submit" variant="primary" color="primary" - onClick={() => this.props.toggle('activate')} + onClick={this.registerAdmin} > Register as an Admin
-

this.props.toggle('login')}> - Don't have an account? +

this.props.toggle("login")} + > + Already have an account? Login

@@ -90,4 +146,13 @@ class Register extends Component { ); } } -export default Register; + +// map state to props +const mapStateToProps = (state) => ({ + auth: state.auth, + error: state.error, + admin: state.admin, + status: state.status +}) + +export default connect(mapStateToProps, { createAdmin })(Register); diff --git a/src/user/dashboard/Community/CommunitySetting.js b/src/user/dashboard/Community/CommunitySetting.js index 798c75cc..044c14a0 100644 --- a/src/user/dashboard/Community/CommunitySetting.js +++ b/src/user/dashboard/Community/CommunitySetting.js @@ -1,5 +1,4 @@ import React, { Component } from 'react' -import { Modal, Button} from 'react-bootstrap' import LeftNav from './LeftNav' import './community.scss' import OrgProfile from './components/OrgProfile'; diff --git a/src/user/dashboard/Community/LeftNav.js b/src/user/dashboard/Community/LeftNav.js index 359a848c..fec66ca5 100644 --- a/src/user/dashboard/Community/LeftNav.js +++ b/src/user/dashboard/Community/LeftNav.js @@ -1,6 +1,5 @@ import React, { Component } from "react"; -import { ListGroup, Button } from "react-bootstrap"; -import { NavLink } from "react-router-dom"; +import { ListGroup } from "react-bootstrap"; import PropTypes from "prop-types"; import "./navigation.scss"; diff --git a/src/user/dashboard/Community/components/OrgAuth.js b/src/user/dashboard/Community/components/OrgAuth.js index df436819..4a420afc 100644 --- a/src/user/dashboard/Community/components/OrgAuth.js +++ b/src/user/dashboard/Community/components/OrgAuth.js @@ -33,6 +33,7 @@ class OrgAuth extends Component { gitlab } } + console.log('updating auth settings ', info); this.props.updateSettings(info) } @@ -45,17 +46,25 @@ class OrgAuth extends Component { const { authentication } = nextProps.org.org.options; console.log("authentication ", authentication); const { email, google, github, gitlab } = authentication; - this.setState({ email, google, github, gitlab }, () => { + this.setState({ + email, + google, + github, + gitlab, + error: nextProps.error.msg + }, () => { console.log("updated state", this.state); }); - this.setState({ error: nextProps.error.msg }, () => { - console.log('state ', this.state) - }) } - render() { - const { email, github, gitlab, google, error } = this.state + const { + email, + github, + gitlab, + google, + // error + } = this.state return (
diff --git a/src/user/dashboard/Community/components/OrgPermission.js b/src/user/dashboard/Community/components/OrgPermission.js index f8e8beef..1c564a6e 100644 --- a/src/user/dashboard/Community/components/OrgPermission.js +++ b/src/user/dashboard/Community/components/OrgPermission.js @@ -60,12 +60,18 @@ class OrgPermission extends Component { } render() { - const { canChangeEmail, canChangeName, sendInvite, canCreateManage, error } = this.state + const { + canChangeEmail, + canChangeName, + sendInvite, + canCreateManage, + // error + } = this.state return (
-

Organization Permission

+

Organization Permission

@@ -76,14 +82,19 @@ class OrgPermission extends Component { Are invitations required for joining the organization? - - - + + @@ -137,10 +148,30 @@ class OrgPermission extends Component { > Who can create and manage user groups - - - - + + + + diff --git a/src/user/dashboard/Community/components/OrgProfile.js b/src/user/dashboard/Community/components/OrgProfile.js index 264187f8..61dad877 100644 --- a/src/user/dashboard/Community/components/OrgProfile.js +++ b/src/user/dashboard/Community/components/OrgProfile.js @@ -12,10 +12,8 @@ class OrgProfile extends Component { isDeactivated: false, logo: null, orgName: "", - desc: { - short: "", - long: "" - }, + shortDesc: "", + longDesc: "", error: '' } } @@ -26,14 +24,9 @@ class OrgProfile extends Component { } componentWillReceiveProps(nextProps) { - console.log('nextProps ', nextProps) const { name, description } = nextProps.org.org; - let info = { - short: description.shortDescription, - long: description.longDescription, - }; const { isDeactivated } = nextProps.org - this.setState({ orgName: name, desc: info, isDeactivated: isDeactivated }, () => { + this.setState({ orgName: name, shortDesc: description.shortDescription, longDesc: description.longDescription, isDeactivated: isDeactivated }, () => { console.log('org info ', this.state) }) const { msg } = nextProps.error @@ -42,7 +35,9 @@ class OrgProfile extends Component { handleChange = (event) => { const { name, value } = event.target; - this.setState({ [name] : value }) + this.setState({ [name] : value }, () => { + console.log('state ', this.state) + }) } deactivateOrg = () => { @@ -52,15 +47,16 @@ class OrgProfile extends Component { updateInfo = () => { console.log('Update info clicked!'); - const { orgName, desc } = this.state - const updatedInfo = { + const { orgName, shortDesc, longDesc } = this.state + const info = { description: { - shortDescription: desc.short, - longDescription: desc.long, + shortDescription: shortDesc, + longDescription: longDesc, }, name: orgName }; - this.props.updateOrgProfile(updatedInfo) + console.log('updatedInfo ', info) + this.props.updateOrgProfile(info) } onFileChange = (e) => { @@ -71,7 +67,14 @@ class OrgProfile extends Component { } render() { - const { logo, orgName, desc, error, isDeactivated } = this.state; + const { + logo, + orgName, + shortDesc, + longDesc, + // error, + isDeactivated + } = this.state; return (
@@ -118,13 +121,13 @@ class OrgProfile extends Component { @@ -138,7 +141,7 @@ class OrgProfile extends Component { placeholder="Long description" required={true} className="placeholder_text" - defaultValue={desc.long} + defaultValue={longDesc} onChange={this.handleChange} name="longDesc" /> @@ -176,4 +179,8 @@ const mapStateToProps = (state) => ({ org: state.org }) -export default connect(mapStateToProps, { getOrgProfile, updateOrgProfile, deactivateOrg })(OrgProfile); \ No newline at end of file +export default connect(mapStateToProps, { + getOrgProfile, + updateOrgProfile, + deactivateOrg +})(OrgProfile); diff --git a/src/user/dashboard/Community/components/OrgSettings.js b/src/user/dashboard/Community/components/OrgSettings.js index 638a16dd..26a939aa 100644 --- a/src/user/dashboard/Community/components/OrgSettings.js +++ b/src/user/dashboard/Community/components/OrgSettings.js @@ -13,7 +13,8 @@ class OrgSettings extends Component { enableEmail: true, language: "", time: "", - error: '' + error: '', + editingTime: '' }; } @@ -35,9 +36,10 @@ class OrgSettings extends Component { settings: { enableEmail, language, - time - } + timeFormat: time + }, }; + console.log('updating settings ', info); this.props.updateSettings(info) } @@ -59,7 +61,14 @@ class OrgSettings extends Component { } render() { - const { enableEmail, language, time, error } = this.state; + const { + enableEmail, + language, + time, + editingTime, + // editing + // error + } = this.state; return (
@@ -74,6 +83,7 @@ class OrgSettings extends Component { as="select" className="select_option" name="editing" + value={editingTime} onChange={this.onChange} > @@ -140,11 +150,27 @@ class OrgSettings extends Component { as="select" name="language" className="select_option" + value={language} onChange={this.onChange} > - - - + + + @@ -158,10 +184,19 @@ class OrgSettings extends Component { as="select" name="time" className="select_option" + value={time} onChange={this.onChange} > - - + + diff --git a/src/user/dashboard/Community/components/permission.scss b/src/user/dashboard/Community/components/permission.scss index 06da56b8..fde907e6 100644 --- a/src/user/dashboard/Community/components/permission.scss +++ b/src/user/dashboard/Community/components/permission.scss @@ -17,6 +17,9 @@ border: 0.75px solid #90949C; background: #FFFFFF; box-sizing: border-box; + .hide { + display: none; + } } .placeholder_text { color: #C9C9C9; diff --git a/src/user/dashboard/Community/components/settings.scss b/src/user/dashboard/Community/components/settings.scss index e64bc290..4007fc7e 100644 --- a/src/user/dashboard/Community/components/settings.scss +++ b/src/user/dashboard/Community/components/settings.scss @@ -17,6 +17,9 @@ border: 0.75px solid #90949C; background: #FFFFFF; box-sizing: border-box; + .hide { + display: none; + } } .placeholder_text { color: #C9C9C9; diff --git a/src/user/dashboard/dashboard.js b/src/user/dashboard/dashboard.js index 275ee41f..ae42e0cd 100644 --- a/src/user/dashboard/dashboard.js +++ b/src/user/dashboard/dashboard.js @@ -5,8 +5,8 @@ import UpcomingEvents from "./upcoming-events/upcoming-events"; import Notifications from "./notifications/notifications"; import Portfolio from "./portfolio/portfolio"; import NewsFeed from "./news-feed/news-feed"; -import Updates from "./updates/updates"; -import orgUpdatesLoading from "../../placeholderLoading/orgUpdatesLoading/orgUpdatesLoading"; +// import Updates from "./updates/updates"; +// import orgUpdatesLoading from "../../placeholderLoading/orgUpdatesLoading/orgUpdatesLoading"; import notifyUsersLoading from "../../placeholderLoading/notifyUsersLoading/notifyUsersLoading"; import portfolioLoading from "../../placeholderLoading/portfolioLoading/portfolioLoading"; import newsFeedLoading from "../../placeholderLoading/newsFeedLoading/newsFeedLoading"; diff --git a/src/user/dashboard/insights/components/CommunityStats.js b/src/user/dashboard/insights/components/CommunityStats.js index 562b8d51..d2d0f69e 100644 --- a/src/user/dashboard/insights/components/CommunityStats.js +++ b/src/user/dashboard/insights/components/CommunityStats.js @@ -1,7 +1,6 @@ import React, { Component } from 'react' -import { Form, Button } from 'react-bootstrap'; +import { Button } from 'react-bootstrap'; import './community.scss' -import Navigation from '../../navigation/navigation'; import { connect } from 'react-redux' import { getMember, getMembers, getOrgOverview, getPersonalOverview } from '../../../../actions/insightAction' diff --git a/src/user/dashboard/navigation/navigation.js b/src/user/dashboard/navigation/navigation.js index f8071de8..72ac2e12 100644 --- a/src/user/dashboard/navigation/navigation.js +++ b/src/user/dashboard/navigation/navigation.js @@ -1,5 +1,5 @@ import React, { Component } from "react"; -import { ListGroup, Button, OverlayTrigger, Tooltip } from "react-bootstrap"; +import { ListGroup, Button } from "react-bootstrap"; import { NavLink } from "react-router-dom"; import PropTypes from "prop-types"; import "./navigation.scss"; @@ -11,9 +11,9 @@ import { DonutTitleSmall, DonutIconSmall, } from "../../../donutTitle/donutTitle"; -import ComminytPng from "../../../images/community.png"; -import CommunitySetting from "../Community/CommunitySetting"; -import { Desktop, Mobile, Default, Tablet } from "../../../utils/breakpoints"; +// import ComminytPng from "../../../images/community.png"; +// import CommunitySetting from "../Community/CommunitySetting"; +import { Desktop, Mobile } from "../../../utils/breakpoints"; import SVGIcon from "../../../utils/SVGIcon"; class Navigation extends Component { @@ -22,13 +22,13 @@ class Navigation extends Component { org: false }; render() { - function renderTooltip(props) { - return ( - - Simple tooltip - - ); - } + // function renderTooltip(props) { + // return ( + // + // Simple tooltip + // + // ); + // } const ListItem = (props) => { const item = props.isMobile ? ( @@ -55,20 +55,15 @@ class Navigation extends Component { this.setState({ open: false, }); - // const closeOrgSetting = () => { - // this.setState({ - // org: false - // }) - // } - const divStyle = { - position: "fixed", - bottom: '5em' - }; + // const divStyle = { + // position: "fixed", + // bottom: '5em' + // }; const divStyle2 = { position: "fixed", bottom: "2em" }; - const { dashboard, posts, org, orgSettings, event, proj, profile, logout, settings } = this.props; + const { logout } = this.props; return (
diff --git a/src/user/dashboard/navigation/navigation.scss b/src/user/dashboard/navigation/navigation.scss index bde19203..03260b53 100644 --- a/src/user/dashboard/navigation/navigation.scss +++ b/src/user/dashboard/navigation/navigation.scss @@ -31,6 +31,14 @@ color: #1a73e8; } } + span { + .active { + background-color: rgba(26, 115, 232, 0.1); + .link { + color: #1a73e8; + } + } + } } } @@ -41,6 +49,14 @@ color: rgba(0, 0, 0, 0.5); } } + span { + .active { + background-color: rgba(26, 115, 232, 0.1); + .link { + color: #1a73e8; + } + } + } } } @@ -50,6 +66,11 @@ svg { padding: 0px 10px 0px 10px; } + span { + svg { + padding: 0px; + } + } } } } diff --git a/src/user/dashboard/news-feed/news-feed.js b/src/user/dashboard/news-feed/news-feed.js index b813abae..62bde94b 100644 --- a/src/user/dashboard/news-feed/news-feed.js +++ b/src/user/dashboard/news-feed/news-feed.js @@ -9,7 +9,7 @@ import { ListItemAvatar, Avatar, ListItemText, - ListItemSecondaryAction, + // ListItemSecondaryAction, IconButton, CardMedia, } from "@material-ui/core"; @@ -18,17 +18,18 @@ import { Button } from "react-bootstrap"; import AddEventModal from "./popups/AddEventModal"; import AddProjectModal from "./popups/AddProjectModal"; import ArrowDropUpIcon from "@material-ui/icons/ArrowDropUp"; -import ArrowDropDownIcon from "@material-ui/icons/ArrowDropDown"; +// import ArrowDropDownIcon from "@material-ui/icons/ArrowDropDown"; import ChatBubbleIcon from "@material-ui/icons/ChatBubble"; -import EventNoteIcon from "@material-ui/icons/EventNote"; -import EventIcon from "@material-ui/icons/Event"; -import ReplyIcon from '@material-ui/icons/Reply'; -import feed from "../../../jsonData/news-feed"; +// import EventNoteIcon from "@material-ui/icons/EventNote"; +// import EventIcon from "@material-ui/icons/Event"; +// import ReplyIcon from '@material-ui/icons/Reply'; +// import feed from "../../../jsonData/news-feed"; import "../../pinned-posts/posts/posts.scss"; import "./news-feed.scss"; import AddPostModal from "./popups/AddPostModal"; -import { Comment } from "./popups/comment"; +import Comment from "./popups/comment"; import { connect } from 'react-redux' +import { getAllCommentsOfPost } from '../../../actions/commentAction' import profileImg from '../../../svgs/evt-creator.svg'; import eventImg from "../../../svgs/event-img-1.svg"; import eventImg2 from "../../../svgs/event-img-2.svg"; @@ -97,17 +98,19 @@ function NewsFeed(props) { const [writePost, showPostModal] = useState(false); const [showComment, toggle] = useState(false); const [commentId, setCommentId] = useState(''); - const [all, setAll] = useState([]); + // const [all, setAll] = useState([]); const [events, setEvents] = useState([]); const [projects, setAllProjects] = useState([]); const [posts, setAllPosts] = useState([]); + // const [allCommentsOfPost, setAllCommentsOfPost] = useState({}) useEffect(() => { console.log("useEffect from news-feed ", props); setEvents(props?.allEvents); setAllProjects(props?.allProjects); setAllPosts(props?.allPosts); - setAll(props?.allMix); + // setAll(props?.allMix); + // setAllCommentsOfPost(props?.comment?.allComments) }, [props]); let handleClick = (atrb) => () => { @@ -141,18 +144,19 @@ function NewsFeed(props) { let commentToggle = (postId) => { console.log("Comment toggle clicked!", postId); + props.getAllCommentsOfPost(postId) setCommentId(postId); toggle(!showComment); } - let postContent = posts.map((post) => { + let postContent = posts?.map((post) => { return (
- - + */} @@ -196,10 +200,6 @@ function NewsFeed(props) { - @@ -207,7 +207,7 @@ function NewsFeed(props) { ) }) - let projectsContent = projects.map((project) => { + let projectsContent = projects?.map((project) => { return (
@@ -269,7 +269,6 @@ function NewsFeed(props) { - @@ -277,7 +276,7 @@ function NewsFeed(props) { ) }) - let eventsContent = events.map((event) => { + let eventsContent = events?.map((event) => { return (
@@ -352,10 +351,14 @@ function NewsFeed(props) { */} - +
) }) @@ -463,7 +466,7 @@ function NewsFeed(props) { ) : ( diff --git a/src/user/dashboard/news-feed/popups/AddPostModal.js b/src/user/dashboard/news-feed/popups/AddPostModal.js index 652cab64..28cb4a2b 100644 --- a/src/user/dashboard/news-feed/popups/AddPostModal.js +++ b/src/user/dashboard/news-feed/popups/AddPostModal.js @@ -1,4 +1,4 @@ -import React, { useState, useEffect } from "react"; +import React, { useState } from "react"; import { Button, Modal, Form, Col } from "react-bootstrap"; import PropTypes from "prop-types"; import { connect } from 'react-redux'; @@ -60,7 +60,7 @@ const AddPostModal = (props) => {
-
Other people who commented
- {all_comments} + {Boolean(allComments?.length > 0) ? all_comments : "Be the first to comment!"}
); } } + +// map state to props +const mapStateToProps = (state) => ({ + auth: state.auth, + error: state.error, + comment: state.comment, + post: state.post +}) + +export default connect(mapStateToProps, { getAllCommentsOfPost, createComment, deleteComment })(Comment); diff --git a/src/user/dashboard/news-feed/popups/comment.scss b/src/user/dashboard/news-feed/popups/comment.scss index 61308921..11edefca 100644 --- a/src/user/dashboard/news-feed/popups/comment.scss +++ b/src/user/dashboard/news-feed/popups/comment.scss @@ -65,6 +65,11 @@ font-size: 0.8em; color: rgb(90, 84, 84); margin-top: -13px; + max-width: 52ch; + .delete__icon { + color: rgb(82, 82, 82); + float: right; + } } .user_comment{ diff --git a/src/user/dashboard/portfolio/portfolio.js b/src/user/dashboard/portfolio/portfolio.js index 42939e19..ceada520 100644 --- a/src/user/dashboard/portfolio/portfolio.js +++ b/src/user/dashboard/portfolio/portfolio.js @@ -37,7 +37,7 @@ class Portfolio extends Component { componentWillReceiveProps(nextProps) { const { insight, user} = nextProps let members = insight.allMembers - let admins = insight.allMembers.filter(member => member.isAdmin == true); + let admins = insight.allMembers.filter(member => member.isAdmin === true); let info = insight.personalOverview let followers = user.userProfile.followers let followings = user.userProfile.followings; diff --git a/src/user/dashboard/upcoming-events/upcoming-events.js b/src/user/dashboard/upcoming-events/upcoming-events.js index c5dd98e2..b61bdde1 100644 --- a/src/user/dashboard/upcoming-events/upcoming-events.js +++ b/src/user/dashboard/upcoming-events/upcoming-events.js @@ -1,6 +1,6 @@ import React, { Component } from "react"; import "./upcoming-events.scss"; -import events from '../../../jsonData/upcoming-events'; +// import events from '../../../jsonData/upcoming-events'; import donutIcon from '../../../svgs/donut-icon.svg' import { connect } from "react-redux"; import { upcomingEvents } from '../../../actions/dashboardAction' diff --git a/src/user/dashboard/utils/checkDeleteRights.js b/src/user/dashboard/utils/checkDeleteRights.js new file mode 100644 index 00000000..986c9564 --- /dev/null +++ b/src/user/dashboard/utils/checkDeleteRights.js @@ -0,0 +1,16 @@ +export const checkDeleteRights = (userId) => { + const isAdmin = localStorage.getItem('admin'); + const userLoggedIn = JSON.stringify(localStorage.getItem('userId')) + if(isAdmin === 'true' || userLoggedIn === JSON.stringify(userId)){ + return true + } + return false +} + +export const checkRemoveRight = () => { + const isAdmin = localStorage.getItem('admin') + if(isAdmin === 'true'){ + return true + } + return false +} diff --git a/src/user/dashboard/utils/notification.js b/src/user/dashboard/utils/notification.js index 8ad1e6aa..e59eb27a 100644 --- a/src/user/dashboard/utils/notification.js +++ b/src/user/dashboard/utils/notification.js @@ -1,4 +1,4 @@ - import { ToastContainer, toast } from "react-toastify"; +// import { ToastContainer, toast } from "react-toastify"; import "react-toastify/dist/ReactToastify.css"; export const initializeSockets = (state, donutIcon, addToNotification) => { diff --git a/src/user/events/events.js b/src/user/events/events.js index c4e7ef6b..bba437e8 100644 --- a/src/user/events/events.js +++ b/src/user/events/events.js @@ -1,12 +1,15 @@ import React, { Component } from "react"; import Navigation from "../dashboard/navigation/navigation"; import { Grid ,CardActions, Card} from "@material-ui/core"; -import Event_list from "../../jsonData/events"; +// import Event_list from "../../jsonData/events"; import { Row, Col } from "react-bootstrap"; import "./events.scss"; import Popups from './popups/popups'; import DeleteEvent from "./popups/DeleteEvent"; import EditEvent from "./popups/EditEvent"; +import { connect } from 'react-redux' +import { getAllEvents } from '../../actions/eventAction' +import { checkDeleteRights } from '../dashboard/utils/checkDeleteRights' class Events extends Component { constructor(props) { @@ -16,77 +19,101 @@ class Events extends Component { modalShow: false, optionValue: {}, delete: false, - edit: false + edit: false, + allEvents: [], + eventId: '', + singleEvent: {} } } + componentWillMount() { + setTimeout(() => { + this.props.getAllEvents() + }) + } + + componentWillReceiveProps(nextProps) { + console.log('events nextProps', nextProps) + const { allEvents } = nextProps.event + this.setState({ allEvents: allEvents, isAdmin: nextProps.auth?.isAdmin }, () => { + console.log('updating all events ', this.state) + }) + } + + render() { - const setOptionValue = (targetId) => { - const event = Event_list.filter((x) => x._id === targetId); - this.setState({optionValue: event[0]}) + const { allEvents } = this.state + // const setOptionValue = (targetId) => { + // const event = Event_list.filter((x) => x._id === targetId); + // this.setState({optionValue: event[0]}) + // } + + const handleToggle = (eventId, event) => { + console.log("-handletoggel",eventId) + this.setState({ modalShow: true, eventId: eventId, singleEvent: event }); + } + + const RefineDate = (d) => { + const date = d.split("T") + const eventDate = date[0].slice(-2) + return eventDate; } - const handleToggle = (e) => { - const targetId = e.target.id; - console.log("-handletoggel",targetId) - this.setState({ modalShow: true }); - setOptionValue(targetId); + const RefineTime = (d) => { + const time = d.split("T"); + const eventTime = time[1].slice(0, 5) + return eventTime; } - var RefinedDay = (d) => { + const RefinedDay = (d) => { const day = d.slice(0, 3); return day; }; - const editEvent = (e) => { - e.preventDefault(); - this.setState({ modalShow: false, edit: true }) + const RefinedYear = (d) => { + const month = d.slice(4, 7); + const year = d.slice(11, 15); + return month + " " + year; + }; + + const editEvent = (eventId, eventInfo) => { + console.log('eventId ', eventId) + this.setState({ modalShow: false, edit: true, eventId: eventId, singleEvent: eventInfo }) } - const handleDelete = (e) => { - this.setState({ modalShow: false, delete: true }) + const handleDelete = (eventId) => { + console.log('eventId ', eventId) + this.setState({ modalShow: false, delete: true, eventId: eventId }) } const cancel = () => { this.setState({ delete: false, edit: false }) } - const RefinedYear = (d) => { - const month = d.slice(4, 7); - const year = d.slice(11, 15); - return month + " " + year; - }; - const FooterOfEvents = ({ Item }) => { return (
- -
- Edit - Delete + {checkDeleteRights(Item.createdBy._id) ? ( + <> + Edit + Delete + + ) : null }
See More @@ -96,42 +123,40 @@ class Events extends Component { ) } - let Events = Event_list.map((Item, index) => ( - + let Events = allEvents?.map((Item, index) => ( + {Date.parse(Item.eventDate) >= Date.parse(new Date()) ? ( - + {Item.isCancelled ? (
{""}
) : (
{""}
)} - -
- {new Date(Date.parse(Item.eventDate)).getDate()} -
+ +
{RefineDate(Item?.eventDate)}
{RefinedDay( - new Date(Date.parse(Item.eventDate)).toString() + new Date(Date.parse(Item?.eventDate)).toString() )} , {RefinedYear( - new Date(Date.parse(Item.eventDate)).toString() + new Date(Date.parse(Item?.eventDate)).toString() )}
-

{Item.eventName}

+

{Item?.eventName}

- {Item.description.shortDescription} + {Item?.description?.shortDescription}

@@ -139,24 +164,24 @@ class Events extends Component { Time : {Item.isCancelled ? ( - {new Date(Date.parse(Item.eventDate)).toTimeString()} + {RefineTime(Item?.eventDate)} ) : ( - {new Date(Date.parse(Item.eventDate)).toTimeString()} + {RefineTime(Item?.eventDate)} )}

- {!Item.isCancelled ? ( - Item.isOnline ? ( + {!Item?.isCancelled ? ( + Item?.isOnline ? (

Online

) : (

- {Item.location} + {Item?.location}

) ) : ( @@ -164,9 +189,7 @@ class Events extends Component { )}
- +
@@ -177,16 +200,16 @@ class Events extends Component { - - {Item.isCancelled ? ( -
{""}
- ) : ( -
{""}
- )} + + {Item.isCancelled ? ( +
{""}
+ ) : ( +
{""}
+ )} - +
- {new Date(Date.parse(Item.eventDate)).getDate()} + {RefineDate(Item?.eventDate)}
@@ -213,32 +236,32 @@ class Events extends Component { Time : {Item.isCancelled ? ( - {new Date(Date.parse(Item.eventDate)).toTimeString()} + {RefineTime(Item?.eventDate)} ) : ( - - {new Date(Date.parse(Item.eventDate)).toTimeString()} + + {RefineTime(Item?.eventDate)} )}

- {!Item.isCancelled ? ( - Item.isOnline ? ( -

- Online -

+ {!Item.isCancelled ? ( + Item.isOnline ? ( +

+ Online +

+ ) : ( +

+ {Item.location} +

+ ) ) : ( -

- {Item.location} -

- ) - ) : ( -

CANCELLED

- )} +

CANCELLED

+ )}
- +
@@ -256,19 +279,37 @@ class Events extends Component {

All Events

- + {Events}
- + +
); } } +// map state to props +const mapStateToProps = (state) => ({ + auth: state.auth, + error: state.error, + event: state.event +}) -export default Events; +export default connect(mapStateToProps, { getAllEvents })(Events); diff --git a/src/user/events/events.scss b/src/user/events/events.scss index 4a7c14b8..e73b0b4f 100644 --- a/src/user/events/events.scss +++ b/src/user/events/events.scss @@ -14,6 +14,13 @@ line-height: 1.3em; color: #2D2D2D; } + .card__container { + max-width: 33.33%; + } + .MuiCard-root { + overflow: hidden; + height: 42vh; + } } } } @@ -77,6 +84,8 @@ width: auto; text-align: center; font-size: 1.45rem; + margin-left: 5vw; + margin-right: -12vw; .day{ font-weight: 25px; } @@ -100,14 +109,20 @@ .short-des{ text-align: justify; - text-overflow: ellipsis; font-family: Inter; font-style: normal; font-weight: normal; font-size: 1em; line-height: 1.3em; color: #2D2D2D; -} + /* white-space: nowrap; */ + max-width: 259px; + overflow: hidden; + text-overflow: ellipsis; + display: -webkit-box; + -webkit-line-clamp: 3; + -webkit-box-orient: vertical; + } .createdAt{ text-align: center; diff --git a/src/user/events/popups/DeleteEvent.js b/src/user/events/popups/DeleteEvent.js index 0cc9d429..e6c0164a 100644 --- a/src/user/events/popups/DeleteEvent.js +++ b/src/user/events/popups/DeleteEvent.js @@ -14,8 +14,11 @@ class DeleteEvent extends Component { } } - deleteEventClick = (e) => { - e.preventDefault(); + componentWillReceiveProps(nextProps){ + console.log('deleteEvent ', nextProps) + } + + deleteEventClick = () => { console.log("Clicked on delete event") this.props.deleteEvent(this.props.eventId); if(this.props.status.success){ @@ -26,7 +29,7 @@ class DeleteEvent extends Component { } render() { - const { show, onHide, eventId } = this.props; + const { show, onHide } = this.props; return (
{ - // FETCH THE EVENT DETAILS ON POPUP GETS TRIGGERED (INTEGRATION) - console.log("Fetching the event details!"); - }; + + componentWillReceiveProps(nextProps) { + console.log('edit ', nextProps) + const { eventInfo } = nextProps + const { eventName, description, eventDate, location } = eventInfo + this.setState({ + eventName: eventName, + shortDesc: description?.shortDescription, + longDesc: description?.longDescription, + location: location, + date: eventDate + }, () => { + console.log('edit state ', this.state) + }) + } onChange = (event) => { const { name, value } = event.target; this.setState({ [name]: value }); }; + refineDate = (d) => { + const date = d.split("T") + const eventDate = date[0].slice(-2) + return eventDate; + } + + refineTime = (d) => { + const time = d.split("T"); + const eventTime = time[1].slice(0, 5) + return eventTime; + } + + refineDay = (d) => { + const day = d.slice(0, 3); + return day; + }; + + refineYear = (d) => { + const month = d.slice(4, 7); + const year = d.slice(11, 15); + return month + " " + year; + }; + updateEvent = (e) => { e.preventDefault(); console.log("Updating the event!!"); @@ -49,7 +83,7 @@ class EditEvent extends Component { render() { const { show, onHide } = this.props; - + const { eventName, shortDesc, longDesc, location } =this.state return ( @@ -88,6 +123,7 @@ class EditEvent extends Component { placeholder="Write a few lines about event.." size="sm" name="shortDesc" + defaultValue={shortDesc} onChange={this.onChange} required={true} /> @@ -100,6 +136,7 @@ class EditEvent extends Component { placeholder="Write a details of event.." size="sm" name="longDesc" + defaultValue={longDesc} onChange={this.onChange} required={true} /> @@ -112,6 +149,7 @@ class EditEvent extends Component { placeholder="Event location.." size="sm" name="location" + defaultValue={location} onChange={this.onChange} required={true} /> @@ -124,6 +162,7 @@ class EditEvent extends Component { placeholder="Event date.." size="sm" name="date" + // defaultValue={this.refineDate(date)} onChange={this.onChange} required={true} /> @@ -146,12 +185,15 @@ class EditEvent extends Component { EditEvent.propTypes = { show: PropTypes.bool.isRequired, onHide: PropTypes.func.isRequired, - eventId: PropTypes.string.isRequired + eventId: PropTypes.string.isRequired, + eventInfo: PropTypes.object.isRequired } const mapStateToProps = (state) => ({ + auth: state.auth, + status: state.status, error: state.error, - statue: state.status + event: state.event }) -export default connect(mapStateToProps, { updateEvent, deleteEvent })((EditEvent)) +export default connect(mapStateToProps, { updateEvent, deleteEvent, getEventById })((EditEvent)) diff --git a/src/user/events/popups/popups.js b/src/user/events/popups/popups.js index 7ed0cab2..39ba646d 100644 --- a/src/user/events/popups/popups.js +++ b/src/user/events/popups/popups.js @@ -11,13 +11,17 @@ class Popups extends Component { this.state = { show: false, optionValue: {}, + eventInfo: {}, + isCancelled: false }; } componentWillReceiveProps(nextProps) { + console.log('popups ', nextProps) this.setState({ show: nextProps.modalShow, - optionValue: nextProps.optionValue, + optionValue: nextProps?.optionValue, + eventInfo: nextProps?.eventInfo }); } @@ -25,20 +29,32 @@ class Popups extends Component { this.setState({ show: false }); }; - render() { - let { - eventName, - rsvpYes, - rsvpNo, - rsvpMaybe, - description, - slots, - eventDate, - isOnline, - location, - isCancelled, - } = this.state.optionValue; + RefineDate = (d) => { + const date = d.split("T") + const eventDate = date[0].slice(-2) + return eventDate; + } + + RefineTime = (d) => { + const time = d.split("T"); + const eventTime = time[1].slice(0, 5) + return eventTime; + } + + RefinedDay = (d) => { + const day = d.slice(0, 3); + return day; + }; + + RefinedYear = (d) => { + const month = d.slice(4, 7); + const year = d.slice(11, 15); + return month + " " + year; + }; + + render() { + const { eventName, eventDate, description, location, isOnline, slots, rsvpMaybe, rsvpNo, rsvpYes } = this.state.eventInfo return ( {eventName ? ( -

{eventName}

+

{eventName || "EventName"}

) : null} {slots ? (

- Slots : {slots} + Slots : {slots || 0}

) : null} @@ -71,21 +87,32 @@ class Popups extends Component { {eventDate ? ( -

{eventDate.slice(0, 16)}

+

{this.RefineDate(eventDate)}

) : null} {eventDate ? ( -

{eventDate.slice(16, 33)}

+

+ {" "} + {this.RefinedDay( + new Date(Date.parse(eventDate)).toString() + )} + , + {this.RefinedYear( + new Date(Date.parse(eventDate)).toString() + )} +

) : null} - {isCancelled ? ( + {this.state.isCancelled ? (

CANCELLED

) : { isOnline } ? ( -

Online

+

+ {isOnline ? "Online" : "Offline"} +

) : ( -

{location}

+

{location || "Location"}

)}
@@ -94,7 +121,7 @@ class Popups extends Component { {description ? (

- {description.longDescription} + {description?.longDescription}

) : null} @@ -104,7 +131,9 @@ class Popups extends Component { {rsvpYes ? (

Attending :{" "} - {rsvpYes.length} + + {rsvpYes?.length || 0} +

) : null} @@ -112,7 +141,9 @@ class Popups extends Component { {rsvpYes ? (

Might Attend :{" "} - {rsvpMaybe.length} + + {rsvpMaybe?.length || 0} +

) : null} @@ -120,7 +151,9 @@ class Popups extends Component { {rsvpYes ? (

Not Attending :{" "} - {rsvpNo.length} + + {rsvpNo?.length || 0} +

) : null} @@ -134,7 +167,6 @@ class Popups extends Component { Popups.propTypes = { modalShow: PropTypes.bool.isRequired, - option: PropTypes.string.isRequired, optionValue: PropTypes.any.isRequired, }; diff --git a/src/user/integrations/NameForm.js b/src/user/integrations/NameForm.js index 8711590e..0753cecd 100644 --- a/src/user/integrations/NameForm.js +++ b/src/user/integrations/NameForm.js @@ -1,5 +1,5 @@ import React, {Component} from 'react'; -import {Modal, Button, Form, Row, Col} from 'react-bootstrap'; +import {Modal, Button, Form, Row} from 'react-bootstrap'; import {JitsiMeet} from './Jitsi'; import "./jitsi.scss"; @@ -17,7 +17,7 @@ export class Info extends Component{ params === "user" ? this.setState({ user: event.target.value }) : this.setState({ roomID: event.target.value }); - this.setState({disable: (this.state.roomID == '' || this.state.user == '') ? + this.setState({disable: (this.state.roomID === '' || this.state.user === '') ? true : false }); }; closeJitsi = ()=>this.setState({ diff --git a/src/user/organization/org-contact/OrgContact.js b/src/user/organization/org-contact/OrgContact.js index 57d162c6..5c8ac099 100644 --- a/src/user/organization/org-contact/OrgContact.js +++ b/src/user/organization/org-contact/OrgContact.js @@ -1,13 +1,24 @@ import React, { Component } from "react"; import "./org-contact.scss"; import { Card, Avatar, CardContent } from '@material-ui/core'; +import { connect } from 'react-redux' +import { getOrgProfile } from '../../../actions/orgAction' class OrgContact extends Component { constructor(props) { super(props); this.state = { + website: '', + email: '', + admins: [], + moderators: [] }; } + componentWillReceiveProps(nextProps) { + console.log('org contacts ', nextProps) + const { contactInfo } = nextProps.org?.org + this.setState({website: contactInfo?.website, email: contactInfo?.email }) + } render() { return (
@@ -25,12 +36,12 @@ class OrgContact extends Component {

Website

-

{this.props.website}

+

{this.state.website}

Community

-

Contact

-

{this.props.contactinfo}

+

Community email

+

{this.state.email}

@@ -39,4 +50,10 @@ class OrgContact extends Component { ) } } -export default OrgContact; +// map state to props +const mapStateToProps = (state) => ({ + auth: state.auth, + error: state.error, + org: state.org +}) +export default connect(mapStateToProps, { getOrgProfile })(OrgContact); diff --git a/src/user/organization/org-info/org-info.js b/src/user/organization/org-info/org-info.js index f9c7f61b..9767fa46 100644 --- a/src/user/organization/org-info/org-info.js +++ b/src/user/organization/org-info/org-info.js @@ -3,24 +3,48 @@ import "./org-info.scss"; import { Button } from "react-bootstrap"; import { Avatar } from "@material-ui/core"; import EditInfo from "../popups/EditInfo"; +import { connect } from 'react-redux'; +import { getOrgProfile } from '../../../actions/orgAction' class OrgInfo extends Component { constructor(props) { super(props); this.state = { - editOrg: false + editOrg: false, + orgProfile: {} } } + onEditOrg = () => { console.log('Edit org is clicked!') this.setState({ editOrg: true }) } + closeEditPop = () => { console.log('Closing edit pop'); this.setState({ editOrg: false }) } + componentDidMount() { + console.log('props ', this.props) + // this.props.getOrgProfile() + } + + componentWillReceiveProps(nextProps) { + console.log('orgInfo nextProps', nextProps) + this.setState({ orgProfile: nextProps.org?.org }, () => { + console.log('updating org profile', this.state) + }) + } + render() { + const { orgProfile } = this.state + const { + name, + description, + // contactInfo, + createdAt + } = orgProfile return (
@@ -28,24 +52,22 @@ class OrgInfo extends Component {
-

- CodeUnio - + */}

-

Started 10 years ago

-

584 members

+

Created on: {createdAt || "NA"}

- Where millions of people gather together every day to imagine, - create + {description?.shortDescription || "Short description of org "}

@@ -58,4 +80,11 @@ class OrgInfo extends Component { } } -export default OrgInfo; +// map state to props +const mapStateToProps = (state) => ({ + auth: state.auth, + org: state.org, + error: state.error +}) + +export default connect(mapStateToProps, { getOrgProfile })(OrgInfo); diff --git a/src/user/organization/org-info/org-info.scss b/src/user/organization/org-info/org-info.scss index f5d8832b..46d5a5cf 100644 --- a/src/user/organization/org-info/org-info.scss +++ b/src/user/organization/org-info/org-info.scss @@ -42,6 +42,7 @@ font-weight: 600; margin: 4px 0; line-height: 0%; + padding-bottom: 10px; } .place { font-family: Inter; @@ -58,8 +59,8 @@ font-weight: normal; font-size: 14px; line-height: 17px; - color: #1d2129; + text-align: justify; } .social-icons { display: flex; diff --git a/src/user/organization/organization.js b/src/user/organization/organization.js index ac8480bb..8d419c3a 100644 --- a/src/user/organization/organization.js +++ b/src/user/organization/organization.js @@ -11,6 +11,8 @@ import topBarLoading from "../../placeholderLoading/topBarLoading/topBarLoading" import orgUpdatesLoading from "../../placeholderLoading/orgUpdatesLoading/orgUpdatesLoading"; import contactLoading from "../../placeholderLoading/contactLoading/contactLoading"; import cardLoading from "../../placeholderLoading/cardLoading/cardLoading"; +import { connect } from 'react-redux' +import { getOrgProfile } from '../../actions/orgAction' class Organization extends Component { constructor(props) { @@ -18,16 +20,31 @@ class Organization extends Component { this.state = { org: true, isLoading: true, + orgProfile: {} }; } componentDidMount() { + setTimeout(() => { + this.props.getOrgProfile() + }) setTimeout(() => { this.setState({ isLoading: false }); }, 1000); } + componentWillReceiveProps(nextProps) { + console.log('organization ', nextProps) + this.setState({ orgProfile: nextProps.org?.org }) + } + render() { + const { orgProfile } = this.state + const { + // name, + description, + // contactInfo + } = orgProfile return (
@@ -47,7 +64,7 @@ class Organization extends Component { cardLoading() ) : (
-

Posts

+ {/*

Posts

*/}
About Us
Donuts
@@ -56,11 +73,11 @@ class Organization extends Component {
-
Codeuino
-
{orginfo.question_1}
-

{orginfo.description_1}

-
{orginfo.question_1}
-

{orginfo.description_1}

+
{orgProfile?.name}
+
Short description
+

{description?.shortDescription || "Short details of organization"}

+
About us in details
+

{description?.longDescription || "Long description of the organization"}

@@ -94,5 +111,11 @@ class Organization extends Component { ); } } +// map state to props +const mapStateToProps = (state) => ({ + auth: state.auth, + error: state.error, + org: state.org +}) -export default Organization; +export default connect(mapStateToProps, { getOrgProfile })(Organization); diff --git a/src/user/organization/organization.scss b/src/user/organization/organization.scss index b1b5e0b0..b4890be2 100644 --- a/src/user/organization/organization.scss +++ b/src/user/organization/organization.scss @@ -69,6 +69,15 @@ color: black; font-weight: bold; } + .short__desc, .long__desc { + font-family: Inter; + font-style: normal; + font-weight: normal; + font-size: 14px; + line-height: 17px; + color: #1d2129; + text-align: justify; + } } } .org-updates { diff --git a/src/user/organization/popups/Admins.js b/src/user/organization/popups/Admins.js index cadcc061..103a022a 100644 --- a/src/user/organization/popups/Admins.js +++ b/src/user/organization/popups/Admins.js @@ -1,5 +1,5 @@ import React, { Component } from "react"; -import { Modal, Button, Row, Col, Image, Form } from "react-bootstrap"; +import { Modal, Button, Row, Image, Form } from "react-bootstrap"; import { connect } from 'react-redux' import { removeAdmin } from '../../../actions/orgAction' import logo from "../../../svgs/logo-image.jpg"; @@ -64,6 +64,11 @@ class Admins extends Component { } } + onSearchClick = () => { + const { query } = this.state + this.props.getMember(query) + } + render() { const { onHide, show } = this.props const adminList = [...this.state.admins] @@ -100,14 +105,17 @@ class Admins extends Component {
Administrators
- +
diff --git a/src/user/organization/popups/EditInfo.js b/src/user/organization/popups/EditInfo.js index 2d427faf..7d271516 100644 --- a/src/user/organization/popups/EditInfo.js +++ b/src/user/organization/popups/EditInfo.js @@ -1,4 +1,4 @@ -import React, { useState } from "react"; +import React from "react"; import { Button, Modal, Form, Col } from "react-bootstrap"; import PropTypes from "prop-types"; import UploadImg from '../../../images/upload.jpg' diff --git a/src/user/organization/popups/Members.js b/src/user/organization/popups/Members.js index c2e1f351..e4911ce1 100644 --- a/src/user/organization/popups/Members.js +++ b/src/user/organization/popups/Members.js @@ -1,9 +1,12 @@ import React, { Component } from "react"; -import { Modal, Button, Row, Col, Image, Form } from "react-bootstrap"; +import { Modal, Button, Row, Image, Form } from "react-bootstrap"; import { connect } from 'react-redux'; -import { removeUser } from '../../../actions/usersAction' +import { removeUser, getInviteLink } from '../../../actions/usersAction' import { getMember } from '../../../actions/insightAction' import logo from "../../../svgs/logo-image.jpg"; +import { checkRemoveRight } from '../../dashboard/utils/checkDeleteRights' +import { ToastContainer, toast } from "react-toastify"; +import "react-toastify/dist/ReactToastify.css"; class Members extends Component { constructor(props) { @@ -11,14 +14,18 @@ class Members extends Component { this.state = { text: 'Follow', members: [], - query: '' + query: '', + isAdmin: '', + inviteLink: null } } onRemoveClick = (userId) => { console.log('Removing !', userId); // SEND REQUEST TO REMOVE USER WITH ID = INDEX - this.props.removeUser(userId) + if(this.state.isAdmin) { + this.props.removeUser(userId); + } } onChange = (e) => { @@ -34,10 +41,21 @@ class Members extends Component { onSearchClick = () => { const { query } = this.state; - console.log('') + console.log('query ', query); this.props.getMember(query); } + onGetInviteLink = () => { + console.log('Get invite link clicked!'); + this.props.getInviteLink(); + } + + componentDidMount() { + checkRemoveRight() + ? this.setState({ isAdmin: true }) + : this.setState({ isAdmin: false }) + } + componentWillReceiveProps(nextProps) { console.log('nextProps ', nextProps) const { query } = this.state @@ -49,7 +67,7 @@ class Members extends Component { let allMembers = nextProps.insight.allMembers res = this.mapHelper(allMembers) } - this.setState({ members: res }, () => { + this.setState({ members: res, inviteLink: nextProps.user.inviteLink }, () => { console.log("members ", this.state); }); } @@ -64,8 +82,21 @@ class Members extends Component { return membersInfo } + copyToClipBoard = async (link) => { + try { + await navigator.clipboard.writeText(link); + if(this.state.inviteLink !== null){ + toast.success('Link copied to clipboard!'); + } + } catch (error) { + toast.error('Something went wrong!'); + console.log('error ', error) + } + } + render() { const { onHide, show } = this.props + const { isAdmin, inviteLink } = this.state const membersList = [ ...this.state.members] let members = membersList.map((item) => ( @@ -85,7 +116,10 @@ class Members extends Component { onClick={this.onRemoveClick.bind(this, item._id)} > - {Boolean(item.isRemoved === true) ? (Removed) : (Remove)} + {Boolean(item.isRemoved === true) + ? (Removed) + : isAdmin ? (Remove) : (New!) + }
@@ -112,6 +146,12 @@ class Members extends Component { onChange={this.onChange} onKeyPress={this.onKeyPress} /> + @@ -121,14 +161,17 @@ class Members extends Component {

ADD MEMBER

- Email + Get invite link
- +

or share invite on

@@ -139,6 +182,17 @@ class Members extends Component {
+ ); } @@ -152,4 +206,4 @@ const mapStateToProps = (state) => ({ status: state.status }) -export default connect(mapStateToProps, { removeUser, getMember })(Members); \ No newline at end of file +export default connect(mapStateToProps, { removeUser, getMember, getInviteLink })(Members); \ No newline at end of file diff --git a/src/user/pinned-posts/pinned-posts.js b/src/user/pinned-posts/pinned-posts.js index ce5f0c88..2b48de2c 100644 --- a/src/user/pinned-posts/pinned-posts.js +++ b/src/user/pinned-posts/pinned-posts.js @@ -1,10 +1,10 @@ import React, { Component } from "react"; import "./pinned-posts.scss"; import Navigation from "../dashboard/navigation/navigation"; -import Updates from "../dashboard/updates/updates"; +// import Updates from "../dashboard/updates/updates"; import PinPosts from "../pinned-posts/posts/pinPosts"; import pinnedPostsLoading from "../../placeholderLoading/pinnedPostsLoading/pinnedPostsLoading"; -import orgUpdatesLoading from "../../placeholderLoading/orgUpdatesLoading/orgUpdatesLoading"; +// import orgUpdatesLoading from "../../placeholderLoading/orgUpdatesLoading/orgUpdatesLoading"; class PinnedPosts extends Component { constructor(props) { diff --git a/src/user/pinned-posts/posts/pinPosts.js b/src/user/pinned-posts/posts/pinPosts.js index cc6b1ec4..c8ac8fad 100644 --- a/src/user/pinned-posts/posts/pinPosts.js +++ b/src/user/pinned-posts/posts/pinPosts.js @@ -1,22 +1,35 @@ import React , { useState, useEffect } from 'react'; -import {List, Card, Button, Paper, ListItem, ListItemAvatar, Avatar, ListItemText, ListItemSecondaryAction, IconButton, CardMedia} from '@material-ui/core'; +import { + List, + Card, + Button, + Paper, + ListItem, + ListItemAvatar, + Avatar, + ListItemText, + // ListItemSecondaryAction, + IconButton, + CardMedia +} from '@material-ui/core'; import { makeStyles } from '@material-ui/core/styles'; -import MoreHorizIcon from '@material-ui/icons/MoreHoriz'; +// import MoreHorizIcon from '@material-ui/icons/MoreHoriz'; import ArrowDropUpIcon from '@material-ui/icons/ArrowDropUp'; -import ArrowDropDownIcon from '@material-ui/icons/ArrowDropDown'; +// import ArrowDropDownIcon from '@material-ui/icons/ArrowDropDown'; import ChatBubbleIcon from '@material-ui/icons/ChatBubble'; -import EventNoteIcon from '@material-ui/icons/EventNote'; -import EventIcon from '@material-ui/icons/Event'; -import feed from '../../../jsonData/news-feed'; -import ReplyIcon from '@material-ui/icons/Reply'; +// import EventNoteIcon from '@material-ui/icons/EventNote'; +// import EventIcon from '@material-ui/icons/Event'; +// import feed from '../../../jsonData/news-feed'; +// import ReplyIcon from '@material-ui/icons/Reply'; import { connect } from 'react-redux' import { getEventsCreatedByUser, getProjectCreatedByUser } from '../../../actions/usersAction' import "./posts.scss"; -import { Comment } from '../../dashboard/news-feed/popups/comment'; +import Comment from '../../dashboard/news-feed/popups/comment'; import { withRouter } from 'react-router-dom'; import profileImg from '../../../svgs/evt-creator.svg'; import eventImg from "../../../svgs/event-img-1.svg"; import eventImg2 from "../../../svgs/event-img-2.svg"; +import { getAllPinnedPosts } from '../../../actions/postAction' const styles = makeStyles((theme) => ({ root: { @@ -75,7 +88,7 @@ function PinPosts(props){ const [first, second] = useState('f'); const [showComment, toggle] = useState(false); const [commentId, setCommentId] = useState(''); - const [all, setAll] = useState([]) + // const [all, setAll] = useState([]) const [userEvents, setEvents] = useState([]) const [userPosts, setPosts] = useState([]) const [userProjects, setAllProjects] = useState([]) @@ -83,15 +96,19 @@ function PinPosts(props){ useEffect(() => { console.log('props from PinPosts ', props) if(props.match?.path === '/pinned-posts') { - console.log('fetch all the pinned posts!') + console.log('fetch all the pinned posts!', props) + props.getAllPinnedPosts() + setTimeout(() => { + setPosts(props.posts?.pinnedPosts); + }) } // debugger; if(props.match?.path === '/profile'){ setEvents(props.userEvents) setAllProjects(props.userProjects || []) setPosts(props.userPosts) - let all = [...userEvents, ...userProjects, ...userPosts] - setAll(all) + // let all = [...userEvents, ...userProjects, ...userPosts] + // setAll(all) } }, [props]) @@ -108,7 +125,7 @@ function PinPosts(props){ toggle(!showComment); } - let userProjectsContent = userProjects.map((newsItem) => { + let userProjectsContent = userProjects?.map((newsItem) => { return (
@@ -133,7 +150,7 @@ function PinPosts(props){ -

{newsItem?.createdBy?.name?.firstName + " " + newsItem?.createdBy?.name?.lastName}

+

{newsItem?.createdBy?.name?.firstName + " " + newsItem?.createdBy?.name?.lastName || "No Name"}

{newsItem?.createdAt}
{/* @@ -178,7 +195,7 @@ function PinPosts(props){ ) }) - let userEventsContent = userEvents.map((newsItem, index) => { + let userEventsContent = userEvents?.map((newsItem, index) => { return (
@@ -261,14 +278,14 @@ function PinPosts(props){ ) }); - let userPostsContent = userPosts.map((newsItem, index) => { + let userPostsContent = userPosts?.map((newsItem, index) => { return (
- - + */} @@ -372,7 +389,8 @@ const mapStateToProps = (state) => ({ auth: state.auth, error: state.error, user: state.user, - status: state.status + status: state.status, + posts: state.post }) -export default connect(mapStateToProps , { getEventsCreatedByUser, getProjectCreatedByUser })(withRouter(PinPosts)); \ No newline at end of file +export default connect(mapStateToProps , { getEventsCreatedByUser, getProjectCreatedByUser, getAllPinnedPosts })(withRouter(PinPosts)); \ No newline at end of file diff --git a/src/user/pinned-posts/posts/posts.js b/src/user/pinned-posts/posts/posts.js index 6abaa5d3..4d9f530f 100644 --- a/src/user/pinned-posts/posts/posts.js +++ b/src/user/pinned-posts/posts/posts.js @@ -1,6 +1,6 @@ import React, { Component } from "react"; import "./posts.scss"; -import userIcon2 from "../../../images/gsoc.png"; +import gsoc from "../../../images/gsoc.png"; class Posts extends Component { state = { date: new Date() }; diff --git a/src/user/profile/popups/EditProfile.js b/src/user/profile/popups/EditProfile.js index 90ef3146..7d6ff760 100644 --- a/src/user/profile/popups/EditProfile.js +++ b/src/user/profile/popups/EditProfile.js @@ -27,7 +27,7 @@ class EditProfile extends Component { onSave = (e) => { e.preventDefault(); - const { firstName, lastName, designation, location, website, github, shortDesc, longDesc } = this.state + const { firstName, lastName, designation, location, website, shortDesc, longDesc } = this.state const info = { name: { firstName, @@ -66,7 +66,7 @@ class EditProfile extends Component { render() { const { borderStyle, onHide, show } = this.props - const { firstName, lastName, shortDesc, location, github, linkedIn, fb, designation, website, longDesc } = this.state + const { firstName, lastName, shortDesc, location, designation, website, longDesc } = this.state return ( { - console.log('started following user ', userId) - this.props.followUser(userId) - } + console.log("started following user ", userId); + this.props.followUser(userId); + }; unFollow = (userId) => { - console.log('started unfollowing ', userId) - this.props.unFollowUser(userId) - } + console.log("started unfollowing ", userId); + this.props.unFollowUser(userId); + }; checkFollowing = (userId = 0) => { - let followingArray = this.state.followings.map(follow => follow._id) - let isFollowing = followingArray.includes(userId) ? true : false - console.log('isFollowing ', isFollowing) - return isFollowing - } + let followingArray = this.state.followings.map((follow) => follow._id); + let isFollowing = followingArray.includes(userId) ? true : false; + console.log("isFollowing ", isFollowing); + return isFollowing; + }; onFollowUnFollowClick = (userId, text) => { - console.log('userId text ', userId + " " + text) - if(text === 'Follow') { - this.follow(userId) + console.log("userId text ", userId + " " + text); + if (text === "Follow") { + this.follow(userId); } - if(text === 'UnFollow') { - this.unFollow(userId) + if (text === "UnFollow") { + this.unFollow(userId); } - } + }; + + onChange = (e) => { + this.setState({ query: e.target.value }); + }; + + // onKeyPress = (e) => { + // console.log("event ", e.key); + // if (e.key === "Enter") { + // this.onSearchClick(); + // } + // }; + + // onSearchClick = () => { + // const { query } = this.state; + // console.log("query ", query); + // this.props.getMember(query); + // }; componentWillReceiveProps(nextProps) { - console.log('nextProps ', nextProps) - this.setState({ followings: nextProps.followings }) + console.log("nextProps ", nextProps); + this.setState({ followings: nextProps.followings }); } render() { - const { borderStyle, onHide, followers, followings, show } = this.props - let followersList = [] - - if(followers && followers.length > 0) { + const { borderStyle, onHide, followers, show } = this.props; + // const { query } = this.state; + let followersList = []; + + if (followers && followers.length > 0) { for (const follower in followers) { - let tempObj = {} - tempObj.name = followers[follower].name.firstName + ' ' + followers[follower].name.lastName; - tempObj.desg = followers[follower].info.about.designation || 'NA'; - tempObj._id = followers[follower]._id - this.checkFollowing(tempObj._id) ? tempObj.text = 'UnFollow' : tempObj.text = 'Follow' - followersList.push(tempObj) + let tempObj = {}; + tempObj.name = + followers[follower].name.firstName + + " " + + followers[follower].name.lastName; + tempObj.desg = followers[follower].info.about.designation || "NA"; + tempObj._id = followers[follower]._id; + this.checkFollowing(tempObj._id) + ? (tempObj.text = "UnFollow") + : (tempObj.text = "Follow"); + followersList.push(tempObj); } } - let followersContent = followersList.map((item) => (
- I + I
{item.name} - - {item.desg} - + {item.desg}
-
-
- )) + + )); return (
Followers
- + {/* + */}
diff --git a/src/user/profile/profile.js b/src/user/profile/profile.js index eb2e044d..bcdbac2e 100644 --- a/src/user/profile/profile.js +++ b/src/user/profile/profile.js @@ -4,9 +4,10 @@ import Navigation from "../dashboard/navigation/navigation"; import UserInfo from "./user-info/user-info"; import Portfolio from "../dashboard/portfolio/portfolio"; import PinPosts from "../pinned-posts/posts/pinPosts"; -import Updates from "../dashboard/updates/updates"; +// import Updates from "../dashboard/updates/updates"; import { connect } from 'react-redux' import { getProfile, getEventsCreatedByUser, getProjectCreatedByUser, getPostsCreatedByUser } from '../../actions/usersAction' +import { getAllPinnedPosts } from '../../actions/postAction' class Profile extends Component { constructor(props) { @@ -17,7 +18,8 @@ class Profile extends Component { all: [], userEvents: [], userProjects: [], - userPosts: [] + userPosts: [], + pinnedPosts: [] }; } @@ -38,15 +40,20 @@ class Profile extends Component { setTimeout(() => { this.props.getProjectCreatedByUser(); }); + setTimeout(() => { + this.props.getAllPinnedPosts() + }) } } componentWillReceiveProps(nextProps) { console.log("profile nextProps ", nextProps); const { userEvents, userProjects, userPosts } = nextProps.user; + const { pinnedPosts } = nextProps.posts console.log("userEvents ", userEvents); console.log("userProjects ", userProjects); console.log("userPosts ", userPosts); + console.log("pinnedPosts ", pinnedPosts) let all = [...userEvents, ...userProjects, ...userPosts] console.log("all ", all); this.setState({ @@ -54,12 +61,13 @@ class Profile extends Component { userEvents: userEvents, userProjects: userProjects, userPosts: userPosts, + pinnedPosts: pinnedPosts, all: all, }); } render() { - const { userProfile, all, userEvents, userProjects, userPosts } = this.state; + const { userProfile, all, userEvents, userProjects, userPosts, pinnedPosts } = this.state; return (
@@ -72,7 +80,13 @@ class Profile extends Component {
- +
@@ -96,5 +110,6 @@ export default connect(mapStateToProps, { getProfile, getEventsCreatedByUser, getProjectCreatedByUser, - getPostsCreatedByUser + getPostsCreatedByUser, + getAllPinnedPosts })(Profile); diff --git a/src/user/profile/user-info/user-info.js b/src/user/profile/user-info/user-info.js index 70b79649..a095ab1e 100644 --- a/src/user/profile/user-info/user-info.js +++ b/src/user/profile/user-info/user-info.js @@ -3,7 +3,7 @@ import "./user-info.scss"; import { Button } from "react-bootstrap"; import { Avatar } from "@material-ui/core"; import EditProfile from "./../popups/EditProfile"; -import Followers from "../popups/Followers"; +// import Followers from "../popups/Followers"; class UserInfo extends Component { constructor(props) { @@ -33,15 +33,15 @@ class UserInfo extends Component { } render() { - const { designation, website, location, shortDesc, name } = this.state + const { designation, location, shortDesc, name } = this.state let cancel = () => this.setState({ editProfile: false, }); - let cancelf = () => - this.setState({ - followersList: false, - }); + // let cancelf = () => + // this.setState({ + // followersList: false, + // }); return (
diff --git a/src/user/projects/popups/delete-project.js b/src/user/projects/popups/delete-project.js index b7c757bb..9c986565 100644 --- a/src/user/projects/popups/delete-project.js +++ b/src/user/projects/popups/delete-project.js @@ -1,11 +1,20 @@ import React, { Component } from "react"; import { Modal, Button } from "react-bootstrap"; +import { connect } from 'react-redux' +import { deleteProjectById } from '../../../actions/projectAction' +import { withRouter } from 'react-router-dom' -export class DeleteProject extends Component { +class DeleteProject extends Component { + onRemove = () => { + console.log('deleting project', this.props.projectId); + this.props.deleteProjectById(this.props.projectId, this.props.history); + } render() { + const { show, onHide } = this.props return ( @@ -15,10 +24,20 @@ export class DeleteProject extends Component { - - + + ); } } + +// map state to props +const mapStateToProps = (state) => ({ + auth: state.auth, + error: state.error, + project: state.project +}) + +export default connect(mapStateToProps, { deleteProjectById })(withRouter(DeleteProject)); + diff --git a/src/user/projects/popups/edit-project.js b/src/user/projects/popups/edit-project.js index e5a0fa0a..79f4a1c3 100644 --- a/src/user/projects/popups/edit-project.js +++ b/src/user/projects/popups/edit-project.js @@ -1,43 +1,71 @@ import React, { Component } from "react"; import { Modal, Button, Row, Col, Form } from "react-bootstrap"; -export class EditProject extends Component { +import { connect } from 'react-redux' +import { updateProject } from '../../../actions/projectAction' + +class EditProject extends Component { constructor(props) { super(props); this.state = { - Proj_name: "", - version: "", - short_des: "", - long_des: "", - github_link: "", - bitbucket_link: "", - host_link: "", - img_link: "", + projectName: '', + github_link: '', + bitbucket_link: '', + version: '', + long_des: '', + short_des: '', + img_link: '', + projectId: '' }; - this.trigger = 0; - this.onChange = this.onChange.bind(this); - this.onSubmit = this.onSubmit.bind(this); } componentWillReceiveProps(nextProps) { - if (this.trigger < 1) this.setState({ ...nextProps.data }); - this.trigger = this.trigger + 1; + console.log('edit nextProps ',nextProps); + const { projectName, description, links, version, _id, imgUrl } = nextProps.project.singleProject + this.setState({ + projectName: projectName, + long_des: description?.long, + short_des: description?.short, + github_link: links[0]?.githubLink || '', + bitbucket_link: links[0]?.bitbucketLink || '', + version: version || '', + img_link: imgUrl || '', + projectId: _id + },() => { + console.log('edit project ', this.state) + }); } - onChange(e) { + onChange = (e) => { this.setState({ [e.target.name]: e.target.value }); } - onSubmit(e) { - e.preventDefault(); - const EditProject = this.state; - - console.log("Edited Project", EditProject); + onUpdateClick = (e) => { + e.preventDefault() + const { projectName, projectId, github_link, bitbucket_link, version, long_des, short_des, img_link} = this.state + const info = { + projectName: projectName, + description: { + long: long_des, + short: short_des + }, + version: version, + links: [{ + githubLink: github_link, + bitbucketLink: bitbucket_link + }], + imgUrl: img_link + } + console.log('updating project ', info) + this.props.updateProject(projectId, info) } render() { + const { projectName, github_link, bitbucket_link, version, short_des, long_des, img_link } = this.state + const { show, onHide } = this.props return ( Version @@ -81,7 +109,7 @@ export class EditProject extends Component { className="form-input" as="textarea" name="short_des" - value={this.state.short_des} + value={short_des} onChange={this.onChange} placeholder="Write a brief info about the project.." size="sm" @@ -93,7 +121,7 @@ export class EditProject extends Component { className="form-input" as="textarea" name="long_des" - value={this.state.long_des} + value={long_des} onChange={this.onChange} placeholder="Whats the project is about.." size="sm" @@ -107,9 +135,9 @@ export class EditProject extends Component { className="form-input" type="text" name="github_link" - value={this.state.github_link} + value={github_link} onChange={this.onChange} - placeholder="GitHub Profile" + placeholder="GitHub Link" size="sm" /> @@ -119,33 +147,21 @@ export class EditProject extends Component { className="form-input" type="text" name="bitbucket_link" - value={this.state.bitbucket_link} + value={bitbucket_link} onChange={this.onChange} - placeholder="BitBucket Profile" + placeholder="BitBucket Link" size="sm" /> - - Hosted URL - - Image URL
-
@@ -171,3 +187,13 @@ export class EditProject extends Component { ); } } + +// map state to props +const mapStateToProps = (state) => ({ + auth: state.auth, + error: state.error, + project: state.project +}) + +export default connect(mapStateToProps, { updateProject })(EditProject); + diff --git a/src/user/projects/proj-info/proj-info.js b/src/user/projects/proj-info/proj-info.js index f0925a55..41a4045f 100644 --- a/src/user/projects/proj-info/proj-info.js +++ b/src/user/projects/proj-info/proj-info.js @@ -1,5 +1,4 @@ import React, { Component } from "react"; -import Project_list from "../../../jsonData/projects"; import EditIcon from '@material-ui/icons/Edit'; import GitHubIcon from '@material-ui/icons/GitHub'; import LanguageIcon from '@material-ui/icons/Language'; @@ -8,11 +7,14 @@ import { Card, Button, Badge, Col, Row } from "react-bootstrap"; import "./proj-info.scss"; import ArrowBackIcon from "@material-ui/icons/ArrowBack"; import proj_img from "../../../images/project.png"; -import user_img from "../../../images/userIcon.jpg"; -import { EditProject } from "../popups/edit-project"; +import EditProject from "../popups/edit-project"; import DeleteIcon from "@material-ui/icons/Delete"; -import { DeleteProject } from "../popups/delete-project"; -import { makeStyles,Grid, Fab, CardActionArea, CardActions, CardContent, CardMedia, Typography} from "@material-ui/core"; +import DeleteProject from "../popups/delete-project"; +import { makeStyles,Grid, Fab} from "@material-ui/core"; +// import { CardActionArea, CardActions, CardContent, CardMedia, Typography } from "@material-ui/core" +import { connect } from 'react-redux' +import { getProjectById } from '../../../actions/projectAction' +import { checkDeleteRights } from '../../dashboard/utils/checkDeleteRights' class ProjInfo extends Component { @@ -20,21 +22,47 @@ class ProjInfo extends Component { super(props); this.state = { proj: true, - editproject: false, - project_info: {}, + editProject: false, + projectInfo: {}, + deleteProject: false, + githubLink: '', + bitBucketLink: '', + techStacks: [] }; } + componentDidMount() { + console.log('project info mounted ',this.props) + // fetch the data from db + setTimeout(() => { + this.props.getProjectById(this.props.match.params.id) + }) + } + + componentWillReceiveProps(nextProps) { + console.log('nextProps ', nextProps) + const { singleProject } = nextProps.project + this.setState({ projectInfo: singleProject, techStacks: singleProject.techStacks }, () => { + console.log('updating project info state ', this.state) + }) + const { links } = singleProject + this.setState({ githubLink: links[0]?.githubLink, bitBucketLink: links[0]?.bitBucketLink }) + } + render() { - let cancel = () => + const { projectInfo, editProject, proj, deleteProject, githubLink, bitBucketLink, techStacks } = this.state + + let cancel = () =>{ this.setState({ - editproject: false, - profile_info:{} + editProject: false, }); - let cancel_del = () => + } + + let cancel_del = () => { this.setState({ - deleteproject: false, - }); + deleteProject: false, + }) + } const useStyles = makeStyles((theme) => ({ root: { @@ -42,51 +70,56 @@ class ProjInfo extends Component { }, })); - const useStyles2 = makeStyles({ - root: { - maxWidth: 345, - marginTop: "20px", - }, - }); + // const useStyles2 = makeStyles({ + // root: { + // maxWidth: 345, + // marginTop: "20px", + // }, + // }); - let project_info = Project_list.filter( - (x) => x._id === this.props.match.params.id - ); - let maintainers = project_info[0].maintainers.map((item) => ( - - - - - - - - {item} - - - Software developer in Codeuino - - - - - - - - - )); + // let maintainers = projectInfo?.maintainers.map((item) => ( + // + // + // + // + + // + // + // {item} + // + // + // Software developer in Codeuino + // + // + // + // + // + // + // + // + // )); + + let variant = ["primary", "secondary", "success", "danger", "warning", "light", "dark"] + const techBadge = techStacks?.map((techs, index) => ( + <> + {techs}{" "} + + )) return (
- +
@@ -98,109 +131,91 @@ class ProjInfo extends Component {
-

{project_info[0].Proj_name}

+

{projectInfo?.projectName}

- Version {project_info[0].version} + Version {projectInfo?.version || "1.0.0"} {" "} - {" "} - {" "} - {" "} + {checkDeleteRights(projectInfo.createdBy?._id) ? ( + + ) : null } - + {checkDeleteRights(projectInfo.createdBy?._id) ? ( + + ) : null}

- - React - {" "} - - Passport - {" "} - - Nodejs - {" "} - - Bootstrap - {" "} -

- - Mongoose - {" "} - - JWT - {" "} - - Material-ui - {" "} - - Redux - -
+ {techBadge} +

- Created At: {project_info[0].createAt}{" "} + Created At: {projectInfo?.createdAt}{" "}

-

{project_info[0].short_des}

-

Updated At: {project_info[0].updatedAt}

- - +

Updated At: {projectInfo?.updatedAt}

+

{projectInfo.description?.short || "Short description"}

-

About the Project

+

Project Details


- {project_info[0].long_des} + {projectInfo.description?.long || "Long description"}

- + {/*

Maintainers


-
+
*/}
- {maintainers} + {/* {maintainers} */}
@@ -209,4 +224,11 @@ class ProjInfo extends Component { } } -export default ProjInfo; +// map state to props +const mapStateToProps = (state) => ({ + auth: state.auth, + error: state.error, + project: state.project +}) + +export default connect(mapStateToProps, { getProjectById })(ProjInfo); diff --git a/src/user/projects/proj-info/proj-info.scss b/src/user/projects/proj-info/proj-info.scss index 0781ed03..376389dc 100644 --- a/src/user/projects/proj-info/proj-info.scss +++ b/src/user/projects/proj-info/proj-info.scss @@ -9,29 +9,29 @@ } .proj_img{ - height:20rem; - width:auto; + height:15rem; + margin-left: 1vw; + max-width: 23vw; + max-height: 42vh; + height: 39vh; } -.img { - height:20rem; - width:auto; -} - - .project-info { flex: 1; padding: 10px 14px; h1 { - color: #0069d9; + color: #2D2D2D; font-size: 40px; - font-weight: bold; + font-weight: 500; margin: 0; padding: 0; } .createAt{ - color: #2c3e50; + font-family: Inter; + font-style: normal; + font-weight: normal; + color: #2D2D2D; font-size: 12px; margin: 4px 0; padding: 0; @@ -40,53 +40,70 @@ margin-top: 3vh; } .short_des { - color: #748391; + font-family: Inter; + font-style: normal; + font-weight: normal; + color: #2D2D2D; font-size: 18px; - font-weight: bold; + font-weight: 500; margin: 4px 0; padding: 0; + text-align: justify; + max-width: 80%; } .place { - color: #2c3e50; + font-family: Inter; + font-style: normal; + font-weight: normal; + color: #2D2D2D; font-size: 12px; margin: 4px 0; padding: 0; + margin-bottom: 5%; } .desc { - color: #5d5d5d; - font-size: 14px; - margin: 0; - padding: 0; + font-family: Inter; + font-style: normal; + font-weight: normal; + font-size: 1.5em; + line-height: 1.3em; + color: #2D2D2D; + text-align: justify; + max-width: 83%; } } .description{ h1{ - color: #0069d9; - font-size: 30px; + font-family: Inter; + font-style: normal; + color: #2D2D2D; + font-size: 27px; margin: 0; - font-weight: bold; + font-weight: 500; padding: 0; - text-align: center; + text-align: left; + margin-left: 2%; } .desc { - color: #5d5d5d; - font-size: 14px; - margin: auto; - font-weight: 100; - padding: 20px; + font-family: Inter; + font-style: normal; + font-weight: normal; + font-size: 1.2em; + line-height: 1.3em; + color: #2D2D2D; + margin-left: 2%; + max-width: 83%; } - - - margin-top: 2vh; + margin-top: 5vh; } .maintainers{ h1{ - color: #0069d9; + color: #2D2D2D; font-size: 30px; font-weight: bold; margin: 0; diff --git a/src/user/projects/projects.js b/src/user/projects/projects.js index e9c831e0..1ae4da1a 100644 --- a/src/user/projects/projects.js +++ b/src/user/projects/projects.js @@ -1,22 +1,40 @@ import React, { Component } from "react"; import "./projects.scss"; import Navigation from "../dashboard/navigation/navigation"; -import Project_list from "../../jsonData/projects"; +// import Project_list from "../../jsonData/projects"; import { makeStyles,Grid , Card, CardActionArea, CardActions, CardContent, CardMedia, Typography} from "@material-ui/core"; import { Button } from "react-bootstrap"; -import Popups from "../../common/Popups"; - +// import Popups from "../../common/Popups"; +import { connect } from 'react-redux' +import { createProject, getAllProjects } from '../../actions/projectAction' +import projectImage from '../../images/project.png' class Projects extends Component { constructor(props) { super(props); this.state = { proj: true, - deleteproject: false + deleteproject: false, + allProjects: [] }; } + componentDidMount() { + setTimeout(() => { + this.props.getAllProjects(); + }) + } + + componentWillReceiveProps(nextProps) { + console.log('project ', nextProps) + const { allProjects } = nextProps.project + this.setState({ allProjects: allProjects }, () => { + console.log('projects state ', this.state) + }) + } + render() { + const { allProjects } = this.state const useStyles = makeStyles((theme) => ({ root: { flexGrow: 1, @@ -35,21 +53,21 @@ class Projects extends Component { }, }); - let Projects = Project_list.map((Item) => ( - + let Projects = allProjects.map((Item, index) => ( + - {Item.Proj_name} + {Item.projectName || "Project Name"} - - {Item.short_des} + + {Item.description?.shortDescription || "Short description of the project"} @@ -68,20 +86,28 @@ class Projects extends Component {
+

All Projects

- + {Projects}
- + /> */}
); } } -export default Projects; +// map state to props +const mapStateToProps = (state) => ({ + auth: state.auth, + error: state.error, + project: state.project +}) + +export default connect(mapStateToProps, { createProject, getAllProjects })(Projects); diff --git a/src/user/projects/projects.scss b/src/user/projects/projects.scss index 045aab75..e71ec7cd 100644 --- a/src/user/projects/projects.scss +++ b/src/user/projects/projects.scss @@ -8,13 +8,40 @@ } .projects { - margin-top: 2vh; + margin-top: 5vh; + margin-left: 4vw; + margin-right: 6vw; + p { + font-family: Inter; + font-style: normal; + font-weight: normal; + font-size: 1.5em; + line-height: 1.3em; + color: #2D2D2D; + } + #project_header { + font-family: Inter; + font-style: normal; + font-weight: normal; + font-size: 1.5em; + line-height: 1.3em; + color: #2D2D2D; + } + + .card__container{ + max-width: 33.33%; + } + + .MuiCard-root { + overflow: hidden; + height: 42vh; + } img{ - height: 20rem; + height: 10rem; width:auto; + object-fit: cover; } - .create{ position:fixed; z-index: 2; @@ -26,5 +53,22 @@ color:#1A73E8; } + .short-des { + text-align: justify; + font-family: Inter; + font-style: normal; + font-weight: normal; + font-size: 1em; + line-height: 1.3em; + color: #2D2D2D; + /* white-space: nowrap; */ + max-width: 259px; + overflow: hidden; + text-overflow: ellipsis; + display: -webkit-box; + -webkit-line-clamp: 3; + -webkit-box-orient: vertical; + } + } } \ No newline at end of file diff --git a/src/user/proposals/AdminProposalDashboard/DashboardContent/DashboardContent.js b/src/user/proposals/AdminProposalDashboard/DashboardContent/DashboardContent.js index b1d88689..60f9dda1 100644 --- a/src/user/proposals/AdminProposalDashboard/DashboardContent/DashboardContent.js +++ b/src/user/proposals/AdminProposalDashboard/DashboardContent/DashboardContent.js @@ -1,5 +1,5 @@ import React, { Component } from "react"; -import { Button, Form, Col, Image } from "react-bootstrap"; +import { Button, Form, Image } from "react-bootstrap"; import "./DashboardContent.scss"; import userIcon2 from "../../../../images/userIcon2.jpg"; diff --git a/src/user/proposals/ProposalDiscussion/DiscussionContent/DiscussionComments/DiscussionComments.js b/src/user/proposals/ProposalDiscussion/DiscussionContent/DiscussionComments/DiscussionComments.js index cfa35155..df121134 100644 --- a/src/user/proposals/ProposalDiscussion/DiscussionContent/DiscussionComments/DiscussionComments.js +++ b/src/user/proposals/ProposalDiscussion/DiscussionContent/DiscussionComments/DiscussionComments.js @@ -1,5 +1,5 @@ import React, { Component } from "react"; -import userIcon2 from "../../../../../images/userIcon2.jpg"; +// import userIcon2 from "../../../../../images/userIcon2.jpg"; import { Form, ListGroup } from "react-bootstrap"; import "./DiscussionComments.scss"; diff --git a/src/user/proposals/ProposalDiscussion/DiscussionContent/DiscussionContent.js b/src/user/proposals/ProposalDiscussion/DiscussionContent/DiscussionContent.js index 66248bb0..f9df6d1b 100644 --- a/src/user/proposals/ProposalDiscussion/DiscussionContent/DiscussionContent.js +++ b/src/user/proposals/ProposalDiscussion/DiscussionContent/DiscussionContent.js @@ -1,6 +1,6 @@ import React, { Component } from "react"; import "./DiscussionContent.scss"; -import { Button, Container, Row, Col, Image, ListGroup } from "react-bootstrap"; +import { Button, Row, Image, ListGroup } from "react-bootstrap"; import DiscussionComments from "./DiscussionComments/DiscussionComments"; import eventImg from "../../../../svgs/event-img-1.svg"; import userIcon2 from "../../../../images/userIcon2.jpg"; diff --git a/src/user/proposals/UserProposalDashboard/DashboardContent/DashboardContent.js b/src/user/proposals/UserProposalDashboard/DashboardContent/DashboardContent.js index 9fd70fc8..032cc2b2 100644 --- a/src/user/proposals/UserProposalDashboard/DashboardContent/DashboardContent.js +++ b/src/user/proposals/UserProposalDashboard/DashboardContent/DashboardContent.js @@ -1,5 +1,5 @@ import React, { Component } from "react"; -import { Button, Form, Col, Image } from "react-bootstrap"; +import { Button, Form, Image } from "react-bootstrap"; import "./DashboardContent.scss"; import userIcon2 from "../../../../images/userIcon2.jpg"; diff --git a/src/user/setup/Setup.js b/src/user/setup/Setup.js index 6f44cb71..4b1d3599 100644 --- a/src/user/setup/Setup.js +++ b/src/user/setup/Setup.js @@ -57,7 +57,7 @@ class Setup extends Component { onFinish = () => { console.log('Finish message from setup page!', this.state); - const { communityName, shortDesc, longDesc, email, website, chatPlatform, color } = this.state + const { communityName, shortDesc, longDesc, email, website, chatPlatform } = this.state const orgObj = { name: communityName, description: { @@ -77,7 +77,7 @@ class Setup extends Component { componentWillReceiveProps(nextProps) { const { msg } = nextProps.error; - if (msg == null || msg == undefined) { + if (msg == null || msg === undefined) { window.location.href = "/dashboard"; } else { this.setState({ error: msg }); diff --git a/src/utils/SVGIcon.js b/src/utils/SVGIcon.js index 9c22e9f5..92588610 100644 --- a/src/utils/SVGIcon.js +++ b/src/utils/SVGIcon.js @@ -41,18 +41,18 @@ const getPath = (name, props) => { ); case "Pinned Posts": return ( ); @@ -61,7 +61,7 @@ const getPath = (name, props) => { ); @@ -70,7 +70,7 @@ const getPath = (name, props) => { ); @@ -79,7 +79,7 @@ const getPath = (name, props) => { ); @@ -147,20 +147,20 @@ const getPath = (name, props) => { return ( <> {