From d069e5639776de30d4af80fa4d7a46696211c656 Mon Sep 17 00:00:00 2001 From: QkoSad Date: Fri, 5 May 2023 23:10:06 +0300 Subject: [PATCH] Fixing after react update --- client/package.json | 8 ++ client/src/App.css | 10 +- client/src/App.js | 37 ++++++++ client/src/actions/alert.js | 6 +- client/src/actions/auth.js | 4 + client/src/components/.DS_Store | Bin 0 -> 6148 bytes client/src/components/auth/Register.js | 7 ++ client/src/components/dashboard/Dashboard.js | 23 +++++ .../components/dashboard/DashboardActions.js | 6 +- client/src/components/dashboard/Education.js | 6 +- client/src/components/dashboard/Experience.js | 9 +- client/src/components/layout/Alert.js | 6 +- client/src/components/layout/Landing.js | 30 +++++- client/src/components/layout/NotFound.js | 6 +- client/src/components/layout/Spinner.js | 6 +- client/src/components/post/CommentForm.js | 6 +- client/src/components/post/CommentItem.js | 6 +- client/src/components/post/Post.js | 6 +- client/src/components/posts/PostForm.js | 6 +- client/src/components/posts/PostItem.js | 53 ++++++++++- client/src/components/posts/Posts.js | 6 +- .../components/profile-forms/AddEducation.js | 10 +- .../components/profile-forms/AddExperience.js | 10 +- .../components/profile-forms/ProfileForm.js | 14 ++- client/src/components/profile/Profile.js | 8 ++ client/src/components/profile/ProfileAbout.js | 6 +- .../components/profile/ProfileEducation.js | 6 +- .../components/profile/ProfileExperience.js | 6 +- .../src/components/profile/ProfileGithub.js | 6 +- client/src/components/profile/ProfileTop.js | 6 +- client/src/components/profiles/ProfileItem.js | 6 +- client/src/components/profiles/Profiles.js | 51 ++++++++++ client/src/components/routing/PrivateRoute.js | 6 +- client/src/index.js | 10 +- client/src/reducers/alert.js | 6 +- client/src/reducers/auth.js | 6 +- client/src/reducers/index.js | 6 +- client/src/reducers/post.js | 87 +++++++++++++++++- client/src/reducers/profile.js | 33 +++++++ client/src/store.js | 6 +- client/src/utils/api.js | 14 +++ client/src/utils/formatDate.js | 3 + client/src/utils/setAuthToken.js | 14 +++ package.json | 4 + server.js | 10 ++ 45 files changed, 550 insertions(+), 31 deletions(-) create mode 100644 client/src/components/.DS_Store diff --git a/client/package.json b/client/package.json index 1d8fe12..ea6cddb 100644 --- a/client/package.json +++ b/client/package.json @@ -20,7 +20,11 @@ "web-vitals": "^2.1.4" }, "scripts": { +<<<<<<< HEAD + "start": "react-scripts start --openssl-legacy-provider start", +======= "start": "react-scripts start", +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb "build": "react-scripts build", "test": "react-scripts test", "eject": "react-scripts eject" @@ -43,5 +47,9 @@ "last 1 safari version" ] }, +<<<<<<< HEAD + "proxy":"http://localhost:5000" +======= "proxy":"http://localhost:5000/" +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb } diff --git a/client/src/App.css b/client/src/App.css index 6beee45..91e16d6 100644 --- a/client/src/App.css +++ b/client/src/App.css @@ -333,7 +333,11 @@ button { /* Landing Page */ .landing { position: relative; +<<<<<<< HEAD + background: url('./img/showcase.jpg') no-repeat center center/cover; +======= background: url('./img/vimCheatSheet.jpg') no-repeat center center/cover; +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb height: 100vh; } @@ -581,4 +585,8 @@ button { top: 4rem; right: 2rem; display: inline-block; -} \ No newline at end of file +<<<<<<< HEAD +} +======= +} +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb diff --git a/client/src/App.js b/client/src/App.js index cf05ce9..4397cd2 100644 --- a/client/src/App.js +++ b/client/src/App.js @@ -1,3 +1,31 @@ +<<<<<<< HEAD +import React, { useEffect } from 'react'; +import { BrowserRouter as Router, Route, Routes } from 'react-router-dom'; +import Navbar from './components/layout/Navbar'; +import Landing from './components/layout/Landing'; +import Register from './components/auth/Register'; +import Login from './components/auth/Login'; +import Alert from './components/layout/Alert'; +import Dashboard from './components/dashboard/Dashboard'; +import ProfileForm from './components/profile-forms/ProfileForm'; +import AddExperience from './components/profile-forms/AddExperience'; +import AddEducation from './components/profile-forms/AddEducation'; +import Profiles from './components/profiles/Profiles'; +import Profile from './components/profile/Profile'; +import Posts from './components/posts/Posts'; +import Post from './components/post/Post'; +import NotFound from './components/layout/NotFound'; +import PrivateRoute from './components/routing/PrivateRoute'; +import { LOGOUT } from './actions/types'; + +// Redux +import { Provider } from 'react-redux'; +import store from './store'; +import { loadUser } from './actions/auth'; +import setAuthToken from './utils/setAuthToken'; + +import './App.css'; +======= import React, { useEffect } from "react"; import { BrowserRouter as Router, Route, Routes } from "react-router-dom"; import Navbar from "./components/layout/Navbar"; @@ -24,6 +52,7 @@ import { loadUser } from "./actions/auth"; import setAuthToken from "./utils/setAuthToken"; import "./App.css"; +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb const App = () => { useEffect(() => { @@ -37,7 +66,11 @@ const App = () => { store.dispatch(loadUser()); // log user out from all tabs if they log out in one tab +<<<<<<< HEAD + window.addEventListener('storage', () => { +======= window.addEventListener("storage", () => { +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb if (!localStorage.token) store.dispatch({ type: LOGOUT }); }); }, []); @@ -52,7 +85,11 @@ const App = () => { } /> } /> } /> +<<<<<<< HEAD + } /> +======= } /> +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb } diff --git a/client/src/actions/alert.js b/client/src/actions/alert.js index 256f75b..43fec4a 100644 --- a/client/src/actions/alert.js +++ b/client/src/actions/alert.js @@ -9,4 +9,8 @@ export const setAlert = (msg, alertType, timeout = 5000) => dispatch => { }); setTimeout(() => dispatch({ type: REMOVE_ALERT, payload: id }), timeout); -}; \ No newline at end of file +<<<<<<< HEAD +}; +======= +}; +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb diff --git a/client/src/actions/auth.js b/client/src/actions/auth.js index 74a933a..5341e64 100644 --- a/client/src/actions/auth.js +++ b/client/src/actions/auth.js @@ -63,6 +63,10 @@ export const login = (email, password) => async (dispatch) => { try { const res = await api.post("/auth", body); +<<<<<<< HEAD + console.log(res) +======= +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb dispatch({ type: LOGIN_SUCCESS, payload: res.data, diff --git a/client/src/components/.DS_Store b/client/src/components/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..1f3b78df8ecd1810caa046638daa8c2d0bc0f87f GIT binary patch literal 6148 zcmZQzU|@7AO)+F(5MW?n;9!8zOq>i@0Z1N%F(jFwBJ3dZKxTO6TPyEz0PF)!h7^WGhGK>ch9ri3hD3%Uh7>d%E75eY zG2}2LGE_3;gUm-&%P5XdZBlu00W>9@N-D_7EG{uHxX#GL%)-jX&cVsS$-&DJ8=R3} z9$b=GQd;bkSQHK71tgYaBth9B`T03;c4AUkW@>r7fQWN`UP)qRUTP6Yd2nV*YEoiR zOn7EqN`ARheraAxG1wfa1jruFcmc`kY7-L!9R(u`lUf~xYC}T;+{&uzn%cTq;80>o{JeBX{$b!{C}1dJ$Y)4n z$YjW2NM+DvNMp!nC}PNEC`Jpr&uC%C4%P>X!%T)ehIBO5t!S!Y?ir;=Ltr!nMs5f| z%P9`-ksAb~J|7K%(Gb890-*9i0opckfYJ>R8YIQQ$iM*Z0x&W#u)vI91oZ>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb const Register = ({ setAlert, register, isAuthenticated }) => { const [formData, setFormData] = useState({ diff --git a/client/src/components/dashboard/Dashboard.js b/client/src/components/dashboard/Dashboard.js index 24461d5..0bd838d 100644 --- a/client/src/components/dashboard/Dashboard.js +++ b/client/src/components/dashboard/Dashboard.js @@ -1,3 +1,13 @@ +<<<<<<< HEAD +import React, { useEffect } from 'react'; +import { Link } from 'react-router-dom'; +import PropTypes from 'prop-types'; +import { connect } from 'react-redux'; +import DashboardActions from './DashboardActions'; +import Experience from './Experience'; +import Education from './Education'; +import { getCurrentProfile, deleteAccount } from '../../actions/profile'; +======= import React, { useEffect } from "react"; import { Link } from "react-router-dom"; import PropTypes from "prop-types"; @@ -6,12 +16,17 @@ import DashboardActions from "./DashboardActions"; import Experience from "./Experience"; import Education from "./Education"; import { getCurrentProfile, deleteAccount } from "../../actions/profile"; +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb const Dashboard = ({ getCurrentProfile, deleteAccount, auth: { user }, +<<<<<<< HEAD + profile: { profile } +======= profile: { profile }, +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb }) => { useEffect(() => { getCurrentProfile(); @@ -51,12 +66,20 @@ Dashboard.propTypes = { getCurrentProfile: PropTypes.func.isRequired, deleteAccount: PropTypes.func.isRequired, auth: PropTypes.object.isRequired, +<<<<<<< HEAD + profile: PropTypes.object.isRequired +======= profile: PropTypes.object.isRequired, +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb }; const mapStateToProps = (state) => ({ auth: state.auth, +<<<<<<< HEAD + profile: state.profile +======= profile: state.profile, +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb }); export default connect(mapStateToProps, { getCurrentProfile, deleteAccount })( diff --git a/client/src/components/dashboard/DashboardActions.js b/client/src/components/dashboard/DashboardActions.js index 5332065..a9961be 100644 --- a/client/src/components/dashboard/DashboardActions.js +++ b/client/src/components/dashboard/DashboardActions.js @@ -17,4 +17,8 @@ const DashboardActions = () => { ); }; -export default DashboardActions; \ No newline at end of file +<<<<<<< HEAD +export default DashboardActions; +======= +export default DashboardActions; +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb diff --git a/client/src/components/dashboard/Education.js b/client/src/components/dashboard/Education.js index 1c6a0e1..57a75fa 100644 --- a/client/src/components/dashboard/Education.js +++ b/client/src/components/dashboard/Education.js @@ -46,4 +46,8 @@ Education.propTypes = { deleteEducation: PropTypes.func.isRequired }; -export default connect(null, { deleteEducation })(Education); \ No newline at end of file +<<<<<<< HEAD +export default connect(null, { deleteEducation })(Education); +======= +export default connect(null, { deleteEducation })(Education); +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb diff --git a/client/src/components/dashboard/Experience.js b/client/src/components/dashboard/Experience.js index 6bc94a8..0b9a474 100644 --- a/client/src/components/dashboard/Experience.js +++ b/client/src/components/dashboard/Experience.js @@ -1,4 +1,7 @@ +<<<<<<< HEAD +======= +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb import React, { Fragment } from 'react'; import PropTypes from 'prop-types'; import { connect } from 'react-redux'; @@ -47,4 +50,8 @@ Experience.propTypes = { deleteExperience: PropTypes.func.isRequired }; -export default connect(null, { deleteExperience })(Experience); \ No newline at end of file +<<<<<<< HEAD +export default connect(null, { deleteExperience })(Experience); +======= +export default connect(null, { deleteExperience })(Experience); +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb diff --git a/client/src/components/layout/Alert.js b/client/src/components/layout/Alert.js index 1d43520..97349bf 100644 --- a/client/src/components/layout/Alert.js +++ b/client/src/components/layout/Alert.js @@ -20,4 +20,8 @@ const mapStateToProps = (state) => ({ alerts: state.alert }); -export default connect(mapStateToProps)(Alert); \ No newline at end of file +<<<<<<< HEAD +export default connect(mapStateToProps)(Alert); +======= +export default connect(mapStateToProps)(Alert); +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb diff --git a/client/src/components/layout/Landing.js b/client/src/components/layout/Landing.js index 3fd8eaf..007524c 100644 --- a/client/src/components/layout/Landing.js +++ b/client/src/components/layout/Landing.js @@ -5,6 +5,25 @@ import PropTypes from 'prop-types'; const Landing = ({ isAuthenticated }) => { if (isAuthenticated) { +<<<<<<< HEAD + return ; + } + + return ( +
+
+
+

