-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ft(comment): User should comment on article: (#35)
- fetch all comments - fetch all replies to comment - post comment - post reply to comment [Maintains #164798170]
- Loading branch information
Showing
23 changed files
with
358 additions
and
209 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,38 @@ | ||
import axios from 'axios'; | ||
import notification from '../utils/Notify'; | ||
|
||
|
||
export const successRating = data => ({ | ||
type: 'RATING_SUCCESSFUL', | ||
data, | ||
}); | ||
|
||
export const startAction = () => ({ | ||
type: 'RATING_STARTED', | ||
}); | ||
|
||
export const failedRating = err => ({ | ||
type: 'RATING_FAILED', | ||
err, | ||
}); | ||
|
||
const { baseURL } = process.env; | ||
export const userRating = (ratingData, slug) => (dispatch) => { | ||
const url = `${baseURL}/articles/${slug}/rate`; | ||
const headers = { | ||
Authorization: `Bearer ${localStorage.getItem('accessToken')}`, | ||
'Content-Type': 'application/json', | ||
}; | ||
|
||
dispatch(startAction()); | ||
return axios.post(url, ratingData, { headers }) | ||
.then((data) => { | ||
if (data.data) { | ||
dispatch(successRating(data.data)); | ||
notification(data.data.message, 'success', 5000); | ||
} else { | ||
dispatch(failedRating(data.error.message)); | ||
notification(data.error, 'success', 5000); | ||
} | ||
}); | ||
}; |
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 |
---|---|---|
|
@@ -251,3 +251,10 @@ i { | |
} | ||
|
||
|
||
.fa-star{ | ||
color: #ffb400 | ||
} | ||
.rating-comp, .rating-comp{ | ||
text-align: center; | ||
font-size: 30px; | ||
} |
This file was deleted.
Oops, something went wrong.
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,67 @@ | ||
import React from 'react'; | ||
import StarRatingComponent from 'react-star-rating-component'; | ||
|
||
const Rating = props => ( | ||
<div> | ||
<a | ||
className="ratingButton" | ||
data-toggle="modal" | ||
data-target="#exampleModalCenter" | ||
href="#modal1" | ||
> | ||
Rate This Article | ||
</a> | ||
<div | ||
className="modal fade" | ||
id="exampleModalCenter" | ||
tabIndex="-1" | ||
role="dialog" | ||
aria-labelledby="exampleModalCenterTitle" | ||
aria-hidden="true" | ||
> | ||
<div className="modal-dialog modal-dialog-centered" role="document"> | ||
<div className="modal-content"> | ||
<div className="modal-header"> | ||
<h5 className="modal-title rating-title" id="exampleModalLongTitle"> | ||
Your Rating is | ||
{' '} | ||
{' '} | ||
{props.rating} | ||
</h5> | ||
<button | ||
type="button" | ||
className="close" | ||
data-dismiss="modal" | ||
aria-label="Close" | ||
> | ||
<span aria-hidden="true">×</span> | ||
</button> | ||
</div> | ||
<div className="modal-body"> | ||
<div className="form-group rating-comp"> | ||
<StarRatingComponent | ||
name={props.name} | ||
starCount={props.starCount} | ||
value={props.value} | ||
onStarClick={props.onStarClick} | ||
/> | ||
</div> | ||
</div> | ||
<div className="modal-footer"> | ||
<button | ||
type="submit" | ||
className="btn btn-secondary pagButton" | ||
data-dismiss="modal" | ||
onClick={props.onSubmit} | ||
> | ||
Submit | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
</div> | ||
); | ||
|
||
export default Rating; |
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,44 @@ | ||
import React, { Component } from 'react'; | ||
import { connect } from 'react-redux'; | ||
import Rating from '../../components/Ratings'; | ||
import { userRating } from '../../actions/ratingActions'; | ||
|
||
export class RatingContainer extends Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
ratings: 1, | ||
}; | ||
} | ||
|
||
onStarClick = (nextValue, prevValue, name) => { | ||
this.setState({ ratings: nextValue }); | ||
}; | ||
|
||
onSubmit = () => { | ||
const { slug } = this.props; | ||
const ratingData = { ratings: this.state.ratings }; | ||
this.props.userRating(ratingData, slug); | ||
}; | ||
|
||
render() { | ||
const { ratings } = this.state; | ||
return ( | ||
<div> | ||
<Rating | ||
name="rate1" | ||
starCount={5} | ||
value={ratings} | ||
onStarClick={this.onStarClick} | ||
rating={ratings} | ||
onSubmit={this.onSubmit} | ||
/> | ||
|
||
</div> | ||
); | ||
} | ||
} | ||
export const mapStateToProps = state => ( | ||
{ ratingReducer: state.ratingReducer } | ||
); | ||
export default connect(mapStateToProps, { userRating })(RatingContainer); |
Oops, something went wrong.