From 2d2efb1b306fced8d50e90dd21de9368bc8a03a9 Mon Sep 17 00:00:00 2001 From: Jayasanka Date: Thu, 4 Jul 2019 22:43:38 +0530 Subject: [PATCH] Complete edit release functionality --- .../apps/release/review/CurrentUsersReview.js | 9 +--- .../review/singleReview/SingleReview.js | 42 +++++++++++++++---- .../singleReview/editReview/EditReview.js | 5 ++- 3 files changed, 40 insertions(+), 16 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/CurrentUsersReview.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/CurrentUsersReview.js index eb32114bb5..eca40fc60e 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/CurrentUsersReview.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/CurrentUsersReview.js @@ -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 => ( - + )} > diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/singleReview/SingleReview.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/singleReview/SingleReview.js index 66a7033bd5..8ca5820858 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/singleReview/SingleReview.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/singleReview/SingleReview.js @@ -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 = (
{review.createdAt}
- {review.content} + {content}
@@ -38,7 +66,7 @@ class SingleReview extends React.Component { const title = (
{review.username} - {isEditable && ()} + {isEditable && ()} {isDeletable && (delete)}
); @@ -47,12 +75,12 @@ class SingleReview extends React.Component {
+ {avatarLetter} } title={title} - description={content} + description={body} />
); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/singleReview/editReview/EditReview.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/singleReview/editReview/EditReview.js index ed72f51511..3a2af32e91 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/singleReview/editReview/EditReview.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/singleReview/editReview/EditReview.js @@ -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({