mirror of
https://github.com/ClaytonWWilson/CS307-Team24.git
synced 2025-12-16 02:08:47 +00:00
change topic display to user-specific topics
This commit is contained in:
parent
607ea3fd55
commit
3da2449050
@ -1,44 +1,44 @@
|
||||
/* eslint-disable */
|
||||
import React, { Component } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { connect } from 'react-redux';
|
||||
import axios from 'axios';
|
||||
import React, { Component } from "react";
|
||||
import PropTypes from "prop-types";
|
||||
import { connect } from "react-redux";
|
||||
import axios from "axios";
|
||||
//import '../App.css';
|
||||
// Material-UI
|
||||
import withStyles from '@material-ui/core/styles/withStyles';
|
||||
import { makeStyles, styled } from '@material-ui/core/styles';
|
||||
import { Link } from 'react-router-dom';
|
||||
import Card from '@material-ui/core/Card';
|
||||
import CardMedia from '@material-ui/core/CardMedia';
|
||||
import CardContent from '@material-ui/core/CardContent';
|
||||
import Button from '@material-ui/core/Button';
|
||||
import Grid from '@material-ui/core/Grid';
|
||||
import withStyles from "@material-ui/core/styles/withStyles";
|
||||
import { makeStyles, styled } from "@material-ui/core/styles";
|
||||
import { Link } from "react-router-dom";
|
||||
import Card from "@material-ui/core/Card";
|
||||
import CardMedia from "@material-ui/core/CardMedia";
|
||||
import CardContent from "@material-ui/core/CardContent";
|
||||
import Button from "@material-ui/core/Button";
|
||||
import Grid from "@material-ui/core/Grid";
|
||||
|
||||
import Chip from '@material-ui/core/Chip';
|
||||
import Typography from '@material-ui/core/Typography';
|
||||
import AddCircle from '@material-ui/icons/AddCircle';
|
||||
import TextField from '@material-ui/core/TextField';
|
||||
import VerifiedIcon from '@material-ui/icons/CheckSharp';
|
||||
import Paper from '@material-ui/core/Paper';
|
||||
import GridList from '@material-ui/core/GridList';
|
||||
import GridListTile from '@material-ui/core/GridListTile';
|
||||
import GridListTileBar from '@material-ui/core/GridListTileBar';
|
||||
import Container from '@material-ui/core/Container';
|
||||
import Chip from "@material-ui/core/Chip";
|
||||
import Typography from "@material-ui/core/Typography";
|
||||
import AddCircle from "@material-ui/icons/AddCircle";
|
||||
import TextField from "@material-ui/core/TextField";
|
||||
import VerifiedIcon from "@material-ui/icons/CheckSharp";
|
||||
import Paper from "@material-ui/core/Paper";
|
||||
import GridList from "@material-ui/core/GridList";
|
||||
import GridListTile from "@material-ui/core/GridListTile";
|
||||
import GridListTileBar from "@material-ui/core/GridListTileBar";
|
||||
import Container from "@material-ui/core/Container";
|
||||
|
||||
// component
|
||||
import '../App.css';
|
||||
import noImage from '../images/no-img.png';
|
||||
import Writing_Microblogs from '../Writing_Microblogs';
|
||||
import "../App.css";
|
||||
import noImage from "../images/no-img.png";
|
||||
import Writing_Microblogs from "../Writing_Microblogs";
|
||||
|
||||
const MyChip = styled(Chip)({
|
||||
margin: 2,
|
||||
color: 'primary'
|
||||
color: "primary"
|
||||
});
|
||||
|
||||
const styles = {
|
||||
button: {
|
||||
positon: 'relative',
|
||||
float: 'left',
|
||||
positon: "relative",
|
||||
float: "left",
|
||||
marginLeft: 30,
|
||||
marginTop: 20
|
||||
},
|
||||
@ -53,7 +53,7 @@ const styles = {
|
||||
marginTop: 20
|
||||
},
|
||||
topicsContainer: {
|
||||
border: 'lightgray solid 1px',
|
||||
border: "lightgray solid 1px",
|
||||
marginTop: 20,
|
||||
paddingTop: 10,
|
||||
paddingBottom: 10,
|
||||
@ -77,7 +77,7 @@ class user extends Component {
|
||||
newTopic: null
|
||||
};
|
||||
|
||||
handleDelete = (topic) => {
|
||||
handleDelete = topic => {
|
||||
axios
|
||||
.delete(`/deleteTopic/${topic.id}`)
|
||||
.then(function() {
|
||||
@ -90,7 +90,7 @@ class user extends Component {
|
||||
|
||||
handleAddCircle = () => {
|
||||
axios
|
||||
.post('/putTopic', {
|
||||
.post("/putTopic", {
|
||||
topic: this.state.newTopic
|
||||
})
|
||||
.then(function() {
|
||||
@ -109,34 +109,28 @@ class user extends Component {
|
||||
|
||||
componentDidMount() {
|
||||
axios
|
||||
.get('/user')
|
||||
.then((res) => {
|
||||
.get("/user")
|
||||
.then(res => {
|
||||
this.setState({
|
||||
profile: res.data.credentials.handle,
|
||||
imageUrl: res.data.credentials.imageUrl,
|
||||
verified: res.data.credentials.verified ? res.data.credentials.verified : false
|
||||
verified: res.data.credentials.verified
|
||||
? res.data.credentials.verified
|
||||
: false,
|
||||
topics: res.data.credentials.followedTopics
|
||||
});
|
||||
})
|
||||
.catch((err) => console.log(err));
|
||||
.catch(err => console.log(err));
|
||||
|
||||
axios
|
||||
.get('/getAllTopics')
|
||||
.then((res) => {
|
||||
this.setState({
|
||||
topics: res.data
|
||||
});
|
||||
})
|
||||
.catch((err) => console.log(err));
|
||||
|
||||
axios
|
||||
.get('/getallPostsforUser')
|
||||
.then((res) => {
|
||||
.get("/getallPostsforUser")
|
||||
.then(res => {
|
||||
console.log(res.data);
|
||||
this.setState({
|
||||
posts: res.data
|
||||
});
|
||||
})
|
||||
.catch((err) => console.log(err));
|
||||
.catch(err => console.log(err));
|
||||
}
|
||||
|
||||
render() {
|
||||
@ -146,7 +140,10 @@ class user extends Component {
|
||||
let profileMarkup = this.state.profile ? (
|
||||
<div>
|
||||
<Typography variant="h5" className={classes.username}>
|
||||
@{this.state.profile} {this.state.verified ? <VerifiedIcon style={{ fill: '#1397D5' }} /> : null}
|
||||
@{this.state.profile}{" "}
|
||||
{this.state.verified ? (
|
||||
<VerifiedIcon style={{ fill: "#1397D5" }} />
|
||||
) : null}
|
||||
</Typography>
|
||||
</div>
|
||||
) : (
|
||||
@ -155,11 +152,11 @@ class user extends Component {
|
||||
|
||||
let topicsMarkup = this.state.topics ? (
|
||||
this.state.topics.map(
|
||||
(topic) => (
|
||||
topic => (
|
||||
<MyChip
|
||||
label={{ topic }.topic.topic}
|
||||
key={{ topic }.topic.id}
|
||||
onDelete={(key) => this.handleDelete(topic)}
|
||||
label={topic}
|
||||
key={topic.id}
|
||||
onDelete={key => this.handleDelete(topic)}
|
||||
/>
|
||||
) // console.log({ topic }.topic.id)
|
||||
)
|
||||
@ -168,13 +165,23 @@ class user extends Component {
|
||||
);
|
||||
|
||||
let imageMarkup = this.state.imageUrl ? (
|
||||
<img className={classes.profileImage} src={this.state.imageUrl} height="250" width="250" />
|
||||
<img
|
||||
className={classes.profileImage}
|
||||
src={this.state.imageUrl}
|
||||
height="250"
|
||||
width="250"
|
||||
/>
|
||||
) : (
|
||||
<img className={classes.profileImage} src={noImage} height="250" width="250" />
|
||||
<img
|
||||
className={classes.profileImage}
|
||||
src={noImage}
|
||||
height="250"
|
||||
width="250"
|
||||
/>
|
||||
);
|
||||
|
||||
let postMarkup = this.state.posts ? (
|
||||
this.state.posts.map((post) => (
|
||||
this.state.posts.map(post => (
|
||||
<Card className={classes.card}>
|
||||
<CardContent>
|
||||
<Typography>
|
||||
@ -187,7 +194,7 @@ class user extends Component {
|
||||
<Typography variant="h7">
|
||||
<b>{post.userHandle}</b>
|
||||
</Typography>
|
||||
<Typography variant="body2" color={'textSecondary'}>
|
||||
<Typography variant="body2" color={"textSecondary"}>
|
||||
{post.createdAt}
|
||||
</Typography>
|
||||
<br />
|
||||
@ -200,7 +207,7 @@ class user extends Component {
|
||||
<b>Topics:</b> {post.microBlogTopics}
|
||||
</Typography>
|
||||
<br />
|
||||
<Typography variant="body2" color={'textSecondary'}>
|
||||
<Typography variant="body2" color={"textSecondary"}>
|
||||
Likes {post.likeCount} Comments {post.commentCount}
|
||||
</Typography>
|
||||
</CardContent>
|
||||
@ -254,7 +261,7 @@ class user extends Component {
|
||||
margin="normal"
|
||||
variant="outlined"
|
||||
value={this.state.newTopic}
|
||||
onChange={(event) => this.handleChange(event)}
|
||||
onChange={event => this.handleChange(event)}
|
||||
/>
|
||||
<AddCircle
|
||||
className={classes.addCircle}
|
||||
@ -279,7 +286,7 @@ class user extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
const mapStateToProps = (state) => ({
|
||||
const mapStateToProps = state => ({
|
||||
user: state.user
|
||||
});
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user