This commit is contained in:
Aditya Sankaran
2019-11-01 13:20:34 -04:00
parent 6dbca16ace
commit cc20e30990
6 changed files with 96 additions and 20 deletions

View File

@@ -3121,6 +3121,11 @@
"merge": "^1.2.0"
}
},
"exenv": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/exenv/-/exenv-1.2.2.tgz",
"integrity": "sha1-KueOhdmJQVhnCwPUe+wfA72Ru50="
},
"exit-hook": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/exit-hook/-/exit-hook-1.1.1.tgz",
@@ -7270,6 +7275,17 @@
"resolved": "https://registry.npmjs.org/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz",
"integrity": "sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA=="
},
"react-modal": {
"version": "3.11.1",
"resolved": "https://registry.npmjs.org/react-modal/-/react-modal-3.11.1.tgz",
"integrity": "sha512-8uN744Yq0X2lbfSLxsEEc2UV3RjSRb4yDVxRQ1aGzPo86QjNOwhQSukDb8U8kR+636TRTvfMren10fgOjAy9eA==",
"requires": {
"exenv": "^1.2.0",
"prop-types": "^15.5.10",
"react-lifecycles-compat": "^3.0.0",
"warning": "^4.0.3"
}
},
"react-overlays": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/react-overlays/-/react-overlays-1.2.0.tgz",

View File

@@ -18,6 +18,7 @@
"react-bootstrap": "^1.0.0-beta.14",
"react-dom": "^16.9.0",
"react-dropdown": "^1.6.4",
"react-modal": "^3.11.1",
"react-redux": "^7.1.1",
"react-router-dom": "^5.1.0",
"react-scripts": "0.9.5",

View File

@@ -9,38 +9,33 @@ class Like extends Component {
super(props);
this.state = {
like : false,
Id : null
};
this.handleSubmit = this.handleSubmit.bind(this);
}
handleSubmit = post => {
handleSubmit(){
this.setState({
like: !this.state.like
});
axios.get("https://us-central1-twistter-e4649.cloudfunctions.net/api/getallPostsforFeed")
.then((res) => {
const postData = res.data;
this.setState({Id: postData.id})
})
const postId = "AJdhYAE4diocF8UcrHDq"
if(this.state.like == false)
{
axios.get(`/putPost/${this.state.Id}/like`)
axios.get(`/putPost/${postId}/like`)
.then((res) => {
console.log(res.data);
})
}
else
{
axios.get(`/putPost/${this.state.Id}/unlike`)
axios.get(`/putPost/${postId}/unlike`)
.then((res) => {
console.log(res.data);
})

View File

@@ -2,6 +2,8 @@ import React, { Component } from "react";
import { BrowserRouter as Router } from 'react-router-dom';
import Route from 'react-router-dom/Route';
import axios from 'axios';
import Modal from "react-modal";
@@ -11,7 +13,7 @@ class Quote extends Component {
constructor(props) {
super(props);
this.state = {
value : ''
post: null
};
this.handleSubmit = this.handleSubmit.bind(this);
this.handleSubmit2 = this.handleSubmit2.bind(this);
@@ -19,11 +21,48 @@ class Quote extends Component {
}
handleSubmit() {
handleSubmit2() {
const postId = "AJdhYAE4diocF8UcrHDq";
const postNoComment = {
body : ""
}
const headers = {
headers: { 'Content-Type': 'application/json'}
}
axios.post(`/putPost/${postId}/quote`, postNoComment, headers)
.then((res) =>{
alert('Quoting was successful!')
console.log(res.data);
})
.catch((err) => {
alert('An error occured.');
console.error(err);
})
event.preventDefault();
}
handleSubmit2() {
handleSubmit() {
const postId = "AJdhYAE4diocF8UcrHDq";
const postComment = {
body : ""
}
const headers = {
headers: { 'Content-Type': 'application/json'}
}
axios
.post(`/putPost/${postId}/quote`, postComment, headers)
.then((res) =>{
alert('Quoting was successful!')
console.log(res.data);
})
.catch((err) => {
alert('An error occured.');
console.error(err);
})
event.preventDefault();
}
render() {