Developer Connector

+

+ Create a developer profile/portfolio, share posts and get help from + other developers +

+
+ + Sign Up + + +======= return ; } @@ -22,6 +41,7 @@ const Landing = ({ isAuthenticated }) => { Sign Up +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb Login
@@ -35,8 +55,16 @@ Landing.propTypes = { isAuthenticated: PropTypes.bool }; +<<<<<<< HEAD +const mapStateToProps = (state) => ({ + isAuthenticated: state.auth.isAuthenticated +}); + +export default connect(mapStateToProps)(Landing); +======= const mapStateToProps = state => ({ isAuthenticated: state.auth.isAuthenticated }); -export default connect(mapStateToProps)(Landing); \ No newline at end of file +export default connect(mapStateToProps)(Landing); +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb diff --git a/client/src/components/layout/NotFound.js b/client/src/components/layout/NotFound.js index 4fc2f6c..df23b1d 100644 --- a/client/src/components/layout/NotFound.js +++ b/client/src/components/layout/NotFound.js @@ -11,4 +11,8 @@ const NotFound = () => { ); }; -export default NotFound; \ No newline at end of file +<<<<<<< HEAD +export default NotFound; +======= +export default NotFound; +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb diff --git a/client/src/components/layout/Spinner.js b/client/src/components/layout/Spinner.js index a03ac94..bc61086 100644 --- a/client/src/components/layout/Spinner.js +++ b/client/src/components/layout/Spinner.js @@ -11,4 +11,8 @@ const Spinner = () => ( ); -export default Spinner; \ No newline at end of file +<<<<<<< HEAD +export default Spinner; +======= +export default Spinner; +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb diff --git a/client/src/components/post/CommentForm.js b/client/src/components/post/CommentForm.js index 8b64840..f0004fa 100644 --- a/client/src/components/post/CommentForm.js +++ b/client/src/components/post/CommentForm.js @@ -41,4 +41,8 @@ CommentForm.propTypes = { export default connect( null, { addComment } -)(CommentForm); \ No newline at end of file +<<<<<<< HEAD +)(CommentForm); +======= +)(CommentForm); +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb diff --git a/client/src/components/post/CommentItem.js b/client/src/components/post/CommentItem.js index dad04a7..7f01817 100644 --- a/client/src/components/post/CommentItem.js +++ b/client/src/components/post/CommentItem.js @@ -45,4 +45,8 @@ const mapStateToProps = (state) => ({ auth: state.auth }); -export default connect(mapStateToProps, { deleteComment })(CommentItem); \ No newline at end of file +<<<<<<< HEAD +export default connect(mapStateToProps, { deleteComment })(CommentItem); +======= +export default connect(mapStateToProps, { deleteComment })(CommentItem); +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb diff --git a/client/src/components/post/Post.js b/client/src/components/post/Post.js index 1296ae2..b901859 100644 --- a/client/src/components/post/Post.js +++ b/client/src/components/post/Post.js @@ -41,4 +41,8 @@ const mapStateToProps = (state) => ({ post: state.post }); -export default connect(mapStateToProps, { getPost })(Post); \ No newline at end of file +<<<<<<< HEAD +export default connect(mapStateToProps, { getPost })(Post); +======= +export default connect(mapStateToProps, { getPost })(Post); +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb diff --git a/client/src/components/posts/PostForm.js b/client/src/components/posts/PostForm.js index 949a53b..af41cec 100644 --- a/client/src/components/posts/PostForm.js +++ b/client/src/components/posts/PostForm.js @@ -41,4 +41,8 @@ PostForm.propTypes = { export default connect( null, { addPost } -)(PostForm); \ No newline at end of file +<<<<<<< HEAD +)(PostForm); +======= +)(PostForm); +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb diff --git a/client/src/components/posts/PostItem.js b/client/src/components/posts/PostItem.js index c9bbf02..f1cfdc5 100644 --- a/client/src/components/posts/PostItem.js +++ b/client/src/components/posts/PostItem.js @@ -1,4 +1,8 @@ +<<<<<<< HEAD +import React from 'react'; +======= import React, { Fragment } from 'react'; +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb import PropTypes from 'prop-types'; import { Link } from 'react-router-dom'; import formatDate from '../../utils/formatDate'; @@ -10,8 +14,12 @@ const PostItem = ({ removeLike, deletePost, auth, +<<<<<<< HEAD + post: { _id, text, name, avatar, user, likes, comments, date } +======= post: { _id, text, name, avatar, user, likes, comments, date }, showActions +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb }) => (
@@ -24,6 +32,37 @@ const PostItem = ({

{text}

Posted on {formatDate(date)}

+<<<<<<< HEAD + + + + Discussion{' '} + {comments.length > 0 && ( + {comments.length} + )} + + {!auth.loading && user === auth.user._id && ( + +======= {showActions && (
); +<<<<<<< HEAD +======= PostItem.defaultProps = { showActions: true }; +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb PostItem.propTypes = { post: PropTypes.object.isRequired, auth: PropTypes.object.isRequired, addLike: PropTypes.func.isRequired, removeLike: PropTypes.func.isRequired, +<<<<<<< HEAD + deletePost: PropTypes.func.isRequired +======= deletePost: PropTypes.func.isRequired, showActions: PropTypes.bool +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb }; const mapStateToProps = (state) => ({ @@ -81,4 +128,8 @@ const mapStateToProps = (state) => ({ export default connect(mapStateToProps, { addLike, removeLike, deletePost })( PostItem -); \ No newline at end of file +<<<<<<< HEAD +); +======= +); +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb diff --git a/client/src/components/posts/Posts.js b/client/src/components/posts/Posts.js index ad76760..9783d4d 100644 --- a/client/src/components/posts/Posts.js +++ b/client/src/components/posts/Posts.js @@ -35,4 +35,8 @@ const mapStateToProps = (state) => ({ post: state.post }); -export default connect(mapStateToProps, { getPosts })(Posts); \ No newline at end of file +<<<<<<< HEAD +export default connect(mapStateToProps, { getPosts })(Posts); +======= +export default connect(mapStateToProps, { getPosts })(Posts); +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb diff --git a/client/src/components/profile-forms/AddEducation.js b/client/src/components/profile-forms/AddEducation.js index 81251c7..681ad86 100644 --- a/client/src/components/profile-forms/AddEducation.js +++ b/client/src/components/profile-forms/AddEducation.js @@ -34,7 +34,11 @@ const AddEducation = ({ addEducation }) => { className="form" onSubmit={(e) => { e.preventDefault(); +<<<<<<< HEAD + addEducation(formData).then(() => navigate('/dashboard')); +======= addEducation(formData, navigate); +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb }} >
@@ -115,4 +119,8 @@ AddEducation.propTypes = { addEducation: PropTypes.func.isRequired }; -export default connect(null, { addEducation })(AddEducation); \ No newline at end of file +<<<<<<< HEAD +export default connect(null, { addEducation })(AddEducation); +======= +export default connect(null, { addEducation })(AddEducation); +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb diff --git a/client/src/components/profile-forms/AddExperience.js b/client/src/components/profile-forms/AddExperience.js index 8549f8d..af37bdf 100644 --- a/client/src/components/profile-forms/AddExperience.js +++ b/client/src/components/profile-forms/AddExperience.js @@ -33,7 +33,11 @@ const AddExperience = ({ addExperience }) => { className="form" onSubmit={(e) => { e.preventDefault(); +<<<<<<< HEAD + addExperience(formData).then(() => navigate('/dashboard')); +======= addExperience(formData, navigate); +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb }} >
@@ -116,4 +120,8 @@ AddExperience.propTypes = { addExperience: PropTypes.func.isRequired }; -export default connect(null, { addExperience })(AddExperience); \ No newline at end of file +<<<<<<< HEAD +export default connect(null, { addExperience })(AddExperience); +======= +export default connect(null, { addExperience })(AddExperience); +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb diff --git a/client/src/components/profile-forms/ProfileForm.js b/client/src/components/profile-forms/ProfileForm.js index dfe5c3c..9189d18 100644 --- a/client/src/components/profile-forms/ProfileForm.js +++ b/client/src/components/profile-forms/ProfileForm.js @@ -78,8 +78,16 @@ const ProfileForm = ({ setFormData({ ...formData, [e.target.name]: e.target.value }); const onSubmit = (e) => { +<<<<<<< HEAD + const editing = profile ? true : false; + e.preventDefault(); + createProfile(formData, editing).then(() => { + if (!editing) navigate('/dashboard'); + }); +======= e.preventDefault(); createProfile(formData, navigate, profile ? true : false); +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb }; return ( @@ -273,4 +281,8 @@ const mapStateToProps = (state) => ({ export default connect(mapStateToProps, { createProfile, getCurrentProfile })( ProfileForm -); \ No newline at end of file +<<<<<<< HEAD +); +======= +); +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb diff --git a/client/src/components/profile/Profile.js b/client/src/components/profile/Profile.js index 90ab139..e31b0df 100644 --- a/client/src/components/profile/Profile.js +++ b/client/src/components/profile/Profile.js @@ -76,11 +76,19 @@ const Profile = ({ getProfileById, profile: { profile }, auth }) => {
); }; +<<<<<<< HEAD + +======= +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb Profile.propTypes = { getProfileById: PropTypes.func.isRequired, profile: PropTypes.object.isRequired, auth: PropTypes.object.isRequired }; +<<<<<<< HEAD + +======= +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb const mapStateToProps = (state) => ({ profile: state.profile, auth: state.auth diff --git a/client/src/components/profile/ProfileAbout.js b/client/src/components/profile/ProfileAbout.js index c317244..0809936 100644 --- a/client/src/components/profile/ProfileAbout.js +++ b/client/src/components/profile/ProfileAbout.js @@ -31,4 +31,8 @@ ProfileAbout.propTypes = { profile: PropTypes.object.isRequired }; -export default ProfileAbout; \ No newline at end of file +<<<<<<< HEAD +export default ProfileAbout; +======= +export default ProfileAbout; +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb diff --git a/client/src/components/profile/ProfileEducation.js b/client/src/components/profile/ProfileEducation.js index 8d85969..d6fa0d8 100644 --- a/client/src/components/profile/ProfileEducation.js +++ b/client/src/components/profile/ProfileEducation.js @@ -26,4 +26,8 @@ ProfileEducation.propTypes = { education: PropTypes.object.isRequired }; -export default ProfileEducation; \ No newline at end of file +<<<<<<< HEAD +export default ProfileEducation; +======= +export default ProfileEducation; +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb diff --git a/client/src/components/profile/ProfileExperience.js b/client/src/components/profile/ProfileExperience.js index 767f6d7..245e3c7 100644 --- a/client/src/components/profile/ProfileExperience.js +++ b/client/src/components/profile/ProfileExperience.js @@ -26,4 +26,8 @@ ProfileExperience.propTypes = { experience: PropTypes.object.isRequired }; -export default ProfileExperience; \ No newline at end of file +<<<<<<< HEAD +export default ProfileExperience; +======= +export default ProfileExperience; +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb diff --git a/client/src/components/profile/ProfileGithub.js b/client/src/components/profile/ProfileGithub.js index 9f563d2..67b374d 100644 --- a/client/src/components/profile/ProfileGithub.js +++ b/client/src/components/profile/ProfileGithub.js @@ -48,4 +48,8 @@ const mapStateToProps = state => ({ repos: state.profile.repos }); -export default connect(mapStateToProps, { getGithubRepos })(ProfileGithub); \ No newline at end of file +<<<<<<< HEAD +export default connect(mapStateToProps, { getGithubRepos })(ProfileGithub); +======= +export default connect(mapStateToProps, { getGithubRepos })(ProfileGithub); +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb diff --git a/client/src/components/profile/ProfileTop.js b/client/src/components/profile/ProfileTop.js index 7712712..a38adc5 100644 --- a/client/src/components/profile/ProfileTop.js +++ b/client/src/components/profile/ProfileTop.js @@ -48,4 +48,8 @@ ProfileTop.propTypes = { profile: PropTypes.object.isRequired }; -export default ProfileTop; \ No newline at end of file +<<<<<<< HEAD +export default ProfileTop; +======= +export default ProfileTop; +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb diff --git a/client/src/components/profiles/ProfileItem.js b/client/src/components/profiles/ProfileItem.js index 4c69272..2fba35a 100644 --- a/client/src/components/profiles/ProfileItem.js +++ b/client/src/components/profiles/ProfileItem.js @@ -39,4 +39,8 @@ ProfileItem.propTypes = { profile: PropTypes.object.isRequired }; -export default ProfileItem; \ No newline at end of file +<<<<<<< HEAD +export default ProfileItem; +======= +export default ProfileItem; +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb diff --git a/client/src/components/profiles/Profiles.js b/client/src/components/profiles/Profiles.js index d1bb1d6..b83853a 100644 --- a/client/src/components/profiles/Profiles.js +++ b/client/src/components/profiles/Profiles.js @@ -1,3 +1,53 @@ +<<<<<<< HEAD +import React, { Fragment, useEffect } from 'react'; +import PropTypes from 'prop-types'; +import { connect } from 'react-redux'; +import Spinner from '../layout/Spinner'; +import ProfileItem from './ProfileItem'; +import { getProfiles } from '../../actions/profile'; + +const Profiles = ({ getProfiles, profile: { profiles, loading } }) => { + useEffect(() => { + getProfiles(); + }, [getProfiles]); + + return ( +
+ {loading ? ( + + ) : ( + +

Developers

+

+ Browse and connect with + developers +

+
+ {profiles.length > 0 ? ( + profiles.map((profile) => ( + + )) + ) : ( +

No profiles found...

+ )} +
+
+ )} +
+ ); +}; + +Profiles.propTypes = { + getProfiles: PropTypes.func.isRequired, + profile: PropTypes.object.isRequired +}; + +const mapStateToProps = (state) => ({ + profile: state.profile +}); + +export default connect(mapStateToProps, { getProfiles })(Profiles); +======= import React from 'react'; import { Link } from 'react-router-dom'; import PropTypes from 'prop-types'; @@ -40,3 +90,4 @@ ProfileItem.propTypes = { }; export default ProfileItem; +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb diff --git a/client/src/components/routing/PrivateRoute.js b/client/src/components/routing/PrivateRoute.js index 9d2896b..70a7af5 100644 --- a/client/src/components/routing/PrivateRoute.js +++ b/client/src/components/routing/PrivateRoute.js @@ -22,4 +22,8 @@ const mapStateToProps = (state) => ({ auth: state.auth }); -export default connect(mapStateToProps)(PrivateRoute); \ No newline at end of file +<<<<<<< HEAD +export default connect(mapStateToProps)(PrivateRoute); +======= +export default connect(mapStateToProps)(PrivateRoute); +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb diff --git a/client/src/index.js b/client/src/index.js index b6c6cb2..b763b62 100644 --- a/client/src/index.js +++ b/client/src/index.js @@ -1,5 +1,13 @@ +<<<<<<< HEAD +import React from 'react'; +import ReactDOM from 'react-dom'; +import App from './App'; + +ReactDOM.render(, document.getElementById('root')); +======= import React from "react"; import ReactDOM from "react-dom/client"; import App from "./App"; const root = ReactDOM.createRoot(document.getElementById('root')); -root.render(); \ No newline at end of file +root.render(); +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb diff --git a/client/src/reducers/alert.js b/client/src/reducers/alert.js index c6a62ef..b66b181 100644 --- a/client/src/reducers/alert.js +++ b/client/src/reducers/alert.js @@ -15,4 +15,8 @@ function alertReducer(state = initialState, action) { } } -export default alertReducer; \ No newline at end of file +<<<<<<< HEAD +export default alertReducer; +======= +export default alertReducer; +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb diff --git a/client/src/reducers/auth.js b/client/src/reducers/auth.js index 5998a4e..02537f6 100644 --- a/client/src/reducers/auth.js +++ b/client/src/reducers/auth.js @@ -50,4 +50,8 @@ function authReducer(state = initialState, action) { } } -export default authReducer; \ No newline at end of file +<<<<<<< HEAD +export default authReducer; +======= +export default authReducer; +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb diff --git a/client/src/reducers/index.js b/client/src/reducers/index.js index 73ee724..1b20294 100644 --- a/client/src/reducers/index.js +++ b/client/src/reducers/index.js @@ -9,4 +9,8 @@ export default combineReducers({ auth, profile, post -}); \ No newline at end of file +<<<<<<< HEAD +}); +======= +}); +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb diff --git a/client/src/reducers/post.js b/client/src/reducers/post.js index 1151ca8..ac280c2 100644 --- a/client/src/reducers/post.js +++ b/client/src/reducers/post.js @@ -1,4 +1,88 @@ import { +<<<<<<< HEAD + GET_POSTS, + POST_ERROR, + UPDATE_LIKES, + DELETE_POST, + ADD_POST, + GET_POST, + ADD_COMMENT, + REMOVE_COMMENT +} from '../actions/types'; + +const initialState = { + posts: [], + post: null, + loading: true, + error: {} +}; + +function postReducer(state = initialState, action) { + const { type, payload } = action; + + switch (type) { + case GET_POSTS: + return { + ...state, + posts: payload, + loading: false + }; + case GET_POST: + return { + ...state, + post: payload, + loading: false + }; + case ADD_POST: + return { + ...state, + posts: [payload, ...state.posts], + loading: false + }; + case DELETE_POST: + return { + ...state, + posts: state.posts.filter((post) => post._id !== payload), + loading: false + }; + case POST_ERROR: + return { + ...state, + error: payload, + loading: false + }; + case UPDATE_LIKES: + return { + ...state, + posts: state.posts.map((post) => + post._id === payload.id ? { ...post, likes: payload.likes } : post + ), + loading: false + }; + case ADD_COMMENT: + return { + ...state, + post: { ...state.post, comments: payload }, + loading: false + }; + case REMOVE_COMMENT: + return { + ...state, + post: { + ...state.post, + comments: state.post.comments.filter( + (comment) => comment._id !== payload + ) + }, + loading: false + }; + default: + return state; + } +} + +export default postReducer; +======= GET_POSTS, POST_ERROR, UPDATE_LIKES, @@ -80,4 +164,5 @@ import { } } - export default postReducer; \ No newline at end of file + export default postReducer; +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb diff --git a/client/src/reducers/profile.js b/client/src/reducers/profile.js index dad5acb..2968be9 100644 --- a/client/src/reducers/profile.js +++ b/client/src/reducers/profile.js @@ -5,15 +5,24 @@ import { UPDATE_PROFILE, GET_PROFILES, GET_REPOS, +<<<<<<< HEAD + NO_REPOS +} from '../actions/types'; +======= NO_REPOS, } from "../actions/types"; +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb const initialState = { profile: null, profiles: [], repos: [], loading: true, +<<<<<<< HEAD + error: {} +======= error: {}, +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb }; function profileReducer(state = initialState, action) { @@ -25,37 +34,61 @@ function profileReducer(state = initialState, action) { return { ...state, profile: payload, +<<<<<<< HEAD + loading: false +======= loading: false, +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb }; case GET_PROFILES: return { ...state, profiles: payload, +<<<<<<< HEAD + loading: false +======= loading: false, +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb }; case PROFILE_ERROR: return { ...state, error: payload, loading: false, +<<<<<<< HEAD + profile: null +======= profile: null, +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb }; case CLEAR_PROFILE: return { ...state, profile: null, +<<<<<<< HEAD + repos: [] +======= repos: [], +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb }; case GET_REPOS: return { ...state, repos: payload, +<<<<<<< HEAD + loading: false +======= loading: false, +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb }; case NO_REPOS: return { ...state, +<<<<<<< HEAD + repos: [] +======= repos: [], +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb }; default: return state; diff --git a/client/src/store.js b/client/src/store.js index 3c4bd1e..f6169e9 100644 --- a/client/src/store.js +++ b/client/src/store.js @@ -36,4 +36,8 @@ store.subscribe(() => { } }); -export default store; \ No newline at end of file +<<<<<<< HEAD +export default store; +======= +export default store; +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb diff --git a/client/src/utils/api.js b/client/src/utils/api.js index 26399e5..40d2e7e 100644 --- a/client/src/utils/api.js +++ b/client/src/utils/api.js @@ -2,12 +2,26 @@ import axios from 'axios'; import store from '../store'; import { LOGOUT } from '../actions/types'; +<<<<<<< HEAD +// Create an instance of axios +======= +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb const api = axios.create({ baseURL: '/api', headers: { 'Content-Type': 'application/json' } }); +<<<<<<< HEAD +/* + NOTE: intercept any error responses from the api + and check if the token is no longer valid. + ie. Token has expired or user is no longer + authenticated. + logout the user if the token has expired +*/ +======= +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb api.interceptors.response.use( (res) => res, diff --git a/client/src/utils/formatDate.js b/client/src/utils/formatDate.js index 0e996da..002b464 100644 --- a/client/src/utils/formatDate.js +++ b/client/src/utils/formatDate.js @@ -3,4 +3,7 @@ function formatDate(date) { } export default formatDate; +<<<<<<< HEAD +======= +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb diff --git a/client/src/utils/setAuthToken.js b/client/src/utils/setAuthToken.js index 16bce85..592152f 100644 --- a/client/src/utils/setAuthToken.js +++ b/client/src/utils/setAuthToken.js @@ -1,3 +1,16 @@ +<<<<<<< HEAD +import api from './api'; + +// store our JWT in LS and set axios headers if we do have a token + +const setAuthToken = (token) => { + if (token) { + api.defaults.headers.common['x-auth-token'] = token; + localStorage.setItem('token', token); + } else { + delete api.defaults.headers.common['x-auth-token']; + localStorage.removeItem('token'); +======= import axios from "axios"; const setAuthToken = (token) => { @@ -7,6 +20,7 @@ const setAuthToken = (token) => { } else { delete axios.defaults.common["x-auth-token"]; localStorage.removeItem('token') +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb } }; diff --git a/package.json b/package.json index 3dbeeb9..dfaf8d9 100644 --- a/package.json +++ b/package.json @@ -7,8 +7,12 @@ "start": "node server", "server": "nodemon server", "client": "npm start --prefix client --trace-depracation", +<<<<<<< HEAD + "dev": "concurrently \"npm run server\" \"npm run client\"" +======= "dev": "concurrently \"npm run server\" \"npm run client\"", "heroku-postbuild":"NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client" +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb }, "author": "", "license": "ISC", diff --git a/server.js b/server.js index 0a1793a..74ff1fa 100644 --- a/server.js +++ b/server.js @@ -1,16 +1,25 @@ const express = require('express'); const connectDB= require('./config/db') +<<<<<<< HEAD +======= const path = require('path') +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb const app = express(); connectDB(); app.use(express.json({extended:false})); +<<<<<<< HEAD +app.get('/',(req,res)=> res.send('API Running')); +======= +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb app.use('/api/users', require('./routers/api/users')) app.use('/api/auth', require('./routers/api/auth')) app.use('/api/profile', require('./routers/api/profile')) app.use('/api/posts', require('./routers/api/posts')) +<<<<<<< HEAD +======= // Serve static assets in production if (process.env.NODE_ENV==='production'){ app.use(express.static('client/build')); @@ -18,6 +27,7 @@ if (process.env.NODE_ENV==='production'){ res.sendFile(path.resolve(__dirname, 'client', 'build','index.html')) ]) } +>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb const PORT = process.env.PORT || 5000; app.listen(PORT,()=> console.log(`Server started on port ${PORT}`)); \ No newline at end of file