mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-29 05:00:43 +10:00
Merge pull request #1106 from sharetribe/fix-bug-in-reviewlink
Fix bug in showing the review link after other party has already reviewed it
This commit is contained in:
commit
a740d03ca2
3 changed files with 23 additions and 17 deletions
2
.auditrc
2
.auditrc
|
|
@ -2,4 +2,6 @@ exports.exceptions = [
|
|||
// Add exceptions to audit script:
|
||||
// // Severity: low, lodash (< 4.17.5), used heavily in our CRA fork
|
||||
// "https://npmjs.com/advisories/577",
|
||||
// Temporarily skip warning about axios until SDK is updated
|
||||
"https://npmjs.com/advisories/880",
|
||||
];
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ way to update this template, but currently, we follow a pattern:
|
|||
|
||||
## Upcoming version 2019-XX-XX
|
||||
|
||||
- [fix] Fix a bug in showing review links. Because of the bug the second review link was not visible
|
||||
in `ActivityFeed`. [#1106](https://github.com/sharetribe/flex-template-web/pull/1106)
|
||||
- [fix] Emptying the priceFilter component in the searchPage caused a page breaking error.
|
||||
[#1101](https://github.com/sharetribe/flex-template-web/pull/1101)
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import {
|
|||
isCustomerReview,
|
||||
isProviderReview,
|
||||
txRoleIsProvider,
|
||||
txRoleIsCustomer,
|
||||
getUserTxRole,
|
||||
isRelevantPastTransition,
|
||||
} from '../../util/transaction';
|
||||
|
|
@ -94,10 +95,10 @@ Review.propTypes = {
|
|||
};
|
||||
|
||||
const hasUserLeftAReviewFirst = (userRole, transaction) => {
|
||||
const isProvider = txRoleIsProvider(userRole);
|
||||
return isProvider
|
||||
? txIsInFirstReviewBy(transaction, isProvider)
|
||||
: txIsInFirstReviewBy(transaction, !isProvider);
|
||||
// Because function txIsInFirstReviewBy uses isCustomer to check in which state the reviews are
|
||||
// we should also use isCustomer insted of isProvider
|
||||
const isCustomer = txRoleIsCustomer(userRole);
|
||||
return txIsInFirstReviewBy(transaction, isCustomer);
|
||||
};
|
||||
|
||||
const resolveTransitionMessage = (
|
||||
|
|
@ -145,20 +146,21 @@ const resolveTransitionMessage = (
|
|||
case TRANSITION_CANCEL:
|
||||
return <FormattedMessage id="ActivityFeed.transitionCancel" />;
|
||||
case TRANSITION_COMPLETE:
|
||||
// Show the leave a review link if the state is delivered or
|
||||
// if current user is not the first to leave a review
|
||||
// Show the leave a review link if the state is delivered and if the current user is the first to leave a review
|
||||
const reviewPeriodJustStarted = txIsDelivered(transaction);
|
||||
const reviewPeriodIsOver = txIsReviewed(transaction);
|
||||
const userHasLeftAReview = hasUserLeftAReviewFirst(ownRole, transaction);
|
||||
|
||||
const reviewLink =
|
||||
reviewPeriodJustStarted || !(reviewPeriodIsOver || userHasLeftAReview) ? (
|
||||
<InlineTextButton onClick={onOpenReviewModal}>
|
||||
<FormattedMessage id="ActivityFeed.leaveAReview" values={{ displayName }} />
|
||||
</InlineTextButton>
|
||||
) : null;
|
||||
const reviewAsFirstLink = reviewPeriodJustStarted ? (
|
||||
<InlineTextButton onClick={onOpenReviewModal}>
|
||||
<FormattedMessage id="ActivityFeed.leaveAReview" values={{ displayName }} />
|
||||
</InlineTextButton>
|
||||
) : null;
|
||||
|
||||
return <FormattedMessage id="ActivityFeed.transitionComplete" values={{ reviewLink }} />;
|
||||
return (
|
||||
<FormattedMessage
|
||||
id="ActivityFeed.transitionComplete"
|
||||
values={{ reviewLink: reviewAsFirstLink }}
|
||||
/>
|
||||
);
|
||||
|
||||
case TRANSITION_REVIEW_1_BY_PROVIDER:
|
||||
case TRANSITION_REVIEW_1_BY_CUSTOMER:
|
||||
|
|
@ -169,7 +171,7 @@ const resolveTransitionMessage = (
|
|||
// one to leave a review
|
||||
const reviewPeriodIsOver = txIsReviewed(transaction);
|
||||
const userHasLeftAReview = hasUserLeftAReviewFirst(ownRole, transaction);
|
||||
const reviewLink = !(reviewPeriodIsOver || userHasLeftAReview) ? (
|
||||
const reviewAsSecondLink = !(reviewPeriodIsOver || userHasLeftAReview) ? (
|
||||
<InlineTextButton onClick={onOpenReviewModal}>
|
||||
<FormattedMessage id="ActivityFeed.leaveAReviewSecond" values={{ displayName }} />
|
||||
</InlineTextButton>
|
||||
|
|
@ -177,7 +179,7 @@ const resolveTransitionMessage = (
|
|||
return (
|
||||
<FormattedMessage
|
||||
id="ActivityFeed.transitionReview"
|
||||
values={{ displayName, reviewLink }}
|
||||
values={{ displayName, reviewLink: reviewAsSecondLink }}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue