before start updating to new redux
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
node_modules
|
node_modules
|
||||||
default.json
|
default.json
|
||||||
.vscode
|
.vscode
|
||||||
|
TODO.txt
|
||||||
|
|||||||
+1
-1
@@ -43,5 +43,5 @@
|
|||||||
"last 1 safari version"
|
"last 1 safari version"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"proxy":"http://localhost:5000"
|
"proxy": "http://localhost:5000"
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -582,4 +582,4 @@ button {
|
|||||||
right: 2rem;
|
right: 2rem;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb
|
|
||||||
|
|||||||
+6
-1
@@ -1,5 +1,6 @@
|
|||||||
import React, { useEffect } from 'react';
|
import React, { useEffect } from 'react';
|
||||||
import { BrowserRouter as Router, Route, Routes } from 'react-router-dom';
|
import { BrowserRouter as Router, Route, Routes } from 'react-router-dom';
|
||||||
|
|
||||||
import Navbar from './components/layout/Navbar';
|
import Navbar from './components/layout/Navbar';
|
||||||
import Landing from './components/layout/Landing';
|
import Landing from './components/layout/Landing';
|
||||||
import Register from './components/auth/Register';
|
import Register from './components/auth/Register';
|
||||||
@@ -25,6 +26,9 @@ import setAuthToken from './utils/setAuthToken';
|
|||||||
|
|
||||||
import './App.css';
|
import './App.css';
|
||||||
|
|
||||||
|
// Level - 1
|
||||||
|
//
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// check for token in LS when app first runs
|
// check for token in LS when app first runs
|
||||||
@@ -43,7 +47,8 @@ const App = () => {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Provider store={store}>
|
<Provider store={store}>
|
||||||
|
// Seting Up redux store
|
||||||
<Router>
|
<Router>
|
||||||
<Navbar />
|
<Navbar />
|
||||||
<Alert />
|
<Alert />
|
||||||
|
|||||||
@@ -11,12 +11,7 @@ import {
|
|||||||
REMOVE_COMMENT
|
REMOVE_COMMENT
|
||||||
} from './types';
|
} from './types';
|
||||||
|
|
||||||
/*
|
|
||||||
NOTE: we don't need a config object for axios as the
|
|
||||||
default headers in axios are already Content-Type: application/json
|
|
||||||
also axios stringifies and parses JSON for you, so no need for
|
|
||||||
JSON.stringify or JSON.parse
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Get posts
|
// Get posts
|
||||||
export const getPosts = () => async (dispatch) => {
|
export const getPosts = () => async (dispatch) => {
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
import React, { useEffect } from 'react';
|
import React, { useEffect } from 'react';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
@@ -33,7 +32,7 @@ const Dashboard = ({
|
|||||||
|
|
||||||
<div className="my-2">
|
<div className="my-2">
|
||||||
<button className="btn btn-danger" onClick={() => deleteAccount()}>
|
<button className="btn btn-danger" onClick={() => deleteAccount()}>
|
||||||
<i className="fas fa-user-minus" /> Delete My Account
|
<i className="fas fa-user" /> Delete My Account
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ const Navbar = ({ auth: { isAuthenticated }, logout }) => {
|
|||||||
<li>
|
<li>
|
||||||
<Link to="/dashboard">
|
<Link to="/dashboard">
|
||||||
<i className="fas fa-user" />{' '}
|
<i className="fas fa-user" />{' '}
|
||||||
<span className="hide-sm">Dashboard</span>
|
<span className="hide-sm">Profile</span>
|
||||||
</Link>
|
</Link>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
@@ -45,7 +45,7 @@ const Navbar = ({ auth: { isAuthenticated }, logout }) => {
|
|||||||
return (
|
return (
|
||||||
<nav className="navbar bg-dark">
|
<nav className="navbar bg-dark">
|
||||||
<h1>
|
<h1>
|
||||||
<Link to="/">
|
<Link to="/posts">
|
||||||
<i className="fas fa-code" /> DevConnector
|
<i className="fas fa-code" /> DevConnector
|
||||||
</Link>
|
</Link>
|
||||||
</h1>
|
</h1>
|
||||||
|
|||||||
@@ -1,44 +1,55 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from "react";
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from "prop-types";
|
||||||
import { connect } from 'react-redux';
|
import { connect } from "react-redux";
|
||||||
import { addPost } from '../../actions/post';
|
import { addPost } from "../../actions/post";
|
||||||
|
|
||||||
const PostForm = ({ addPost }) => {
|
const PostForm = ({ addPost }) => {
|
||||||
const [text, setText] = useState('');
|
const [text, setText] = useState("");
|
||||||
|
const [category, setCategory] = useState("");
|
||||||
|
//const onChange = (e) =>
|
||||||
|
//setFormData({ ...formData, [e.target.name]: e.target.value });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='post-form'>
|
<div className="post-form">
|
||||||
<div className='bg-primary p'>
|
<div className="bg-primary p">
|
||||||
<h3>Say Something...</h3>
|
<h3>Say Something...</h3>
|
||||||
</div>
|
</div>
|
||||||
<form
|
<form
|
||||||
className='form my-1'
|
className="form my-1"
|
||||||
onSubmit={e => {
|
onSubmit={(e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
addPost({ text });
|
addPost({ text, category });
|
||||||
setText('');
|
setText("");
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<textarea
|
<textarea
|
||||||
name='text'
|
name="text"
|
||||||
cols='30'
|
cols="30"
|
||||||
rows='5'
|
rows="5"
|
||||||
placeholder='Create a post'
|
placeholder="Create a post"
|
||||||
value={text}
|
value={text}
|
||||||
onChange={e => setText(e.target.value)}
|
onChange={(e) => setText(e.target.value)}
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
<input type='submit' className='btn btn-dark my-1' value='Submit' />
|
|
||||||
|
<p className="lead">Choose a category:</p>
|
||||||
|
<select name="category" value={category} onChange={setCategory}>
|
||||||
|
<option>* Select Category</option>
|
||||||
|
<option value="opinion">Opinion</option>
|
||||||
|
<option value="question">Question</option>
|
||||||
|
<option value="asssitance">Asking for asssitance</option>
|
||||||
|
<option value="news">News</option>
|
||||||
|
<option value="other">Other</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<input type="submit" className="btn btn-dark my-1" value="Submit" />
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
PostForm.propTypes = {
|
PostForm.propTypes = {
|
||||||
addPost: PropTypes.func.isRequired
|
addPost: PropTypes.func.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default connect(
|
export default connect(null, { addPost })(PostForm);
|
||||||
null,
|
|
||||||
{ addPost }
|
|
||||||
)(PostForm);
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
import App from './App';
|
import App from './App';
|
||||||
|
// Level - 0
|
||||||
|
//Program stars from Here. Imports and renders App.
|
||||||
|
|
||||||
ReactDOM.render(<App />, document.getElementById('root'));
|
ReactDOM.render(<App />, document.getElementById('root'));
|
||||||
|
|
||||||
|
|||||||
@@ -13,8 +13,7 @@ const initialState = {
|
|||||||
profiles: [],
|
profiles: [],
|
||||||
repos: [],
|
repos: [],
|
||||||
loading: true,
|
loading: true,
|
||||||
error: {},
|
error: {}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function profileReducer(state = initialState, action) {
|
function profileReducer(state = initialState, action) {
|
||||||
@@ -26,13 +25,13 @@ function profileReducer(state = initialState, action) {
|
|||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
profile: payload,
|
profile: payload,
|
||||||
loading: false,
|
loading: false
|
||||||
};
|
};
|
||||||
case GET_PROFILES:
|
case GET_PROFILES:
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
profiles: payload,
|
profiles: payload,
|
||||||
loading: false,
|
loading: false
|
||||||
};
|
};
|
||||||
case PROFILE_ERROR:
|
case PROFILE_ERROR:
|
||||||
return {
|
return {
|
||||||
@@ -40,7 +39,6 @@ function profileReducer(state = initialState, action) {
|
|||||||
error: payload,
|
error: payload,
|
||||||
loading: false,
|
loading: false,
|
||||||
profile: null
|
profile: null
|
||||||
profile: null,
|
|
||||||
};
|
};
|
||||||
case CLEAR_PROFILE:
|
case CLEAR_PROFILE:
|
||||||
return {
|
return {
|
||||||
@@ -52,12 +50,12 @@ function profileReducer(state = initialState, action) {
|
|||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
repos: payload,
|
repos: payload,
|
||||||
loading: false,
|
loading: false
|
||||||
};
|
};
|
||||||
case NO_REPOS:
|
case NO_REPOS:
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
repos: [],
|
repos: []
|
||||||
};
|
};
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
|
|||||||
Reference in New Issue
Block a user