From f13580c72754862fb636d5d6da4e0b9b6c1c6a2c Mon Sep 17 00:00:00 2001
From: Leon Liang
Date: Fri, 25 Oct 2019 01:56:07 -0400
Subject: [PATCH] display topics under profile
---
twistter-frontend/src/pages/user.js | 54 +++++++++++++++++++++++++----
twistter-frontend/src/util/theme.js | 8 ++++-
2 files changed, 54 insertions(+), 8 deletions(-)
diff --git a/twistter-frontend/src/pages/user.js b/twistter-frontend/src/pages/user.js
index 7ace6bc..435c92c 100644
--- a/twistter-frontend/src/pages/user.js
+++ b/twistter-frontend/src/pages/user.js
@@ -11,7 +11,7 @@ import CardContent from '@material-ui/core/CardContent';
import Chip from '@material-ui/core/Chip';
import Paper from '@material-ui/core/Paper';
import Typography from "@material-ui/core/Typography";
-
+import AddCircle from '@material-ui/icons/AddCircle';
// component
import Profile from '../components/profile/Profile';
@@ -28,29 +28,63 @@ const PostCard = styled(Card)({
padding: '0 30px',
});
+const MyChip = styled(Chip)({
+ margin: 2,
+ color: 'primary'
+});
-class user extends Component {
+
+const styles = (theme) => ({
+ ...theme
+});
+
+const handleDelete = () => {
+ alert("Delete this topic!");
+}
+
+const handleAddCircle = () => {
+ alert("Add topic");
+}
+
+class user extends Component {
state = {
- profile: null
+ profile: null,
+ topics: null
};
componentDidMount() {
axios
.get("/user")
.then(res => {
- console.log(res.data.userData.credentials.handle);
+ console.log(res.data.credentials.handle);
this.setState({
- profile: res.data.userData.credentials.handle
+ profile: res.data.credentials.handle
});
})
.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() {
-
+ const classes = this.props;
let profileMarkup = this.state.profile ? (
{this.state.profile}
-
) : loading profile...
+
) : (loading username...
);
+
+
+ let topicsMarkup = this.state.topics ? (
+ this.state.topics.map(topic => )
+ ) : ( loading topics...
);
return (
@@ -60,6 +94,12 @@ class user extends Component {
{profileMarkup}
+ {topicsMarkup}
+ }
+ clickable
+ onClick={handleAddCircle}
+ />
);
diff --git a/twistter-frontend/src/util/theme.js b/twistter-frontend/src/util/theme.js
index 38622a6..2ac393e 100644
--- a/twistter-frontend/src/util/theme.js
+++ b/twistter-frontend/src/util/theme.js
@@ -50,7 +50,13 @@ export default {
marginBottom: 20
},
paper: {
- padding: 20
+ padding: 10,
+ display: 'flex',
+ justifyContent: 'center',
+ flexWrap: 'wrap'
+ },
+ chip: {
+ margin: 0.5,
},
profile: {
'& .image-wrapper': {