mirror of
https://github.com/ClaytonWWilson/CS307-Team24.git
synced 2025-12-16 10:18:48 +00:00
Merge branch 'master' into login-frontend
This commit is contained in:
commit
4a5c404be3
@ -28,7 +28,7 @@ exports.putPost = (req, res) => {
|
||||
|
||||
exports.getallPostsforUser = (req, res) => {
|
||||
|
||||
admin.firestore().collection('posts').where('userHandle', '==', 'user' ).get()
|
||||
admin.firestore().collection('posts').where('userHandle', '==', 'new user' ).get()
|
||||
.then((data) => {
|
||||
let posts = [];
|
||||
data.forEach(function(doc) {
|
||||
|
||||
96
twistter-frontend/package-lock.json
generated
96
twistter-frontend/package-lock.json
generated
@ -62,9 +62,9 @@
|
||||
}
|
||||
},
|
||||
"@material-ui/styles": {
|
||||
"version": "4.4.3",
|
||||
"resolved": "https://registry.npmjs.org/@material-ui/styles/-/styles-4.4.3.tgz",
|
||||
"integrity": "sha512-kNUdHFWsrvWKIEPx8Xy2/qayqsGMrYmCMq+FIiJiYczVZl5hiS8j5+KayonnpVta/O+Dktk+cxWkVcgwtxMrHg==",
|
||||
"version": "4.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@material-ui/styles/-/styles-4.5.0.tgz",
|
||||
"integrity": "sha512-O0NSAECHK9f3DZK6wy56PZzp8b/7KSdfpJs8DSC7vnXUAoMPCTtchBKLzMtUsNlijiJFeJjSxNdQfjWXgyur5A==",
|
||||
"requires": {
|
||||
"@babel/runtime": "^7.4.4",
|
||||
"@emotion/hash": "^0.7.1",
|
||||
@ -74,21 +74,21 @@
|
||||
"csstype": "^2.5.2",
|
||||
"deepmerge": "^4.0.0",
|
||||
"hoist-non-react-statics": "^3.2.1",
|
||||
"jss": "10.0.0-alpha.25",
|
||||
"jss-plugin-camel-case": "10.0.0-alpha.25",
|
||||
"jss-plugin-default-unit": "10.0.0-alpha.25",
|
||||
"jss-plugin-global": "10.0.0-alpha.25",
|
||||
"jss-plugin-nested": "10.0.0-alpha.25",
|
||||
"jss-plugin-props-sort": "10.0.0-alpha.25",
|
||||
"jss-plugin-rule-value-function": "10.0.0-alpha.25",
|
||||
"jss-plugin-vendor-prefixer": "10.0.0-alpha.25",
|
||||
"jss": "^10.0.0",
|
||||
"jss-plugin-camel-case": "^10.0.0",
|
||||
"jss-plugin-default-unit": "^10.0.0",
|
||||
"jss-plugin-global": "^10.0.0",
|
||||
"jss-plugin-nested": "^10.0.0",
|
||||
"jss-plugin-props-sort": "^10.0.0",
|
||||
"jss-plugin-rule-value-function": "^10.0.0",
|
||||
"jss-plugin-vendor-prefixer": "^10.0.0",
|
||||
"prop-types": "^15.7.2"
|
||||
}
|
||||
},
|
||||
"@material-ui/system": {
|
||||
"version": "4.4.3",
|
||||
"resolved": "https://registry.npmjs.org/@material-ui/system/-/system-4.4.3.tgz",
|
||||
"integrity": "sha512-Cb05vLXsaCzssXD/iZKa0/qC6YOwbFWnYdnOEdkXZ3Fn2Ytz7rsnMgFejUSQV1luVhUBlEIm8DVz40N25WwW7w==",
|
||||
"version": "4.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@material-ui/system/-/system-4.5.0.tgz",
|
||||
"integrity": "sha512-vR0PbMTzLnuuVCoYNQ13zyhLa/4s/UA9P9JbNuHBOOkfrHn53ShINiG0v05EgfwizfULLtc7mNvsGAgIyyp/hQ==",
|
||||
"requires": {
|
||||
"@babel/runtime": "^7.4.4",
|
||||
"deepmerge": "^4.0.0",
|
||||
@ -119,9 +119,9 @@
|
||||
"integrity": "sha512-KfRL3PuHmqQLOG+2tGpRO26Ctg+Cq1E01D2DMriKEATHgWLfeNDmq9e29Q9WIky0dQ3NPkd1mzYH8Lm936Z9qw=="
|
||||
},
|
||||
"@types/react": {
|
||||
"version": "16.9.3",
|
||||
"resolved": "https://registry.npmjs.org/@types/react/-/react-16.9.3.tgz",
|
||||
"integrity": "sha512-Ogb2nSn+2qQv5opoCv7Ls5yFxtyrdUYxp5G+SWTrlGk7dmFKw331GiezCgEZj9U7QeXJi1CDtws9pdXU1zUL4g==",
|
||||
"version": "16.9.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/react/-/react-16.9.4.tgz",
|
||||
"integrity": "sha512-ItGNmJvQ0IvWt8rbk5PLdpdQhvBVxAaXI9hDlx7UMd8Ie1iMIuwMNiKeTfmVN517CdplpyXvA22X4zm4jGGZnw==",
|
||||
"requires": {
|
||||
"@types/prop-types": "*",
|
||||
"csstype": "^2.2.0"
|
||||
@ -5196,9 +5196,9 @@
|
||||
}
|
||||
},
|
||||
"jss": {
|
||||
"version": "10.0.0-alpha.25",
|
||||
"resolved": "https://registry.npmjs.org/jss/-/jss-10.0.0-alpha.25.tgz",
|
||||
"integrity": "sha512-zqKnXv181B9vue2yYhmVhc+6ggbbxHF/33rjXfXEjaa22nOvknTI21QDfq3oZ8uCC50kcFp3Z8KU1ghUXdFvIA==",
|
||||
"version": "10.0.0",
|
||||
"resolved": "https://registry.npmjs.org/jss/-/jss-10.0.0.tgz",
|
||||
"integrity": "sha512-TPpDFsiBjuERiL+dFDq8QCdiF9oDasPcNqCKLGCo/qED3fNYOQ8PX2lZhknyTiAt3tZrfOFbb0lbQ9lTjPZxsQ==",
|
||||
"requires": {
|
||||
"@babel/runtime": "^7.3.1",
|
||||
"csstype": "^2.6.5",
|
||||
@ -5207,69 +5207,69 @@
|
||||
}
|
||||
},
|
||||
"jss-plugin-camel-case": {
|
||||
"version": "10.0.0-alpha.25",
|
||||
"resolved": "https://registry.npmjs.org/jss-plugin-camel-case/-/jss-plugin-camel-case-10.0.0-alpha.25.tgz",
|
||||
"integrity": "sha512-J5ZEGDTy9ddqdTUPAF4SJQ25u5kiG1ORP8F+ZPEZAkkiMQJp+/Aol4I7xhTS2aW1Lhg8xNxdhdRfBi5yU7wOvg==",
|
||||
"version": "10.0.0",
|
||||
"resolved": "https://registry.npmjs.org/jss-plugin-camel-case/-/jss-plugin-camel-case-10.0.0.tgz",
|
||||
"integrity": "sha512-yALDL00+pPR4FJh+k07A8FeDvfoPPuXU48HLy63enAubcVd3DnS+2rgqPXglHDGixIDVkCSXecl/l5GAMjzIbA==",
|
||||
"requires": {
|
||||
"@babel/runtime": "^7.3.1",
|
||||
"hyphenate-style-name": "^1.0.3",
|
||||
"jss": "10.0.0-alpha.25"
|
||||
"jss": "10.0.0"
|
||||
}
|
||||
},
|
||||
"jss-plugin-default-unit": {
|
||||
"version": "10.0.0-alpha.25",
|
||||
"resolved": "https://registry.npmjs.org/jss-plugin-default-unit/-/jss-plugin-default-unit-10.0.0-alpha.25.tgz",
|
||||
"integrity": "sha512-auOG459B+yEqkojgaXH02SYO9+xjmAxlmP+WbzhVpXqOFJ2CN/kaxd8P4NJZLdj3BQxHiM7WIyMVh786StE+EA==",
|
||||
"version": "10.0.0",
|
||||
"resolved": "https://registry.npmjs.org/jss-plugin-default-unit/-/jss-plugin-default-unit-10.0.0.tgz",
|
||||
"integrity": "sha512-sURozIOdCtGg9ap18erQ+ijndAfEGtTaetxfU3H4qwC18Bi+fdvjlY/ahKbuu0ASs7R/+WKCP7UaRZOjUDMcdQ==",
|
||||
"requires": {
|
||||
"@babel/runtime": "^7.3.1",
|
||||
"jss": "10.0.0-alpha.25"
|
||||
"jss": "10.0.0"
|
||||
}
|
||||
},
|
||||
"jss-plugin-global": {
|
||||
"version": "10.0.0-alpha.25",
|
||||
"resolved": "https://registry.npmjs.org/jss-plugin-global/-/jss-plugin-global-10.0.0-alpha.25.tgz",
|
||||
"integrity": "sha512-cS98Q8X8jwltuaBZd9eYuxMXxkUL+mJGl2Ok3/nmJzH9nLzj6i7kLxSoDtuJNqsRmbP7ogIXVozJUq9lUu2hlQ==",
|
||||
"version": "10.0.0",
|
||||
"resolved": "https://registry.npmjs.org/jss-plugin-global/-/jss-plugin-global-10.0.0.tgz",
|
||||
"integrity": "sha512-80ofWKSQUo62bxLtRoTNe0kFPtHgUbAJeOeR36WEGgWIBEsXLyXOnD5KNnjPqG4heuEkz9eSLccjYST50JnI7Q==",
|
||||
"requires": {
|
||||
"@babel/runtime": "^7.3.1",
|
||||
"jss": "10.0.0-alpha.25"
|
||||
"jss": "10.0.0"
|
||||
}
|
||||
},
|
||||
"jss-plugin-nested": {
|
||||
"version": "10.0.0-alpha.25",
|
||||
"resolved": "https://registry.npmjs.org/jss-plugin-nested/-/jss-plugin-nested-10.0.0-alpha.25.tgz",
|
||||
"integrity": "sha512-7sk7/6mX1YTgXe+AyeD1zEyKTgIGbbhYtg+wWQcHJlE1flW2JHfcQ5mw84FgHcHQRQ8Dq3l9I3aEY51ev0J1Wg==",
|
||||
"version": "10.0.0",
|
||||
"resolved": "https://registry.npmjs.org/jss-plugin-nested/-/jss-plugin-nested-10.0.0.tgz",
|
||||
"integrity": "sha512-waxxwl/po1hN3azTyixKnr8ReEqUv5WK7WsO+5AWB0bFndML5Yqnt8ARZ90HEg8/P6WlqE/AB2413TkCRZE8bA==",
|
||||
"requires": {
|
||||
"@babel/runtime": "^7.3.1",
|
||||
"jss": "10.0.0-alpha.25",
|
||||
"jss": "10.0.0",
|
||||
"tiny-warning": "^1.0.2"
|
||||
}
|
||||
},
|
||||
"jss-plugin-props-sort": {
|
||||
"version": "10.0.0-alpha.25",
|
||||
"resolved": "https://registry.npmjs.org/jss-plugin-props-sort/-/jss-plugin-props-sort-10.0.0-alpha.25.tgz",
|
||||
"integrity": "sha512-8B/6QLQuUX8cIlZbXdjEm5l0jCX4EgacYMcFJhdKwDKEZYeAghpgQQrCKl0/CYHW7iFge5wim67P+uL6QxMzyw==",
|
||||
"version": "10.0.0",
|
||||
"resolved": "https://registry.npmjs.org/jss-plugin-props-sort/-/jss-plugin-props-sort-10.0.0.tgz",
|
||||
"integrity": "sha512-41mf22CImjwNdtOG3r+cdC8+RhwNm616sjHx5YlqTwtSJLyLFinbQC/a4PIFk8xqf1qpFH1kEAIw+yx9HaqZ3g==",
|
||||
"requires": {
|
||||
"@babel/runtime": "^7.3.1",
|
||||
"jss": "10.0.0-alpha.25"
|
||||
"jss": "10.0.0"
|
||||
}
|
||||
},
|
||||
"jss-plugin-rule-value-function": {
|
||||
"version": "10.0.0-alpha.25",
|
||||
"resolved": "https://registry.npmjs.org/jss-plugin-rule-value-function/-/jss-plugin-rule-value-function-10.0.0-alpha.25.tgz",
|
||||
"integrity": "sha512-CQQtWO+/OZRGaFRBSGQUgAci9YlVtdoXcWQKBNo70tmpp+kaXKlFNCYaL3jmHbJHMiwKQYG2RYFQNIrwJ9SGmA==",
|
||||
"version": "10.0.0",
|
||||
"resolved": "https://registry.npmjs.org/jss-plugin-rule-value-function/-/jss-plugin-rule-value-function-10.0.0.tgz",
|
||||
"integrity": "sha512-Jw+BZ8JIw1f12V0SERqGlBT1JEPWax3vuZpMym54NAXpPb7R1LYHiCTIlaJUyqvIfEy3kiHMtgI+r2whGgRIxQ==",
|
||||
"requires": {
|
||||
"@babel/runtime": "^7.3.1",
|
||||
"jss": "10.0.0-alpha.25"
|
||||
"jss": "10.0.0"
|
||||
}
|
||||
},
|
||||
"jss-plugin-vendor-prefixer": {
|
||||
"version": "10.0.0-alpha.25",
|
||||
"resolved": "https://registry.npmjs.org/jss-plugin-vendor-prefixer/-/jss-plugin-vendor-prefixer-10.0.0-alpha.25.tgz",
|
||||
"integrity": "sha512-5FXpB/TiwckbrkoDCmd27YsWCESl1K4hAX/oro2/geEXgnVQvDgQOf2eWCsjYO2K1lYPPXtskMfws/Q3eKmbYg==",
|
||||
"version": "10.0.0",
|
||||
"resolved": "https://registry.npmjs.org/jss-plugin-vendor-prefixer/-/jss-plugin-vendor-prefixer-10.0.0.tgz",
|
||||
"integrity": "sha512-qslqvL0MUbWuzXJWdUxpj6mdNUX8jr4FFTo3aZnAT65nmzWL7g8oTr9ZxmTXXgdp7ANhS1QWE7036/Q2isFBpw==",
|
||||
"requires": {
|
||||
"@babel/runtime": "^7.3.1",
|
||||
"css-vendor": "^2.0.6",
|
||||
"jss": "10.0.0-alpha.25"
|
||||
"jss": "10.0.0"
|
||||
}
|
||||
},
|
||||
"jsx-ast-utils": {
|
||||
|
||||
@ -4,6 +4,8 @@
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@material-ui/core": "^4.4.3",
|
||||
"@material-ui/styles": "^4.5.0",
|
||||
"@material-ui/system": "^4.5.0",
|
||||
"axios": "^0.19.0",
|
||||
"clsx": "^1.0.4",
|
||||
"create-react-app": "^3.1.2",
|
||||
|
||||
@ -47,3 +47,4 @@
|
||||
max-width: 1200px;
|
||||
color: #1da1f2;
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
/* eslint-disable */
|
||||
import React, { Component } from "react";
|
||||
|
||||
import "./App.css";
|
||||
|
||||
import { BrowserRouter as Router } from "react-router-dom";
|
||||
@ -11,18 +10,22 @@ import jwtDecode from "jwt-decode";
|
||||
// Redux
|
||||
import { Provider } from "react-redux";
|
||||
import store from "./redux/store";
|
||||
import MuiThemeProvider from '@material-ui/core/styles/MuiThemeProvider';
|
||||
import createMuiTheme from '@material-ui/core/styles/createMuiTheme';
|
||||
import themeObject from './util/theme';
|
||||
|
||||
// Components
|
||||
import AuthRoute from "./util/AuthRoute";
|
||||
|
||||
import home from "./pages/Home";
|
||||
import register from "./pages/Register";
|
||||
import login from "./pages/Login";
|
||||
import user from "./pages/user";
|
||||
// Pages
|
||||
import home from './pages/Home';
|
||||
import register from './pages/Register';
|
||||
import login from './pages/Login';
|
||||
import user from './pages/user';
|
||||
import writeMicroblog from "./Writing_Microblogs.js";
|
||||
import edit from "./pages/edit.js";
|
||||
import userLine from "./Userline.js";
|
||||
|
||||
// Components
|
||||
import AuthRoute from "./util/AuthRoute";
|
||||
|
||||
let authenticated;
|
||||
const token = localStorage.FBIdToken;
|
||||
if (token) {
|
||||
@ -35,39 +38,29 @@ if (token) {
|
||||
}
|
||||
}
|
||||
|
||||
const theme = createMuiTheme(themeObject);
|
||||
|
||||
class App extends Component {
|
||||
render() {
|
||||
return (
|
||||
<Provider store={store}>
|
||||
<MuiThemeProvider theme={theme}>
|
||||
<Router>
|
||||
<div className="container">
|
||||
<Navbar />
|
||||
</div>
|
||||
<div className="app">
|
||||
<AuthRoute
|
||||
exact
|
||||
path="/"
|
||||
component={home}
|
||||
authenticated={authenticated}
|
||||
/>
|
||||
<AuthRoute
|
||||
exact
|
||||
path="/register"
|
||||
component={register}
|
||||
authenticated={authenticated}
|
||||
/>
|
||||
<AuthRoute
|
||||
exact
|
||||
path="/login"
|
||||
component={login}
|
||||
authenticated={authenticated}
|
||||
/>
|
||||
<Route exact path="/user" component={user} />
|
||||
<Route exact path="/home" component={writeMicroblog} />
|
||||
<Route exact path="/edit" component={edit} />
|
||||
<Route exact path="/userline" component={userLine} />
|
||||
</div>
|
||||
</Router>
|
||||
<div className='container' >
|
||||
<Navbar />
|
||||
</div>
|
||||
<div className="app">
|
||||
<Route exact path="/" component={home}/>
|
||||
<Route exact path="/register" component={register}/>
|
||||
<Route exact path="/login" component={login}/>
|
||||
<Route exact path="/user" component={user}/>
|
||||
<Route exact path="/home" component={writeMicroblog}/>
|
||||
<Route exact path="/edit" component={edit}/>
|
||||
<Route exact path="/user" component={userLine}/>
|
||||
</div>
|
||||
|
||||
</Router>
|
||||
</MuiThemeProvider>
|
||||
</Provider>
|
||||
);
|
||||
}
|
||||
|
||||
@ -2,6 +2,12 @@ import React, { Component } from "react";
|
||||
import { BrowserRouter as Router } from 'react-router-dom';
|
||||
import Route from 'react-router-dom/Route';
|
||||
import axios from 'axios';
|
||||
import Box from '@material-ui/core/Box'
|
||||
import {borders} from '@material-ui/system';
|
||||
import { sizing } from '@material-ui/system';
|
||||
// var moment = require('moment');
|
||||
|
||||
|
||||
|
||||
class Userline extends Component {
|
||||
|
||||
@ -23,20 +29,36 @@ class Userline extends Component {
|
||||
this.setState({microBlogs : post})
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
let sortedPosts = [];
|
||||
const sortedPosts = (this.state.microBlogs).sort((a,b) =>
|
||||
-a.createdAt.localeCompare(b.createdAt)
|
||||
)
|
||||
|
||||
return (
|
||||
<ul>
|
||||
{ this.state.microBlogs.map(microBlog => <p>{microBlog.body}</p>)}
|
||||
</ul>
|
||||
)
|
||||
}
|
||||
<div>
|
||||
<div style={{fontsize: "13px", textAlign: "left", marginLeft: "14px"}}>
|
||||
<p>Userline</p>
|
||||
</div>
|
||||
<Box border={1} width="25%" flex="1" height="auto" m={2} fontSize="13px" textAlign= "left" padding="5px" flexWrap= "wrap" flexDirection= "row" >
|
||||
<div style={{flexWrap: "wrap", flex: "1", flexDirection: "row", wordBreak: "break-word"}}>
|
||||
<p>
|
||||
{sortedPosts.map((microBlog) => <p>Microblog Title: {microBlog.microBlogTitle}
|
||||
<br></br>When post was created: {microBlog.createdAt.substring(0,10) +
|
||||
" " + microBlog.createdAt.substring(11,19)}
|
||||
<br></br>Number of comments: {microBlog.commentCount}
|
||||
<br></br>Number of likes: {microBlog.likeCount}
|
||||
<br></br>Body of post: {microBlog.body}
|
||||
<br></br>Tagged topics: {microBlog.microBlogTopics.join("," + " ")}
|
||||
</p>)}
|
||||
</p>
|
||||
</div>
|
||||
</Box>
|
||||
</div>
|
||||
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
export default Userline;
|
||||
|
||||
@ -12,7 +12,7 @@ class Writing_Microblogs extends Component {
|
||||
value: '',
|
||||
title: '',
|
||||
topics: '',
|
||||
characterCount: 10
|
||||
characterCount: 250
|
||||
|
||||
};
|
||||
|
||||
@ -48,8 +48,9 @@ class Writing_Microblogs extends Component {
|
||||
|
||||
)
|
||||
console.log(response.data);
|
||||
alert('Post was shared successfully!');
|
||||
event.preventDefault();
|
||||
this.setState({value: '', title: '',characterCount: 10, topics: ''})
|
||||
this.setState({value: '', title: '',characterCount: 250, topics: ''})
|
||||
}
|
||||
|
||||
handleChangeforPost(event) {
|
||||
@ -58,7 +59,7 @@ class Writing_Microblogs extends Component {
|
||||
|
||||
handleChangeforCharacterCount(event) {
|
||||
const charCount = event.target.value.length
|
||||
const charRemaining = 10 - charCount
|
||||
const charRemaining = 250 - charCount
|
||||
this.setState({characterCount: charRemaining })
|
||||
|
||||
}
|
||||
@ -80,7 +81,7 @@ class Writing_Microblogs extends Component {
|
||||
|
||||
<div style={{ width: "200px", marginLeft: "50px"}}>
|
||||
<form onSubmit={this.handleSubmit}>
|
||||
<textarea value={this.state.value} required maxLength="10" placeholder= "Write Microblog here..."
|
||||
<textarea value={this.state.value} required maxLength="250" placeholder= "Write Microblog here..."
|
||||
onChange = { (e) => { this.handleChangeforPost(e); this.handleChangeforCharacterCount(e) } } cols={40} rows={20} />
|
||||
<div style={{ fontSize: "14px", marginRight: "-100px"}} >
|
||||
<p2>Characters Left: {this.state.characterCount}</p2>
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
import React, { Component } from "react";
|
||||
import axios from "axios";
|
||||
import PropTypes from "prop-types";
|
||||
/* eslint-disable */
|
||||
import React, { Component } from 'react';
|
||||
import '../App.css';
|
||||
import axios from 'axios';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
import logo from '../images/twistter-logo.png';
|
||||
|
||||
// Material-UI stuff
|
||||
@ -169,5 +172,9 @@ const mapStateToProps = (state) => ({
|
||||
const mapActionsToProps = {
|
||||
loginUser
|
||||
}
|
||||
Login.propTypes = {
|
||||
classes: PropTypes.object.isRequired
|
||||
};
|
||||
|
||||
|
||||
export default connect(mapStateToProps, mapActionsToProps)(withStyles(styles)(Login));
|
||||
|
||||
@ -2,28 +2,96 @@ import React, { Component } from 'react';
|
||||
import '../App.css';
|
||||
|
||||
import logo from '../images/twistter-logo.png';
|
||||
import axios from 'axios';
|
||||
import TextField from '@material-ui/core/TextField';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
|
||||
class Register extends Component {
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.state = {
|
||||
email: '',
|
||||
handle: '',
|
||||
password: '',
|
||||
confirmPassword: '',
|
||||
errors: {}
|
||||
};
|
||||
|
||||
this.handleSubmit = this.handleSubmit.bind(this);
|
||||
this.handleChange = this.handleChange.bind(this);
|
||||
};
|
||||
|
||||
|
||||
handleSubmit = (event) => {
|
||||
const newUserData = {
|
||||
email: this.state.email,
|
||||
handle: this.state.handle,
|
||||
password: this.state.password,
|
||||
confirmPassword: this.state.confirmPassword
|
||||
};
|
||||
axios.post('http://localhost:5001/twistter-e4649/us-central1/api/signup', newUserData)
|
||||
.then(res => {
|
||||
console.log(res.data);
|
||||
localStorage.setItem('firebaseIdToken', `Bearer ${res.data.token}`);
|
||||
this.props.history.push('/');
|
||||
})
|
||||
.catch(err => {
|
||||
this.setState({
|
||||
errors: err.response.data
|
||||
});
|
||||
});
|
||||
alert("You successfully registered");
|
||||
event.preventDefault();
|
||||
this.setState({email: '', handle: '', password: '', confirmPassword: ''});
|
||||
};
|
||||
|
||||
|
||||
handleChange = (event) => {
|
||||
this.setState({
|
||||
[event.target.name]: event.target.value
|
||||
});
|
||||
};
|
||||
|
||||
render() {
|
||||
const { classes } = this.props;
|
||||
const { errors } = this.state;
|
||||
return (
|
||||
<div>
|
||||
<img src={logo} className="app-logo" alt="logo" />
|
||||
<br/><br/>
|
||||
<b>Create your account</b>
|
||||
<br/><br/>
|
||||
<TextField className="authInput" id="email" name="email" label="Email" />
|
||||
<form noValidate onSubmit={this.handleSubmit}>
|
||||
|
||||
<TextField className="authInput" id="email" name="email" label="Email" helperText={errors.email} error={errors.email ? true : false}
|
||||
value={this.state.email} onChange={this.handleChange}/>
|
||||
<br/><br/>
|
||||
<TextField className="authInput" id="username" name="username" label="Username" />
|
||||
<TextField className="authInput" id="username" name="handle" label="Username" helperText={errors.handle} error={errors.handle ? true : false}
|
||||
value={this.state.handle} onChange={this.handleChange} />
|
||||
<br/><br/>
|
||||
<TextField className="authInput" id="password" name="password" label="Password" />
|
||||
<TextField className="authInput" id="password" name="password" label="Password" helperText={errors.password} error={errors.password ? true : false}
|
||||
value={this.state.password} onChange={this.handleChange} />
|
||||
<br/><br/>
|
||||
<TextField className="authInput" id="confirmPassword" name="confirmPassword" label="Confirm Password" />
|
||||
<TextField className="authInput" id="confirmPassword" name="confirmPassword" label="Confirm Password" helperText={errors.confirmPassword} error={errors.confirmPassword ? true : false}
|
||||
value={this.state.confirmPassword} onChange={this.handleChange} />
|
||||
<br/><br/>
|
||||
{
|
||||
errors.general &&
|
||||
(<div className={classes.customError}>
|
||||
{errors.general}
|
||||
</div>)
|
||||
}
|
||||
<button class="authButtons register" id="submit">Sign up</button>
|
||||
</form>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
Register.propTypes = {
|
||||
classes: PropTypes.object.isRequired
|
||||
};
|
||||
|
||||
export default Register;
|
||||
@ -1,40 +1,35 @@
|
||||
/* eslint-disable */
|
||||
import React, { Component } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import StaticProfile from '../components/profile/StaticProfile';
|
||||
//import '../App.css';
|
||||
import { makeStyles, styled } from '@material-ui/core/styles';
|
||||
import Grid from '@material-ui/core/Grid';
|
||||
import Card from '@material-ui/core/Card';
|
||||
import CardMedia from '@material-ui/core/CardMedia';
|
||||
import CardContent from '@material-ui/core/CardContent';
|
||||
|
||||
import PostSkeleton from '../util/PostSkeleton';
|
||||
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
const PostCard = styled(Card)({
|
||||
background: 'linear-gradient(45deg, #1da1f2 90%)',
|
||||
border: 3,
|
||||
borderRadius: 3,
|
||||
height:225,
|
||||
width: 645,
|
||||
padding: '0 30px',
|
||||
});
|
||||
|
||||
class user extends Component {
|
||||
render() {
|
||||
const postMarkup = PostSkeleton;
|
||||
|
||||
return (
|
||||
<b>User page</b>
|
||||
// <Grid container spacing={16}>
|
||||
// <Grid item sm={8} xs={12}>
|
||||
// <b>postMarkup</b>
|
||||
// {postMarkup}
|
||||
// </Grid>
|
||||
// {/* <Grid item sm={4} xs={12}>
|
||||
// <StaticProfile profile={this.state.profile} />
|
||||
// </Grid> */}
|
||||
// </Grid>
|
||||
<div>
|
||||
<h1>User Profile</h1>
|
||||
<br/><br/>
|
||||
<PostCard>Some card and content</PostCard>
|
||||
<br/><br/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
user.propTypes = {
|
||||
// getUserData: PropTypes.func.isRequired,
|
||||
//data: PropTypes.object.isRequired
|
||||
};
|
||||
|
||||
const mapStateToProps = (state) => ({
|
||||
data: state.data
|
||||
});
|
||||
|
||||
export default connect(user);
|
||||
export default user;
|
||||
|
||||
97
twistter-frontend/src/util/theme.js
Normal file
97
twistter-frontend/src/util/theme.js
Normal file
@ -0,0 +1,97 @@
|
||||
export default {
|
||||
palette: {
|
||||
primary: {
|
||||
light: '#1da1f2',
|
||||
main: '#1da1f2',
|
||||
dark: '#008394',
|
||||
contrastText: '#fff'
|
||||
},
|
||||
secondary: {
|
||||
light: '#ff6333',
|
||||
main: '#ff3d00',
|
||||
dark: '#b22a00',
|
||||
contrastText: '#fff'
|
||||
}
|
||||
},
|
||||
typography: {
|
||||
useNextVariants: true
|
||||
},
|
||||
form: {
|
||||
textAlign: 'center'
|
||||
},
|
||||
image: {
|
||||
margin: '20px auto 20px auto'
|
||||
},
|
||||
pageTitle: {
|
||||
margin: '10px auto 10px auto'
|
||||
},
|
||||
textField: {
|
||||
margin: '10px auto 10px auto'
|
||||
},
|
||||
button: {
|
||||
marginTop: 20,
|
||||
position: 'relative'
|
||||
},
|
||||
customError: {
|
||||
color: 'red',
|
||||
fontSize: '0.8rem',
|
||||
marginTop: 10
|
||||
},
|
||||
progress: {
|
||||
position: 'absolute'
|
||||
},
|
||||
invisibleSeparator: {
|
||||
border: 'none',
|
||||
margin: 4
|
||||
},
|
||||
visibleSeparator: {
|
||||
width: '100%',
|
||||
borderBottom: '1px solid rgba(0,0,0,0.1)',
|
||||
marginBottom: 20
|
||||
},
|
||||
paper: {
|
||||
padding: 20
|
||||
},
|
||||
profile: {
|
||||
'& .image-wrapper': {
|
||||
textAlign: 'center',
|
||||
position: 'relative',
|
||||
'& button': {
|
||||
position: 'absolute',
|
||||
top: '80%',
|
||||
left: '70%'
|
||||
}
|
||||
},
|
||||
'& .profile-image': {
|
||||
width: 200,
|
||||
height: 200,
|
||||
objectFit: 'cover',
|
||||
maxWidth: '100%',
|
||||
borderRadius: '50%'
|
||||
},
|
||||
'& .profile-details': {
|
||||
textAlign: 'center',
|
||||
'& span, svg': {
|
||||
verticalAlign: 'middle'
|
||||
},
|
||||
'& a': {
|
||||
color: '#00bcd4'
|
||||
}
|
||||
},
|
||||
'& hr': {
|
||||
border: 'none',
|
||||
margin: '0 0 10px 0'
|
||||
},
|
||||
'& svg.button': {
|
||||
'&:hover': {
|
||||
cursor: 'pointer'
|
||||
}
|
||||
}
|
||||
},
|
||||
buttons: {
|
||||
textAlign: 'center',
|
||||
'& a': {
|
||||
margin: '20px 10px'
|
||||
}
|
||||
}
|
||||
};
|
||||
Loading…
Reference in New Issue
Block a user