mirror of
https://github.com/ClaytonWWilson/CS307-Team24.git
synced 2025-12-16 10:18:48 +00:00
added entering topics field and database call for adding topics when writing microblog
This commit is contained in:
parent
311e8b3716
commit
9d4f175a49
@ -11,6 +11,7 @@ exports.putPost = (req, res) => {
|
|||||||
createdAt: new Date().toISOString(),
|
createdAt: new Date().toISOString(),
|
||||||
likeCount: 0,
|
likeCount: 0,
|
||||||
commentCount: 0,
|
commentCount: 0,
|
||||||
|
microBlogTopics: req.body.microBlogTopics
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -253,7 +253,8 @@ const {putPost, getallPostsforUser} = require('./handlers/post');
|
|||||||
app.get('/getallPostsforUser', getallPostsforUser);
|
app.get('/getallPostsforUser', getallPostsforUser);
|
||||||
|
|
||||||
// Adds one post to the database
|
// Adds one post to the database
|
||||||
app.post('/putPost', fbAuth, putPost);
|
app.post('/putPost', firebaseAuth, putPost);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
exports.api = functions.https.onRequest(app);
|
exports.api = functions.https.onRequest(app);
|
||||||
@ -9,7 +9,8 @@ class Userline extends Component {
|
|||||||
{
|
{
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
microBlogs : []
|
microBlogs : [],
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -24,9 +25,13 @@ class Userline extends Component {
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
let sortedPosts = [];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ul>
|
<ul>
|
||||||
{ this.state.microBlogs.map(microBlog => <p>{microBlog.body}</p>)}
|
{ this.state.microBlogs.map(microBlog => <p>{microBlog.body}</p>)}
|
||||||
|
|||||||
@ -11,6 +11,7 @@ class Writing_Microblogs extends Component {
|
|||||||
this.state = {
|
this.state = {
|
||||||
value: '',
|
value: '',
|
||||||
title: '',
|
title: '',
|
||||||
|
topics: '',
|
||||||
characterCount: 10
|
characterCount: 10
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -19,12 +20,18 @@ class Writing_Microblogs extends Component {
|
|||||||
this.handleChange = this.handleChange.bind(this);
|
this.handleChange = this.handleChange.bind(this);
|
||||||
this.handleSubmit = this.handleSubmit.bind(this);
|
this.handleSubmit = this.handleSubmit.bind(this);
|
||||||
this.handleChangeforPost = this.handleChangeforPost.bind(this);
|
this.handleChangeforPost = this.handleChangeforPost.bind(this);
|
||||||
|
this.handleChangeforTopics = this.handleChangeforTopics.bind(this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handleChange(event) {
|
handleChange(event) {
|
||||||
this.setState( {title: event.target.value });
|
this.setState( {title: event.target.value });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleChangeforTopics(event) {
|
||||||
|
this.setState( {topics: event.target.value});
|
||||||
|
}
|
||||||
|
|
||||||
handleSubmit(event) {
|
handleSubmit(event) {
|
||||||
// alert('A title for the microblog was inputted: ' + this.state.title + '\nA microblog was posted: ' + this.state.value);
|
// alert('A title for the microblog was inputted: ' + this.state.title + '\nA microblog was posted: ' + this.state.value);
|
||||||
|
|
||||||
@ -33,7 +40,8 @@ class Writing_Microblogs extends Component {
|
|||||||
{ body: this.state.value,
|
{ body: this.state.value,
|
||||||
userHandle: "new user",
|
userHandle: "new user",
|
||||||
userImage: "bing-url",
|
userImage: "bing-url",
|
||||||
microBlogTitle: this.state.title
|
microBlogTitle: this.state.title,
|
||||||
|
microBlogTopics: this.state.topics.split(', ')
|
||||||
|
|
||||||
},
|
},
|
||||||
{ headers: { 'Content-Type': 'application/json'} }
|
{ headers: { 'Content-Type': 'application/json'} }
|
||||||
@ -41,7 +49,7 @@ class Writing_Microblogs extends Component {
|
|||||||
)
|
)
|
||||||
console.log(response.data);
|
console.log(response.data);
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
this.setState({value: '', title: '',characterCount: 10})
|
this.setState({value: '', title: '',characterCount: 10, topics: ''})
|
||||||
}
|
}
|
||||||
|
|
||||||
handleChangeforPost(event) {
|
handleChangeforPost(event) {
|
||||||
@ -55,13 +63,18 @@ class Writing_Microblogs extends Component {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div style={{ width: "200px", height: "50px", marginTop: "180px", marginLeft: "30px" }}>
|
<div style={{ width: "200px", height: "50px", marginTop: "180px", marginLeft: "50px" }}>
|
||||||
<form>
|
<form>
|
||||||
<input type="text" placeholder="Enter Microblog Title" value={this.state.title} onChange={this.handleChange} />
|
<textarea placeholder="Enter Microblog Title" value={this.state.title} required onChange={this.handleChange} cols={30} rows={1} />
|
||||||
|
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div style={{ width: "200px", height: "50px", marginLeft: "50px"}} >
|
||||||
|
<form>
|
||||||
|
<textarea placeholder="Enter topics seperated by a comma" value={this.state.topics} required onChange={this.handleChangeforTopics} cols={40} rows={1} />
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user