before start updating to new redux
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user