mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Remove redux from detailed rating component
This commit is contained in:
parent
4a38f877a0
commit
d188b18bc5
@ -21,8 +21,8 @@ class DetailedRating extends React.Component{
|
|||||||
this.getData(this.props.uuid);
|
this.getData(this.props.uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidUpdate(nextProps) {
|
componentDidUpdate(prevProps, prevState) {
|
||||||
if (nextProps !== this.props) {
|
if (prevProps.uuid !== this.props.uuid) {
|
||||||
this.getData(this.props.uuid);
|
this.getData(this.props.uuid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,31 +1,52 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import {Row, Typography, Icon} from "antd";
|
import {Row, Typography, Icon} from "antd";
|
||||||
import StarRatings from "react-star-ratings";
|
import StarRatings from "react-star-ratings";
|
||||||
|
import axios from "axios";
|
||||||
import "./DetailedRating.css";
|
import "./DetailedRating.css";
|
||||||
import {connect} from "react-redux";
|
import config from "../../../../public/conf/config.json";
|
||||||
import {getDetailedRating} from "../../../js/actions";
|
|
||||||
|
|
||||||
const { Text } = Typography;
|
const { Text } = Typography;
|
||||||
|
|
||||||
// connecting state. with the component
|
class DetailedRating extends React.Component{
|
||||||
const mapStateToProps= state => {
|
|
||||||
return {detailedRating : state.detailedRating}
|
|
||||||
};
|
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => ({
|
constructor(props){
|
||||||
getDetailedRating: (uuid) => dispatch(getDetailedRating(uuid))
|
super(props);
|
||||||
});
|
this.state={
|
||||||
|
detailedRating: null
|
||||||
|
}
|
||||||
|
|
||||||
class ConnectedDetailedRating extends React.Component{
|
|
||||||
|
|
||||||
componentDidMount() {
|
|
||||||
this.props.getDetailedRating(this.props.uuid);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
this.getData(this.props.uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidUpdate(prevProps, prevState) {
|
||||||
|
if (prevProps.uuid !== this.props.uuid) {
|
||||||
|
this.getData(this.props.uuid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getData = (uuid)=>{
|
||||||
|
const request = "method=get&content-type=application/json&payload={}&api-endpoint=/application-mgt-store/v1.0/reviews/"+uuid+"/rating";
|
||||||
|
|
||||||
|
return axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request
|
||||||
|
).then(res => {
|
||||||
|
if (res.status === 200) {
|
||||||
|
let detailedRating = res.data.data;
|
||||||
|
this.setState({
|
||||||
|
detailedRating
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
}).catch(function (error) {
|
||||||
|
if (error.response.status === 401) {
|
||||||
|
window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const detailedRating = this.props.detailedRating;
|
const detailedRating = this.state.detailedRating;
|
||||||
|
|
||||||
console.log(detailedRating);
|
console.log(detailedRating);
|
||||||
|
|
||||||
@ -96,6 +117,5 @@ class ConnectedDetailedRating extends React.Component{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const DetailedRating = connect(mapStateToProps,mapDispatchToProps)(ConnectedDetailedRating);
|
|
||||||
|
|
||||||
export default DetailedRating;
|
export default DetailedRating;
|
||||||
Loading…
Reference in New Issue
Block a user