diff --git a/app/feature/feature-addon-purchase/src/main/graphql/UpsellAddonOfferMutation.graphql b/app/feature/feature-addon-purchase/src/main/graphql/UpsellAddonOfferMutation.graphql index 0df6686ac7..cd50fa2c6b 100644 --- a/app/feature/feature-addon-purchase/src/main/graphql/UpsellAddonOfferMutation.graphql +++ b/app/feature/feature-addon-purchase/src/main/graphql/UpsellAddonOfferMutation.graphql @@ -23,6 +23,9 @@ mutation UpsellAddonOffer($contractId: ID!) { ...MoneyFragment } quoteId + addonVariant { + ...AddonVariantFragment + } } titleDisplayName } diff --git a/app/feature/feature-addon-purchase/src/main/kotlin/com/hedvig/android/feature/addon/purchase/data/Addon.kt b/app/feature/feature-addon-purchase/src/main/kotlin/com/hedvig/android/feature/addon/purchase/data/Addon.kt index 973cb93f5e..4e804f4358 100644 --- a/app/feature/feature-addon-purchase/src/main/kotlin/com/hedvig/android/feature/addon/purchase/data/Addon.kt +++ b/app/feature/feature-addon-purchase/src/main/kotlin/com/hedvig/android/feature/addon/purchase/data/Addon.kt @@ -2,7 +2,7 @@ package com.hedvig.android.feature.addon.purchase.data import arrow.core.NonEmptyList import com.hedvig.android.core.uidata.UiMoney -import com.hedvig.android.data.productvariant.InsuranceVariantDocument +import com.hedvig.android.data.productvariant.AddonVariant import kotlinx.datetime.LocalDate import kotlinx.serialization.Serializable @@ -23,12 +23,6 @@ internal data class TravelAddonQuote( val displayName: String, val price: UiMoney, val addonVariant: AddonVariant, -) - -@Serializable -internal data class AddonVariant( - val documents: List, - val termsVersion: String, val displayDetails: List>, ) diff --git a/app/feature/feature-addon-purchase/src/main/kotlin/com/hedvig/android/feature/addon/purchase/data/GetTravelAddonOfferUseCase.kt b/app/feature/feature-addon-purchase/src/main/kotlin/com/hedvig/android/feature/addon/purchase/data/GetTravelAddonOfferUseCase.kt index 5b2219f72f..7c9240feb9 100644 --- a/app/feature/feature-addon-purchase/src/main/kotlin/com/hedvig/android/feature/addon/purchase/data/GetTravelAddonOfferUseCase.kt +++ b/app/feature/feature-addon-purchase/src/main/kotlin/com/hedvig/android/feature/addon/purchase/data/GetTravelAddonOfferUseCase.kt @@ -8,6 +8,7 @@ import com.apollographql.apollo.ApolloClient import com.hedvig.android.apollo.safeExecute import com.hedvig.android.core.common.ErrorMessage import com.hedvig.android.core.uidata.UiMoney +import com.hedvig.android.data.productvariant.toAddonVariant import com.hedvig.android.feature.addon.purchase.data.Addon.TravelAddonOffer import com.hedvig.android.featureflags.FeatureManager import com.hedvig.android.featureflags.flags.Feature @@ -74,13 +75,10 @@ private fun NonEmptyList - item.displayTitle to item.displayValue - }, - ), + displayDetails = it.displayItems.map { item -> + item.displayTitle to item.displayValue + }, + addonVariant = it.addonVariant.toAddonVariant(), ) } } diff --git a/app/feature/feature-addon-purchase/src/main/kotlin/com/hedvig/android/feature/addon/purchase/ui/customize/CustomizeTravelAddonDestination.kt b/app/feature/feature-addon-purchase/src/main/kotlin/com/hedvig/android/feature/addon/purchase/ui/customize/CustomizeTravelAddonDestination.kt index 034b39911f..766c08c1c7 100644 --- a/app/feature/feature-addon-purchase/src/main/kotlin/com/hedvig/android/feature/addon/purchase/ui/customize/CustomizeTravelAddonDestination.kt +++ b/app/feature/feature-addon-purchase/src/main/kotlin/com/hedvig/android/feature/addon/purchase/ui/customize/CustomizeTravelAddonDestination.kt @@ -37,6 +37,7 @@ import androidx.lifecycle.compose.dropUnlessResumed import arrow.core.nonEmptyListOf import com.hedvig.android.core.uidata.UiCurrencyCode import com.hedvig.android.core.uidata.UiMoney +import com.hedvig.android.data.productvariant.AddonVariant import com.hedvig.android.design.system.hedvig.ButtonDefaults.ButtonSize.Large import com.hedvig.android.design.system.hedvig.ChosenState import com.hedvig.android.design.system.hedvig.ChosenState.Chosen @@ -70,7 +71,6 @@ import com.hedvig.android.design.system.hedvig.icon.Close import com.hedvig.android.design.system.hedvig.icon.HedvigIcons import com.hedvig.android.design.system.hedvig.rememberHedvigBottomSheetState import com.hedvig.android.feature.addon.purchase.data.Addon.TravelAddonOffer -import com.hedvig.android.feature.addon.purchase.data.AddonVariant import com.hedvig.android.feature.addon.purchase.data.TravelAddonQuote import com.hedvig.android.feature.addon.purchase.navigation.SummaryParameters import hedvig.resources.R @@ -554,10 +554,14 @@ private val fakeTravelAddonQuote1 = TravelAddonQuote( quoteId = "id", addonId = "addonId1", displayName = "45 days", + displayDetails = listOf(), addonVariant = AddonVariant( termsVersion = "terms", documents = listOf(), - displayDetails = listOf(), + perils = listOf(), + displayName = "45 days", + product = "", + insurableLimits = listOf(), ), price = UiMoney( 49.0, @@ -568,10 +572,14 @@ private val fakeTravelAddonQuote2 = TravelAddonQuote( displayName = "60 days", addonId = "addonId1", quoteId = "id", + displayDetails = listOf(), addonVariant = AddonVariant( termsVersion = "terms", documents = listOf(), - displayDetails = listOf(), + perils = listOf(), + displayName = "60 days", + product = "", + insurableLimits = listOf(), ), price = UiMoney( 60.0, diff --git a/app/feature/feature-addon-purchase/src/main/kotlin/com/hedvig/android/feature/addon/purchase/ui/summary/AddonSummaryDestination.kt b/app/feature/feature-addon-purchase/src/main/kotlin/com/hedvig/android/feature/addon/purchase/ui/summary/AddonSummaryDestination.kt index 7b6a1da7fa..4e8cbbf33f 100644 --- a/app/feature/feature-addon-purchase/src/main/kotlin/com/hedvig/android/feature/addon/purchase/ui/summary/AddonSummaryDestination.kt +++ b/app/feature/feature-addon-purchase/src/main/kotlin/com/hedvig/android/feature/addon/purchase/ui/summary/AddonSummaryDestination.kt @@ -24,7 +24,7 @@ import androidx.compose.ui.unit.dp import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.hedvig.android.core.uidata.UiCurrencyCode import com.hedvig.android.core.uidata.UiMoney -import com.hedvig.android.data.productvariant.InsuranceVariantDocument +import com.hedvig.android.data.productvariant.AddonVariant import com.hedvig.android.design.system.hedvig.ButtonDefaults.ButtonSize.Large import com.hedvig.android.design.system.hedvig.ButtonDefaults.ButtonStyle.Primary import com.hedvig.android.design.system.hedvig.DialogDefaults @@ -41,7 +41,6 @@ import com.hedvig.android.design.system.hedvig.NotificationDefaults import com.hedvig.android.design.system.hedvig.Surface import com.hedvig.android.design.system.hedvig.datepicker.HedvigDateTimeFormatterDefaults import com.hedvig.android.design.system.hedvig.datepicker.getLocale -import com.hedvig.android.feature.addon.purchase.data.AddonVariant import com.hedvig.android.feature.addon.purchase.data.CurrentTravelAddon import com.hedvig.android.feature.addon.purchase.data.TravelAddonQuote import com.hedvig.android.feature.addon.purchase.ui.summary.AddonSummaryState.Content @@ -250,7 +249,7 @@ private fun SummaryCard(uiState: Content, modifier: Modifier = Modifier) { } } }, - displayItems = if (uiState.quote.addonVariant.displayDetails.isNotEmpty()) { + displayItems = if (uiState.quote.displayDetails.isNotEmpty()) { { DetailsWithStrikeThrough(uiState) } } else { null @@ -266,7 +265,7 @@ private fun SummaryCard(uiState: Content, modifier: Modifier = Modifier) { @Composable private fun DetailsWithStrikeThrough(uiState: Content) { - uiState.quote.addonVariant.displayDetails.forEach { quoteItem -> + uiState.quote.displayDetails.forEach { quoteItem -> val currentAddonValue = uiState.currentTravelAddon?.displayDetails?.firstOrNull { currentAddonItem -> currentAddonItem.first == quoteItem.first }?.second @@ -339,19 +338,17 @@ private class ChooseInsuranceForAddonUiStateProvider : displayName = "60 days", addonId = "addonId1", quoteId = "id", + displayDetails = listOf( + "Amount of insured people" to "You +1", + "Coverage" to "60 days", + ), addonVariant = AddonVariant( termsVersion = "terms", - displayDetails = listOf( - "Amount of insured people" to "You +1", - "Coverage" to "60 days", - ), - documents = listOf( - InsuranceVariantDocument( - "Terms and Conditions", - "url", - InsuranceVariantDocument.InsuranceDocumentType.TERMS_AND_CONDITIONS, - ), - ), + documents = listOf(), + perils = listOf(), + displayName = "45 days", + product = "", + insurableLimits = listOf(), ), price = UiMoney( 60.0, diff --git a/app/feature/feature-addon-purchase/src/test/kotlin/data/GetTravelAddonOfferUseCaseImplTest.kt b/app/feature/feature-addon-purchase/src/test/kotlin/data/GetTravelAddonOfferUseCaseImplTest.kt index eb36f1b4f3..fcf2d2174c 100644 --- a/app/feature/feature-addon-purchase/src/test/kotlin/data/GetTravelAddonOfferUseCaseImplTest.kt +++ b/app/feature/feature-addon-purchase/src/test/kotlin/data/GetTravelAddonOfferUseCaseImplTest.kt @@ -17,8 +17,8 @@ import com.hedvig.android.core.common.ErrorMessage import com.hedvig.android.core.common.test.isLeft import com.hedvig.android.core.uidata.UiCurrencyCode import com.hedvig.android.core.uidata.UiMoney +import com.hedvig.android.data.productvariant.AddonVariant import com.hedvig.android.feature.addon.purchase.data.Addon.TravelAddonOffer -import com.hedvig.android.feature.addon.purchase.data.AddonVariant import com.hedvig.android.feature.addon.purchase.data.CurrentTravelAddon import com.hedvig.android.feature.addon.purchase.data.GetTravelAddonOfferUseCaseImpl import com.hedvig.android.feature.addon.purchase.data.TravelAddonQuote @@ -29,6 +29,7 @@ import kotlinx.coroutines.test.runTest import kotlinx.datetime.LocalDate import octopus.UpsellAddonOfferMutation import octopus.type.CurrencyCode +import octopus.type.buildAddonVariant import octopus.type.buildMoney import octopus.type.buildUpsellTravelAddonCurrentAddon import octopus.type.buildUpsellTravelAddonDisplayItem @@ -127,8 +128,8 @@ class GetTravelAddonOfferUseCaseImplTest { displayItems = buildList { add( buildUpsellTravelAddonDisplayItem { - displayTitle = mockWithoutUpgrade.addonOptions[0].addonVariant.displayDetails[0].first - displayValue = mockWithoutUpgrade.addonOptions[0].addonVariant.displayDetails[0].second + displayTitle = mockWithoutUpgrade.addonOptions[0].displayDetails[0].first + displayValue = mockWithoutUpgrade.addonOptions[0].displayDetails[0].second }, ) } @@ -136,6 +137,14 @@ class GetTravelAddonOfferUseCaseImplTest { amount = mockWithoutUpgrade.addonOptions[0].price.amount currencyCode = CurrencyCode.SEK } + addonVariant = buildAddonVariant { + termsVersion = "" + documents = listOf() + displayName = "45 days" + product = "" + perils = listOf() + insurableLimits = listOf() + } }, ) @@ -147,8 +156,8 @@ class GetTravelAddonOfferUseCaseImplTest { displayItems = buildList { add( buildUpsellTravelAddonDisplayItem { - displayTitle = mockWithoutUpgrade.addonOptions[1].addonVariant.displayDetails[0].first - displayValue = mockWithoutUpgrade.addonOptions[1].addonVariant.displayDetails[0].second + displayTitle = mockWithoutUpgrade.addonOptions[1].displayDetails[0].first + displayValue = mockWithoutUpgrade.addonOptions[1].displayDetails[0].second }, ) } @@ -156,6 +165,14 @@ class GetTravelAddonOfferUseCaseImplTest { amount = mockWithoutUpgrade.addonOptions[1].price.amount currencyCode = CurrencyCode.SEK } + addonVariant = buildAddonVariant { + termsVersion = "" + documents = listOf() + displayName = "60 days" + product = "" + perils = listOf() + insurableLimits = listOf() + } }, ) } @@ -200,8 +217,8 @@ class GetTravelAddonOfferUseCaseImplTest { displayItems = buildList { add( buildUpsellTravelAddonDisplayItem { - displayTitle = mockWithUpgrade.addonOptions[0].addonVariant.displayDetails[0].first - displayValue = mockWithUpgrade.addonOptions[0].addonVariant.displayDetails[0].second + displayTitle = mockWithUpgrade.addonOptions[0].displayDetails[0].first + displayValue = mockWithUpgrade.addonOptions[0].displayDetails[0].second }, ) } @@ -209,6 +226,14 @@ class GetTravelAddonOfferUseCaseImplTest { amount = mockWithUpgrade.addonOptions[0].price.amount currencyCode = CurrencyCode.SEK } + addonVariant = buildAddonVariant { + termsVersion = "" + documents = listOf() + displayName = "45 days" + product = "" + perils = listOf() + insurableLimits = listOf() + } }, ) } @@ -285,10 +310,14 @@ private val mockWithoutUpgrade = TravelAddonOffer( quoteId = "id", addonId = "addonId1", displayName = "45 days", + displayDetails = listOf("Coverage" to "45 days"), addonVariant = AddonVariant( termsVersion = "", documents = listOf(), - displayDetails = listOf("Coverage" to "45 days"), + displayName = "45 days", + product = "", + perils = listOf(), + insurableLimits = listOf(), ), price = UiMoney( 49.0, @@ -299,10 +328,14 @@ private val mockWithoutUpgrade = TravelAddonOffer( displayName = "60 days", addonId = "addonId1", quoteId = "id", + displayDetails = listOf("Coverage" to "60 days"), addonVariant = AddonVariant( termsVersion = "", documents = listOf(), - displayDetails = listOf("Coverage" to "60 days"), + displayName = "60 days", + product = "", + perils = listOf(), + insurableLimits = listOf(), ), price = UiMoney( 60.0, @@ -322,10 +355,14 @@ private val mockWithUpgrade = TravelAddonOffer( displayName = "60 days", addonId = "addonId1", quoteId = "id", + displayDetails = listOf("Coverage" to "60 days"), addonVariant = AddonVariant( termsVersion = "", documents = listOf(), - displayDetails = listOf("Coverage" to "60 days"), + displayName = "45 days", + product = "", + perils = listOf(), + insurableLimits = listOf(), ), price = UiMoney( 60.0, diff --git a/app/feature/feature-addon-purchase/src/test/kotlin/ui/AddonSummaryPresenterTest.kt b/app/feature/feature-addon-purchase/src/test/kotlin/ui/AddonSummaryPresenterTest.kt index 114685eea1..7ce747d5f9 100644 --- a/app/feature/feature-addon-purchase/src/test/kotlin/ui/AddonSummaryPresenterTest.kt +++ b/app/feature/feature-addon-purchase/src/test/kotlin/ui/AddonSummaryPresenterTest.kt @@ -13,8 +13,8 @@ import assertk.assertions.prop import com.hedvig.android.core.common.ErrorMessage import com.hedvig.android.core.uidata.UiCurrencyCode import com.hedvig.android.core.uidata.UiMoney +import com.hedvig.android.data.productvariant.AddonVariant import com.hedvig.android.data.productvariant.InsuranceVariantDocument -import com.hedvig.android.feature.addon.purchase.data.AddonVariant import com.hedvig.android.feature.addon.purchase.data.CurrentTravelAddon import com.hedvig.android.feature.addon.purchase.data.SubmitAddonPurchaseUseCase import com.hedvig.android.feature.addon.purchase.data.TravelAddonQuote @@ -102,12 +102,16 @@ private val newQuote = TravelAddonQuote( displayName = "60 days", addonId = "addonId1", quoteId = "id", + displayDetails = listOf( + "Amount of insured people" to "You +1", + "Coverage" to "60 days", + ), addonVariant = AddonVariant( termsVersion = "terms", - displayDetails = listOf( - "Amount of insured people" to "You +1", - "Coverage" to "60 days", - ), + displayName = "45 days", + product = "", + perils = listOf(), + insurableLimits = listOf(), documents = listOf( InsuranceVariantDocument( "Terms and Conditions", @@ -126,12 +130,16 @@ private val newQuote2 = TravelAddonQuote( displayName = "60 days", addonId = "addonId1", quoteId = "id", + displayDetails = listOf( + "Amount of insured people" to "You +1", + "Coverage" to "60 days", + ), addonVariant = AddonVariant( termsVersion = "terms", - displayDetails = listOf( - "Amount of insured people" to "You +1", - "Coverage" to "60 days", - ), + displayName = "60 days", + product = "", + perils = listOf(), + insurableLimits = listOf(), documents = listOf( InsuranceVariantDocument( "Terms and Conditions", diff --git a/app/feature/feature-addon-purchase/src/test/kotlin/ui/CustomizeTravelAddonPresenterTest.kt b/app/feature/feature-addon-purchase/src/test/kotlin/ui/CustomizeTravelAddonPresenterTest.kt index b246f5c03a..c2003bfcf7 100644 --- a/app/feature/feature-addon-purchase/src/test/kotlin/ui/CustomizeTravelAddonPresenterTest.kt +++ b/app/feature/feature-addon-purchase/src/test/kotlin/ui/CustomizeTravelAddonPresenterTest.kt @@ -15,8 +15,9 @@ import assertk.assertions.prop import com.hedvig.android.core.common.ErrorMessage import com.hedvig.android.core.uidata.UiCurrencyCode import com.hedvig.android.core.uidata.UiMoney +import com.hedvig.android.data.productvariant.AddonVariant +import com.hedvig.android.data.productvariant.InsuranceVariantDocument import com.hedvig.android.feature.addon.purchase.data.Addon.TravelAddonOffer -import com.hedvig.android.feature.addon.purchase.data.AddonVariant import com.hedvig.android.feature.addon.purchase.data.GetTravelAddonOfferUseCase import com.hedvig.android.feature.addon.purchase.data.TravelAddonQuote import com.hedvig.android.feature.addon.purchase.navigation.SummaryParameters @@ -219,10 +220,20 @@ private val fakeTravelAddonQuote1 = TravelAddonQuote( quoteId = "id", addonId = "addonId1", displayName = "45 days", + displayDetails = listOf(), addonVariant = AddonVariant( termsVersion = "terms", - documents = listOf(), - displayDetails = listOf(), + displayName = "45 days", + product = "", + perils = listOf(), + insurableLimits = listOf(), + documents = listOf( + InsuranceVariantDocument( + "Terms and Conditions", + "url", + InsuranceVariantDocument.InsuranceDocumentType.TERMS_AND_CONDITIONS, + ), + ), ), price = UiMoney( 49.0, @@ -235,9 +246,19 @@ private val fakeTravelAddonQuote2 = TravelAddonQuote( quoteId = "id", addonVariant = AddonVariant( termsVersion = "terms", - documents = listOf(), - displayDetails = listOf(), + displayName = "60 days", + product = "", + perils = listOf(), + insurableLimits = listOf(), + documents = listOf( + InsuranceVariantDocument( + "Terms and Conditions", + "url", + InsuranceVariantDocument.InsuranceDocumentType.TERMS_AND_CONDITIONS, + ), + ), ), + displayDetails = listOf(), price = UiMoney( 60.0, UiCurrencyCode.SEK, diff --git a/app/feature/feature-movingflow/src/main/kotlin/com/hedvig/android/feature/movingflow/ui/summary/SummaryDestination.kt b/app/feature/feature-movingflow/src/main/kotlin/com/hedvig/android/feature/movingflow/ui/summary/SummaryDestination.kt index 03ca805d6e..991c6561b9 100644 --- a/app/feature/feature-movingflow/src/main/kotlin/com/hedvig/android/feature/movingflow/ui/summary/SummaryDestination.kt +++ b/app/feature/feature-movingflow/src/main/kotlin/com/hedvig/android/feature/movingflow/ui/summary/SummaryDestination.kt @@ -327,6 +327,8 @@ private fun AddonQuoteCard(quote: MovingFlowQuotes.AddonQuote, modifier: Modifie Spacer(Modifier.height(16.dp)) HedvigNotificationCard( "This addon can be removed by contacting support", // todo l10n + // stringResource(R.string.MOVING_FLOW_REMOVE_ADDON_INFO, deepLinkToNewChat), + // todo: add deep link to new conversation! InfoInline, ) }