Complete edit release functionality

feature/appm-store/pbac
Jayasanka 5 years ago
parent aaefdb36fc
commit 2d2efb1b30

@ -42,13 +42,6 @@ class CurrentUsersReview extends React.Component {
});
};
updateCallback = (response) =>{
const {rating, content} = response;
this.setState({
rating,
content
});
};
render() {
const {data} = this.state;
@ -67,7 +60,7 @@ class CurrentUsersReview extends React.Component {
dataSource={data}
renderItem={item => (
<List.Item key={item.id}>
<SingleReview uuid={uuid} review={item} isDeletable={true} isEditable={true} updateCallback={this.updateCallback}/>
<SingleReview uuid={uuid} review={item} isDeletable={true} isEditable={true}/>
</List.Item>
)}
>

@ -10,16 +10,44 @@ const {Text, Paragraph} = Typography;
const colorList = ['#f0932b', '#badc58', '#6ab04c', '#eb4d4b', '#0abde3', '#9b59b6', '#3498db', '#22a6b3','#e84393','#f9ca24'];
class SingleReview extends React.Component {
constructor(props) {
super(props);
this.state = {
content: '',
rating: 0,
color: '#f0932b'
}
}
componentDidMount() {
const {content, rating, username} = this.props.review;
const color = colorList[username.length%10];
this.setState({
content,
rating,
color
});
}
updateCallback = (response) =>{
console.log(response);
const {rating, content} = response;
this.setState({
rating,
content
});
};
render() {
const {review, isEditable, isDeletable, uuid} = this.props;
const {content, rating, color} = this.state;
const {username} = review;
const randomColor = colorList[username.length%10];
const avatarLetter = username.charAt(0).toUpperCase();
const content = (
const body = (
<div style={{marginTop: -5}}>
<StarRatings
rating={review.rating}
rating={rating}
starRatedColor="#777"
starDimension="12px"
starSpacing="2px"
@ -29,7 +57,7 @@ class SingleReview extends React.Component {
<Text style={{fontSize: 12, color: "#aaa"}} type="secondary"> {review.createdAt}</Text><br/>
<Paragraph style={{color: "#777"}}>
<Twemoji options={{className: 'twemoji'}}>
{review.content}
{content}
</Twemoji>
</Paragraph>
</div>
@ -38,7 +66,7 @@ class SingleReview extends React.Component {
const title = (
<div>
{review.username}
{isEditable && (<EditReview uuid={uuid} review={review}/>)}
{isEditable && (<EditReview uuid={uuid} review={review} updateCallback={this.updateCallback}/>)}
{isDeletable && (<span className="delete-button">delete</span>)}
</div>
);
@ -47,12 +75,12 @@ class SingleReview extends React.Component {
<div>
<List.Item.Meta
avatar={
<Avatar style={{backgroundColor: randomColor, verticalAlign: 'middle'}} size="large">
<Avatar style={{backgroundColor: color, verticalAlign: 'middle'}} size="large">
{avatarLetter}
</Avatar>
}
title={title}
description={content}
description={body}
/>
</div>
);

@ -80,6 +80,8 @@ class EditReview extends React.Component {
description:
'Your review has been update successfully.',
});
this.props.updateCallback(res.data.data);
} else {
this.setState({
loading: false,
@ -93,7 +95,8 @@ class EditReview extends React.Component {
}
}).catch((error) => {
if (error.response.status === 401) {
console.log(error);
if (error.hasOwnProperty("response") && error.response.status === 401) {
window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + '/store/login';
} else {
this.setState({

Loading…
Cancel
Save