Fixing errors on the otherUsers page

This commit is contained in:
Clayton Wilson 2019-12-05 21:39:38 -05:00
parent c85eeccd4c
commit a1f9a4bef3

View File

@ -179,7 +179,10 @@ class user extends Component {
}) })
.catch(err => console.log(err)); .catch(err => console.log(err));
axios // Only add Admin posts if this is not the Admin account
let alertPromise;
if (this.state.profile !== "Admin") {
alertPromise = axios
.get("/getAlert") .get("/getAlert")
.then(res => { .then(res => {
let temp = this.state.posts; let temp = this.state.posts;
@ -195,8 +198,14 @@ class user extends Component {
.catch(function(err) { .catch(function(err) {
console.log(err); console.log(err);
}); });
} else {
alertPromise = new Promise((resolve, reject) => {
resolve();
})
}
Promise.all([otherUserPromise, userPromise, posts])
Promise.all([otherUserPromise, userPromise, posts, alertPromise])
.then(() => { .then(() => {
this.setState({ loading: false }); this.setState({ loading: false });
}) })
@ -245,14 +254,14 @@ class user extends Component {
this.state.myTopics.includes(topic) ? ( this.state.myTopics.includes(topic) ? (
<MyChip <MyChip
label={topic} label={topic}
key={{ topic }.topic.id} key={{ topic }.topic.id} // BUG: this value is undefined
onDelete onDelete
deleteIcon={<DoneIcon />} deleteIcon={<DoneIcon />}
/> />
) : ( ) : (
<MyChip <MyChip
label={topic} label={topic}
key={{ topic }.topic.id} key={{ topic }.topic.id} // BUG: this value is undefined
color="secondary" color="secondary"
clickable clickable
onClick={key => this.handleAdd(topic)} onClick={key => this.handleAdd(topic)}
@ -275,7 +284,7 @@ class user extends Component {
//(this.state.posts); //(this.state.posts);
let postMarkup = this.state.posts ? ( let postMarkup = this.state.posts ? (
this.state.posts.map(post => ( this.state.posts.map(post => (
<Card className={classes.card}> <Card className={classes.card} key={post.postId} data-key={post.postId}>
<CardContent> <CardContent>
<Typography> <Typography>
{this.state.imageUrl ? ( {this.state.imageUrl ? (
@ -284,7 +293,7 @@ class user extends Component {
<img src={noImage} height="50" width="50" /> <img src={noImage} height="50" width="50" />
)} )}
</Typography> </Typography>
<Typography variant="h7"> <Typography variant="h4">
<b>{post.userHandle}</b> <b>{post.userHandle}</b>
</Typography> </Typography>
<Typography variant="body2" color={"textSecondary"}> <Typography variant="body2" color={"textSecondary"}>
@ -320,7 +329,7 @@ class user extends Component {
style={{ marginTop: "300px" }} style={{ marginTop: "300px" }}
></CircularProgress> ></CircularProgress>
) : ( ) : (
<Grid container spacing={24}> <Grid container spacing={10}>
<Grid item sm={4} xs={8}> <Grid item sm={4} xs={8}>
{imageMarkup} {imageMarkup}
{profileMarkup} {profileMarkup}