Merge pull request #45 from ClaytonWWilson/display_topic

Display topic
This commit is contained in:
Leon Liang 2019-10-25 01:57:14 -04:00 committed by GitHub
commit b255006f7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 54 additions and 8 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

After

Width:  |  Height:  |  Size: 48 KiB

View File

@ -11,7 +11,7 @@ import CardContent from '@material-ui/core/CardContent';
import Chip from '@material-ui/core/Chip'; import Chip from '@material-ui/core/Chip';
import Paper from '@material-ui/core/Paper'; import Paper from '@material-ui/core/Paper';
import Typography from "@material-ui/core/Typography"; import Typography from "@material-ui/core/Typography";
import AddCircle from '@material-ui/icons/AddCircle';
// component // component
import Profile from '../components/profile/Profile'; import Profile from '../components/profile/Profile';
@ -28,29 +28,63 @@ const PostCard = styled(Card)({
padding: '0 30px', padding: '0 30px',
}); });
const MyChip = styled(Chip)({
margin: 2,
color: 'primary'
});
const styles = (theme) => ({
...theme
});
const handleDelete = () => {
alert("Delete this topic!");
}
const handleAddCircle = () => {
alert("Add topic");
}
class user extends Component { class user extends Component {
state = { state = {
profile: null profile: null,
topics: null
}; };
componentDidMount() { componentDidMount() {
axios axios
.get("/user") .get("/user")
.then(res => { .then(res => {
console.log(res.data.userData.credentials.handle); console.log(res.data.credentials.handle);
this.setState({ this.setState({
profile: res.data.userData.credentials.handle profile: res.data.credentials.handle
}); });
}) })
.catch(err => console.log(err)); .catch(err => console.log(err));
axios
.get("/getAllTopics")
.then(res => {
console.log(res.data[1]);
this.setState({
topics: res.data
})
})
.catch(err => console.log(err));
} }
render() { render() {
const classes = this.props;
let profileMarkup = this.state.profile ? ( let profileMarkup = this.state.profile ? (
<p> <p>
<Typography variant='h5'>{this.state.profile}</Typography> <Typography variant='h5'>{this.state.profile}</Typography>
</p>) : <p>loading profile...</p> </p>) : (<p>loading username...</p>);
let topicsMarkup = this.state.topics ? (
this.state.topics.map(topic => <MyChip
label={{topic}.topic.topic}
onDelete={handleDelete}/>)
) : (<p> loading topics...</p>);
return ( return (
<Grid container spacing={16}> <Grid container spacing={16}>
@ -60,6 +94,12 @@ class user extends Component {
<Grid item sm={4} xs={12}> <Grid item sm={4} xs={12}>
<img src={noImage}/> <img src={noImage}/>
{profileMarkup} {profileMarkup}
{topicsMarkup}
<MyChip
icon={<AddCircle />}
clickable
onClick={handleAddCircle}
/>
</Grid> </Grid>
</Grid> </Grid>
); );

View File

@ -50,7 +50,13 @@ export default {
marginBottom: 20 marginBottom: 20
}, },
paper: { paper: {
padding: 20 padding: 10,
display: 'flex',
justifyContent: 'center',
flexWrap: 'wrap'
},
chip: {
margin: 0.5,
}, },
profile: { profile: {
'& .image-wrapper': { '& .image-wrapper': {