check comment owner by username
This commit is contained in:
@@ -118,6 +118,7 @@ export const validateCredentials = (username, password) => {
|
|||||||
|
|
||||||
// if(decodedAceessToken.data.wiaas_user_type === 'customer'){
|
// if(decodedAceessToken.data.wiaas_user_type === 'customer'){
|
||||||
localStorage.setItem('accessToken', response.data.token);
|
localStorage.setItem('accessToken', response.data.token);
|
||||||
|
localStorage.setItem('username', username);
|
||||||
const serverTime = decodedAceessToken.nbf || 1;
|
const serverTime = decodedAceessToken.nbf || 1;
|
||||||
// refreshToken = response.data.refreshToken;
|
// refreshToken = response.data.refreshToken;
|
||||||
startRefreshTimer(dispatch, serverTime);
|
startRefreshTimer(dispatch, serverTime);
|
||||||
|
|||||||
@@ -69,8 +69,7 @@ export const addComment = (idOrder, newComment, existingComments) => {
|
|||||||
const newCommentObject = {
|
const newCommentObject = {
|
||||||
comment : newComment,
|
comment : newComment,
|
||||||
date : moment().format("Do MMM, YY"),
|
date : moment().format("Do MMM, YY"),
|
||||||
username: 'username',
|
username: localStorage.getItem('username') || '-',
|
||||||
isOwner: 1,
|
|
||||||
}
|
}
|
||||||
const concatenatedComments = (existingComments) ? existingComments.concat(newCommentObject) : [newCommentObject];
|
const concatenatedComments = (existingComments) ? existingComments.concat(newCommentObject) : [newCommentObject];
|
||||||
|
|
||||||
|
|||||||
@@ -25,12 +25,12 @@ class OrderComments extends Component {
|
|||||||
this.setState({newComment});
|
this.setState({newComment});
|
||||||
}
|
}
|
||||||
|
|
||||||
getOffset(isOwner){
|
getOffset(username){
|
||||||
return isOwner ? 6 : 0;
|
return (username === localStorage.getItem('username')) ? 6 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
getClassByOwner(isOwner){
|
getClassByOwner(username){
|
||||||
return isOwner ? 'mine' : '';
|
return (username === localStorage.getItem('username')) ? 'mine' : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
@@ -46,8 +46,8 @@ class OrderComments extends Component {
|
|||||||
orderComments &&
|
orderComments &&
|
||||||
orderComments.map((orderComment, index) =>
|
orderComments.map((orderComment, index) =>
|
||||||
<Row key={'order-comment-' + index}>
|
<Row key={'order-comment-' + index}>
|
||||||
<Col xl={{size:6, offset:this.getOffset(orderComment.isOwner)}}>
|
<Col xl={{size:6, offset:this.getOffset(orderComment.username)}}>
|
||||||
<div className={'order-comment ' + this.getClassByOwner(orderComment.isOwner)} key={'order-comment-' + index}>
|
<div className={'order-comment ' + this.getClassByOwner(orderComment.username)} key={'order-comment-' + index}>
|
||||||
<div className="order-comment-header">{orderComment.username} - {orderComment.date}</div>
|
<div className="order-comment-header">{orderComment.username} - {orderComment.date}</div>
|
||||||
<div dangerouslySetInnerHTML={{__html: orderComment.comment}}></div>
|
<div dangerouslySetInnerHTML={{__html: orderComment.comment}}></div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user