Bug 1840113 - Display review checker info cards

fenix/119.0
rahulsainani 9 months ago committed by mergify[bot]
parent 611d809d19
commit 37a5a02ce4

@ -116,7 +116,7 @@ sealed interface ReviewQualityCheckState : State {
* The status of the product analysis. * The status of the product analysis.
*/ */
enum class AnalysisStatus { enum class AnalysisStatus {
NEEDS_ANALYSIS, REANALYZING, UP_TO_DATE, COMPLETED NEEDS_ANALYSIS, REANALYZING, UP_TO_DATE
} }
} }
} }

@ -5,6 +5,7 @@
package org.mozilla.fenix.shopping.store package org.mozilla.fenix.shopping.store
import mozilla.components.lib.state.Store import mozilla.components.lib.state.Store
import org.mozilla.fenix.shopping.store.ReviewQualityCheckState.OptedIn.ProductReviewState
import org.mozilla.fenix.shopping.store.ReviewQualityCheckState.OptedIn.ProductReviewState.AnalysisPresent.AnalysisStatus import org.mozilla.fenix.shopping.store.ReviewQualityCheckState.OptedIn.ProductReviewState.AnalysisPresent.AnalysisStatus
/** /**
@ -74,20 +75,20 @@ private fun mapStateForUpdateAction(
ReviewQualityCheckAction.FetchProductAnalysis, ReviewQualityCheckAction.RetryProductAnalysis -> { ReviewQualityCheckAction.FetchProductAnalysis, ReviewQualityCheckAction.RetryProductAnalysis -> {
state.mapIfOptedIn { state.mapIfOptedIn {
it.copy(productReviewState = ReviewQualityCheckState.OptedIn.ProductReviewState.Loading) it.copy(productReviewState = ProductReviewState.Loading)
} }
} }
ReviewQualityCheckAction.ReanalyzeProduct -> { ReviewQualityCheckAction.ReanalyzeProduct -> {
state.mapIfOptedIn { state.mapIfOptedIn {
when (it.productReviewState) { when (it.productReviewState) {
is ReviewQualityCheckState.OptedIn.ProductReviewState.AnalysisPresent -> { is ProductReviewState.AnalysisPresent -> {
val productReviewState = val productReviewState =
it.productReviewState.copy(analysisStatus = AnalysisStatus.REANALYZING) it.productReviewState.copy(analysisStatus = AnalysisStatus.REANALYZING)
it.copy(productReviewState = productReviewState) it.copy(productReviewState = productReviewState)
} }
is ReviewQualityCheckState.OptedIn.ProductReviewState.NoAnalysisPresent -> { is ProductReviewState.NoAnalysisPresent -> {
it.copy(productReviewState = it.productReviewState.copy(isReanalyzing = true)) it.copy(productReviewState = it.productReviewState.copy(isReanalyzing = true))
} }

@ -84,15 +84,27 @@ fun ProductAnalysis(
ReanalysisInProgressCard() ReanalysisInProgressCard()
} }
AnalysisStatus.COMPLETED -> {
// TBD
}
AnalysisStatus.UP_TO_DATE -> { AnalysisStatus.UP_TO_DATE -> {
// no-op // no-op
} }
} }
if (productAnalysis.notEnoughReviewsCardVisible) {
ReviewQualityCheckInfoCard(
title = stringResource(id = R.string.review_quality_check_no_reviews_warning_title),
description = stringResource(id = R.string.review_quality_check_no_reviews_warning_body),
type = ReviewQualityCheckInfoType.Info,
modifier = Modifier.fillMaxWidth(),
icon = {
Icon(
painter = painterResource(id = R.drawable.mozac_ic_information_fill_24),
contentDescription = null,
tint = FirefoxTheme.colors.iconPrimary,
)
},
)
}
if (productAnalysis.reviewGrade != null) { if (productAnalysis.reviewGrade != null) {
ReviewGradeCard( ReviewGradeCard(
reviewGrade = productAnalysis.reviewGrade, reviewGrade = productAnalysis.reviewGrade,
@ -448,9 +460,6 @@ private class ProductAnalysisPreviewModelParameterProvider :
ProductAnalysisPreviewModel( ProductAnalysisPreviewModel(
analysisStatus = AnalysisStatus.REANALYZING, analysisStatus = AnalysisStatus.REANALYZING,
), ),
ProductAnalysisPreviewModel(
analysisStatus = AnalysisStatus.COMPLETED,
),
ProductAnalysisPreviewModel( ProductAnalysisPreviewModel(
reviewGrade = null, reviewGrade = null,
), ),

@ -10,15 +10,21 @@ import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.material.Icon
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import org.mozilla.fenix.R
import org.mozilla.fenix.compose.annotation.LightDarkPreview import org.mozilla.fenix.compose.annotation.LightDarkPreview
import org.mozilla.fenix.shopping.store.ReviewQualityCheckState.OptedIn.ProductReviewState
import org.mozilla.fenix.theme.FirefoxTheme import org.mozilla.fenix.theme.FirefoxTheme
/** /**
* Product analysis error UI * Product analysis error UI
* *
* @param error The error state to display.
* @param productRecommendationsEnabled The current state of the product recommendations toggle. * @param productRecommendationsEnabled The current state of the product recommendations toggle.
* @param onReviewGradeLearnMoreClick Invoked when the user clicks to learn more about review grades. * @param onReviewGradeLearnMoreClick Invoked when the user clicks to learn more about review grades.
* @param onOptOutClick Invoked when the user opts out of the review quality check feature. * @param onOptOutClick Invoked when the user opts out of the review quality check feature.
@ -28,7 +34,9 @@ import org.mozilla.fenix.theme.FirefoxTheme
* @param modifier Modifier to apply to the layout. * @param modifier Modifier to apply to the layout.
*/ */
@Composable @Composable
@Suppress("LongParameterList")
fun ProductAnalysisError( fun ProductAnalysisError(
error: ProductReviewState.Error,
productRecommendationsEnabled: Boolean?, productRecommendationsEnabled: Boolean?,
onReviewGradeLearnMoreClick: (String) -> Unit, onReviewGradeLearnMoreClick: (String) -> Unit,
onOptOutClick: () -> Unit, onOptOutClick: () -> Unit,
@ -40,7 +48,52 @@ fun ProductAnalysisError(
modifier = modifier, modifier = modifier,
verticalArrangement = Arrangement.spacedBy(16.dp), verticalArrangement = Arrangement.spacedBy(16.dp),
) { ) {
// Error UI to be done in Bug 1840113 when (error) {
ProductReviewState.Error.GenericError ->
ReviewQualityCheckInfoCard(
title = stringResource(id = R.string.review_quality_check_generic_error_title),
description = stringResource(id = R.string.review_quality_check_generic_error_body),
type = ReviewQualityCheckInfoType.Warning,
modifier = Modifier.fillMaxWidth(),
icon = {
Icon(
painter = painterResource(id = R.drawable.mozac_ic_warning_fill_24),
contentDescription = null,
tint = FirefoxTheme.colors.iconPrimary,
)
},
)
ProductReviewState.Error.NetworkError ->
ReviewQualityCheckInfoCard(
title = stringResource(id = R.string.review_quality_check_no_connection_title),
description = stringResource(id = R.string.review_quality_check_no_connection_body),
type = ReviewQualityCheckInfoType.Warning,
modifier = Modifier.fillMaxWidth(),
icon = {
Icon(
painter = painterResource(id = R.drawable.mozac_ic_warning_fill_24),
contentDescription = null,
tint = FirefoxTheme.colors.iconPrimary,
)
},
)
ProductReviewState.Error.UnsupportedProductTypeError ->
ReviewQualityCheckInfoCard(
title = stringResource(id = R.string.review_quality_check_not_analyzable_info_title),
description = stringResource(id = R.string.review_quality_check_not_analyzable_info_body),
type = ReviewQualityCheckInfoType.Info,
modifier = Modifier.fillMaxWidth(),
icon = {
Icon(
painter = painterResource(id = R.drawable.mozac_ic_information_fill_24),
contentDescription = null,
tint = FirefoxTheme.colors.iconPrimary,
)
},
)
}
ReviewQualityInfoCard( ReviewQualityInfoCard(
onLearnMoreClick = onReviewGradeLearnMoreClick, onLearnMoreClick = onReviewGradeLearnMoreClick,
@ -70,6 +123,7 @@ private fun ProductAnalysisErrorPreview() {
.padding(all = 16.dp), .padding(all = 16.dp),
) { ) {
ProductAnalysisError( ProductAnalysisError(
error = ProductReviewState.Error.NetworkError,
productRecommendationsEnabled = true, productRecommendationsEnabled = true,
onReviewGradeLearnMoreClick = {}, onReviewGradeLearnMoreClick = {},
onOptOutClick = {}, onOptOutClick = {},

@ -119,6 +119,7 @@ private fun ProductReview(
is ReviewQualityCheckState.OptedIn.ProductReviewState.Error -> { is ReviewQualityCheckState.OptedIn.ProductReviewState.Error -> {
ProductAnalysisError( ProductAnalysisError(
error = productReviewState,
productRecommendationsEnabled = state.productRecommendationsPreference, productRecommendationsEnabled = state.productRecommendationsPreference,
onReviewGradeLearnMoreClick = onReviewGradeLearnMoreClick, onReviewGradeLearnMoreClick = onReviewGradeLearnMoreClick,
onOptOutClick = onOptOutClick, onOptOutClick = onOptOutClick,

@ -2163,9 +2163,9 @@
<!-- Text for button from warning card informing the user that the current analysis is outdated. Clicking this should trigger the product's re-analysis. --> <!-- Text for button from warning card informing the user that the current analysis is outdated. Clicking this should trigger the product's re-analysis. -->
<string name="review_quality_check_outdated_analysis_warning_action" tools:ignore="UnusedResources">Check now</string> <string name="review_quality_check_outdated_analysis_warning_action" tools:ignore="UnusedResources">Check now</string>
<!-- Title for warning card informing the user that the current product does not have enough reviews for a review analysis. --> <!-- Title for warning card informing the user that the current product does not have enough reviews for a review analysis. -->
<string name="review_quality_check_no_reviews_warning_title" tools:ignore="UnusedResources">Not enough reviews yet</string> <string name="review_quality_check_no_reviews_warning_title">Not enough reviews yet</string>
<!-- Text for body of warning card informing the user that the current product does not have enough reviews for a review analysis. --> <!-- Text for body of warning card informing the user that the current product does not have enough reviews for a review analysis. -->
<string name="review_quality_check_no_reviews_warning_body" tools:ignore="UnusedResources">When this product has more reviews, well be able to check their quality.</string> <string name="review_quality_check_no_reviews_warning_body">When this product has more reviews, well be able to check their quality.</string>
<!-- Title for warning card informing the user that the current product is currently not available. --> <!-- Title for warning card informing the user that the current product is currently not available. -->
<string name="review_quality_check_product_availability_warning_title" tools:ignore="UnusedResources">Product is not available</string> <string name="review_quality_check_product_availability_warning_title" tools:ignore="UnusedResources">Product is not available</string>
<!-- Text for the body of warning card informing the user that the current product is currently not available. --> <!-- Text for the body of warning card informing the user that the current product is currently not available. -->
@ -2183,9 +2183,9 @@
<!-- Text for body of info card displayed after the user reports a product is back in stock. --> <!-- Text for body of info card displayed after the user reports a product is back in stock. -->
<string name="review_quality_check_analysis_requested_info_body" tools:ignore="UnusedResources">We should have info about this products reviews within 24 hours. Please check back.</string> <string name="review_quality_check_analysis_requested_info_body" tools:ignore="UnusedResources">We should have info about this products reviews within 24 hours. Please check back.</string>
<!-- Title for info card displayed when the user review checker while on a product that Fakespot does not analyze (e.g. gift cards, music). --> <!-- Title for info card displayed when the user review checker while on a product that Fakespot does not analyze (e.g. gift cards, music). -->
<string name="review_quality_check_not_analyzable_info_title" tools:ignore="UnusedResources">We cant check these reviews</string> <string name="review_quality_check_not_analyzable_info_title">We cant check these reviews</string>
<!-- Text for body of info card displayed when the user review checker while on a product that Fakespot does not analyze (e.g. gift cards, music). --> <!-- Text for body of info card displayed when the user review checker while on a product that Fakespot does not analyze (e.g. gift cards, music). -->
<string name="review_quality_check_not_analyzable_info_body" tools:ignore="UnusedResources">Unfortunately, we cant check the review quality for certain types of products. For example, gift cards and streaming video, music, and games.</string> <string name="review_quality_check_not_analyzable_info_body">Unfortunately, we cant check the review quality for certain types of products. For example, gift cards and streaming video, music, and games.</string>
<!-- Title for info card displayed when another user reported the displayed product is back in stock. --> <!-- Title for info card displayed when another user reported the displayed product is back in stock. -->
<string name="review_quality_check_analysis_requested_other_user_info_title" tools:ignore="UnusedResources">Info coming soon</string> <string name="review_quality_check_analysis_requested_other_user_info_title" tools:ignore="UnusedResources">Info coming soon</string>
<!-- Text for body of info card displayed when another user reported the displayed product is back in stock. --> <!-- Text for body of info card displayed when another user reported the displayed product is back in stock. -->
@ -2195,13 +2195,13 @@
<!-- Text for the action button from info card displayed to the user when analysis finished updating. --> <!-- Text for the action button from info card displayed to the user when analysis finished updating. -->
<string name="review_quality_check_analysis_updated_confirmation_action" tools:ignore="UnusedResources">Got it</string> <string name="review_quality_check_analysis_updated_confirmation_action" tools:ignore="UnusedResources">Got it</string>
<!-- Title for error card displayed to the user when an error occurred. --> <!-- Title for error card displayed to the user when an error occurred. -->
<string name="review_quality_check_generic_error_title" tools:ignore="UnusedResources">No info available right now</string> <string name="review_quality_check_generic_error_title">No info available right now</string>
<!-- Text for body of error card displayed to the user when an error occurred. --> <!-- Text for body of error card displayed to the user when an error occurred. -->
<string name="review_quality_check_generic_error_body" tools:ignore="UnusedResources">Were working to resolve the issue. Please check back soon.</string> <string name="review_quality_check_generic_error_body">Were working to resolve the issue. Please check back soon.</string>
<!-- Title for error card displayed to the user when the device is disconnected from the network. --> <!-- Title for error card displayed to the user when the device is disconnected from the network. -->
<string name="review_quality_check_no_connection_title" tools:ignore="UnusedResources">No network connection</string> <string name="review_quality_check_no_connection_title">No network connection</string>
<!-- Text for body of error card displayed to the user when the device is disconnected from the network. --> <!-- Text for body of error card displayed to the user when the device is disconnected from the network. -->
<string name="review_quality_check_no_connection_body" tools:ignore="UnusedResources">Check your network connection and then try reloading the page.</string> <string name="review_quality_check_no_connection_body">Check your network connection and then try reloading the page.</string>
<!-- Title for card displayed to the user for products whose reviews were not analyzed yet. --> <!-- Title for card displayed to the user for products whose reviews were not analyzed yet. -->
<string name="review_quality_check_no_analysis_title">No info about these reviews yet</string> <string name="review_quality_check_no_analysis_title">No info about these reviews yet</string>
<!-- Text for the body of card displayed to the user for products whose reviews were not analyzed yet. --> <!-- Text for the body of card displayed to the user for products whose reviews were not analyzed yet. -->

@ -228,7 +228,7 @@ class ReviewQualityCheckStateTest {
val analysisWithoutGrade = ProductAnalysisTestData.analysisPresent( val analysisWithoutGrade = ProductAnalysisTestData.analysisPresent(
reviewGrade = null, reviewGrade = null,
adjustedRating = 3.2f, adjustedRating = 3.2f,
analysisStatus = AnalysisStatus.COMPLETED, analysisStatus = AnalysisStatus.UP_TO_DATE,
) )
val analysisWithoutRatings = ProductAnalysisTestData.analysisPresent( val analysisWithoutRatings = ProductAnalysisTestData.analysisPresent(

Loading…
Cancel
Save