mirror of
https://github.com/ClaytonWWilson/CS307-Team24.git
synced 2025-12-15 18:08:46 +00:00
Fixing errors on the otherUsers page
This commit is contained in:
parent
c85eeccd4c
commit
a1f9a4bef3
@ -179,24 +179,33 @@ 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
|
||||||
.get("/getAlert")
|
let alertPromise;
|
||||||
.then(res => {
|
if (this.state.profile !== "Admin") {
|
||||||
let temp = this.state.posts;
|
alertPromise = axios
|
||||||
// console.log(res.data);
|
.get("/getAlert")
|
||||||
res.data.forEach(element => {
|
.then(res => {
|
||||||
element ? temp.push(element) : console.err;
|
let temp = this.state.posts;
|
||||||
});
|
// console.log(res.data);
|
||||||
// temp.push(res.data[0]);
|
res.data.forEach(element => {
|
||||||
this.setState({
|
element ? temp.push(element) : console.err;
|
||||||
posts: temp
|
});
|
||||||
|
// temp.push(res.data[0]);
|
||||||
|
this.setState({
|
||||||
|
posts: temp
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(function(err) {
|
||||||
|
console.log(err);
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
alertPromise = new Promise((resolve, reject) => {
|
||||||
|
resolve();
|
||||||
})
|
})
|
||||||
.catch(function(err) {
|
}
|
||||||
console.log(err);
|
|
||||||
});
|
|
||||||
|
|
||||||
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}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user