diff --git a/.auditrc b/.auditrc index 3fa278e1..c37bf8c1 100644 --- a/.auditrc +++ b/.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", ]; diff --git a/CHANGELOG.md b/CHANGELOG.md index 759b6178..82efe230 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/src/components/ActivityFeed/ActivityFeed.js b/src/components/ActivityFeed/ActivityFeed.js index 95ab2616..7e9bb04d 100644 --- a/src/components/ActivityFeed/ActivityFeed.js +++ b/src/components/ActivityFeed/ActivityFeed.js @@ -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 ; 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) ? ( - - - - ) : null; + const reviewAsFirstLink = reviewPeriodJustStarted ? ( + + + + ) : null; - return ; + return ( + + ); 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) ? ( @@ -177,7 +179,7 @@ const resolveTransitionMessage = ( return ( ); }