-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
199 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
const express = require('express') | ||
const router = express.Router() | ||
const passport = require('../passport') | ||
const Comment = require('../database/models/comments') | ||
|
||
router.put('/', (req, res) => { | ||
|
||
const id = req.body.id; | ||
const comment = { | ||
text: req.body.comment | ||
} | ||
|
||
Comment.findByIdAndUpdate( | ||
{ _id: id }, | ||
{ $set: comment }, | ||
(err, data) => { | ||
if (err) { | ||
console.log('put error: ', err); | ||
res.sendStatus(500); | ||
} else { | ||
console.log('comments update success: '); | ||
console.log(data); | ||
res.sendStatus(200); | ||
} | ||
} | ||
); | ||
}); | ||
|
||
module.exports = router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import axios from 'axios'; | ||
const url = '/comment/edit'; | ||
|
||
export default function editComment(commentObj) { | ||
return dispatch => { | ||
console.log('editComment action comment: '); | ||
console.log(commentObj); | ||
axios.put(url, commentObj).then(res => { | ||
console.log('editComment action res.data'); | ||
console.log(res.data); | ||
|
||
axios.get('/injury/info', { | ||
params: { | ||
id: commentObj.injuryId | ||
} | ||
}).then(res => { | ||
console.log('editComment get action res.data'); | ||
console.log(res.data); | ||
|
||
dispatch(editCommentAsync(res.data)); | ||
}).catch(function (error) { | ||
console.log('error editComment get : '); | ||
console.log(error); | ||
}); | ||
|
||
dispatch(editCommentAsync(res.data)); | ||
}).catch((error) => { | ||
console.log('error editComment : '); | ||
console.log(error); | ||
dispatch(editCommentAsync('fail')); | ||
}); | ||
} | ||
} | ||
|
||
function editCommentAsync(payload) { | ||
return { | ||
type: 'GET_INJURY_INFO', | ||
payload: payload | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters