before start updating to new redux
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
node_modules
|
||||
default.json
|
||||
.vscode
|
||||
TODO.txt
|
||||
|
||||
+1
-1
@@ -43,5 +43,5 @@
|
||||
"last 1 safari version"
|
||||
]
|
||||
},
|
||||
"proxy":"http://localhost:5000"
|
||||
"proxy": "http://localhost:5000"
|
||||
}
|
||||
|
||||
+1
-1
@@ -582,4 +582,4 @@ button {
|
||||
right: 2rem;
|
||||
display: inline-block;
|
||||
}
|
||||
>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb
|
||||
|
||||
|
||||
+6
-1
@@ -1,5 +1,6 @@
|
||||
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';
|
||||
@@ -25,6 +26,9 @@ import setAuthToken from './utils/setAuthToken';
|
||||
|
||||
import './App.css';
|
||||
|
||||
// Level - 1
|
||||
//
|
||||
|
||||
const App = () => {
|
||||
useEffect(() => {
|
||||
// check for token in LS when app first runs
|
||||
@@ -43,7 +47,8 @@ const App = () => {
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<Provider store={store}>
|
||||
<Provider store={store}>
|
||||
// Seting Up redux store
|
||||
<Router>
|
||||
<Navbar />
|
||||
<Alert />
|
||||
|
||||
@@ -11,12 +11,7 @@ import {
|
||||
REMOVE_COMMENT
|
||||
} 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
|
||||
export const getPosts = () => async (dispatch) => {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
import React, { useEffect } from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import PropTypes from 'prop-types';
|
||||
@@ -33,7 +32,7 @@ const Dashboard = ({
|
||||
|
||||
<div className="my-2">
|
||||
<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>
|
||||
</div>
|
||||
</>
|
||||
|
||||
@@ -16,7 +16,7 @@ const Navbar = ({ auth: { isAuthenticated }, logout }) => {
|
||||
<li>
|
||||
<Link to="/dashboard">
|
||||
<i className="fas fa-user" />{' '}
|
||||
<span className="hide-sm">Dashboard</span>
|
||||
<span className="hide-sm">Profile</span>
|
||||
</Link>
|
||||
</li>
|
||||
<li>
|
||||
@@ -45,7 +45,7 @@ const Navbar = ({ auth: { isAuthenticated }, logout }) => {
|
||||
return (
|
||||
<nav className="navbar bg-dark">
|
||||
<h1>
|
||||
<Link to="/">
|
||||
<Link to="/posts">
|
||||
<i className="fas fa-code" /> DevConnector
|
||||
</Link>
|
||||
</h1>
|
||||
|
||||
@@ -1,44 +1,55 @@
|
||||
import React, { useState } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { connect } from 'react-redux';
|
||||
import { addPost } from '../../actions/post';
|
||||
import React, { useState } from "react";
|
||||
import PropTypes from "prop-types";
|
||||
import { connect } from "react-redux";
|
||||
import { addPost } from "../../actions/post";
|
||||
|
||||
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 (
|
||||
<div className='post-form'>
|
||||
<div className='bg-primary p'>
|
||||
<div className="post-form">
|
||||
<div className="bg-primary p">
|
||||
<h3>Say Something...</h3>
|
||||
</div>
|
||||
<form
|
||||
className='form my-1'
|
||||
onSubmit={e => {
|
||||
className="form my-1"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
addPost({ text });
|
||||
setText('');
|
||||
addPost({ text, category });
|
||||
setText("");
|
||||
}}
|
||||
>
|
||||
<textarea
|
||||
name='text'
|
||||
cols='30'
|
||||
rows='5'
|
||||
placeholder='Create a post'
|
||||
name="text"
|
||||
cols="30"
|
||||
rows="5"
|
||||
placeholder="Create a post"
|
||||
value={text}
|
||||
onChange={e => setText(e.target.value)}
|
||||
onChange={(e) => setText(e.target.value)}
|
||||
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>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
PostForm.propTypes = {
|
||||
addPost: PropTypes.func.isRequired
|
||||
addPost: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
export default connect(
|
||||
null,
|
||||
{ addPost }
|
||||
)(PostForm);
|
||||
export default connect(null, { addPost })(PostForm);
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import App from './App';
|
||||
// Level - 0
|
||||
//Program stars from Here. Imports and renders App.
|
||||
|
||||
ReactDOM.render(<App />, document.getElementById('root'));
|
||||
|
||||
|
||||
@@ -13,8 +13,7 @@ const initialState = {
|
||||
profiles: [],
|
||||
repos: [],
|
||||
loading: true,
|
||||
error: {},
|
||||
|
||||
error: {}
|
||||
};
|
||||
|
||||
function profileReducer(state = initialState, action) {
|
||||
@@ -26,13 +25,13 @@ function profileReducer(state = initialState, action) {
|
||||
return {
|
||||
...state,
|
||||
profile: payload,
|
||||
loading: false,
|
||||
loading: false
|
||||
};
|
||||
case GET_PROFILES:
|
||||
return {
|
||||
...state,
|
||||
profiles: payload,
|
||||
loading: false,
|
||||
loading: false
|
||||
};
|
||||
case PROFILE_ERROR:
|
||||
return {
|
||||
@@ -40,7 +39,6 @@ function profileReducer(state = initialState, action) {
|
||||
error: payload,
|
||||
loading: false,
|
||||
profile: null
|
||||
profile: null,
|
||||
};
|
||||
case CLEAR_PROFILE:
|
||||
return {
|
||||
@@ -52,12 +50,12 @@ function profileReducer(state = initialState, action) {
|
||||
return {
|
||||
...state,
|
||||
repos: payload,
|
||||
loading: false,
|
||||
loading: false
|
||||
};
|
||||
case NO_REPOS:
|
||||
return {
|
||||
...state,
|
||||
repos: [],
|
||||
repos: []
|
||||
};
|
||||
default:
|
||||
return state;
|
||||
|
||||
Reference in New Issue
Block a user