Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use display items for move quote #1824

Merged
merged 1 commit into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ mutation MoveIntentRequest($intentId: ID!, $input: MoveIntentRequestInput!) {
amount
currencyCode
}
displayItems {
displayValue
displayTitle
}
startDate
exposureName
productVariant {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.hedvig.android.apollo.toEither
import com.hedvig.android.core.common.ErrorMessage
import com.hedvig.android.core.ui.insurance.toProductVariant
import com.hedvig.android.core.uidata.UiMoney
import kotlinx.collections.immutable.toImmutableList
import octopus.MoveIntentCommitMutation
import octopus.MoveIntentCreateMutation
import octopus.MoveIntentRequestMutation
Expand Down Expand Up @@ -106,25 +107,14 @@ private fun MoveIntentRequestMutation.Data.MoveIntentRequest.MoveIntent.toMoveQu
id = id,
insuranceName = quote.exposureName ?: quote.productVariant.displayName,
moveIntentId = MoveIntentId(id),
// address = Address(
// id = AddressId(quote.address.id),
// postalCode = quote.address.postalCode,
// street = quote.address.street,
// ),
address = Address(AddressId("1"), postalCode = "", street = ""),
// numberInsured = quote.numberCoInsured?.plus(1) ?: 1, // numberInsured = numberCoInsured + member
numberInsured = 0,
premium = UiMoney(
amount = quote.premium.amount,
currencyCode = quote.premium.currencyCode,
),
startDate = quote.startDate,
// ancillaryArea = quote.ancilliaryArea,
ancillaryArea = null,
// yearOfConstruction = quote.yearOfConstruction,
yearOfConstruction = null,
// squareMeters = quote.squareMeters,
squareMeters = null,
productVariant = quote.productVariant.toProductVariant(),
displayItems = quote.displayItems
.map { it.displayTitle to it.displayValue }
.toImmutableList(),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.hedvig.android.core.ui.insurance.ContractType
import com.hedvig.android.core.ui.insurance.InsurableLimit
import com.hedvig.android.core.ui.insurance.ProductVariant
import com.hedvig.android.core.uidata.UiMoney
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf
import kotlinx.datetime.LocalDate
import octopus.type.CurrencyCode
Expand All @@ -12,16 +13,13 @@ data class MoveQuote(
val id: String,
val insuranceName: String,
val moveIntentId: MoveIntentId,
val address: Address,
val numberInsured: Int?,
val premium: UiMoney,
val startDate: LocalDate,
val ancillaryArea: Int?,
val yearOfConstruction: Int?,
val squareMeters: Int?,
val productVariant: ProductVariant,
val isExpanded: Boolean = false,
val displayItems: ImmutableList<Pair<String, String>>,
) {

companion object {
fun PreviewData(index: Int = 0): MoveQuote {
@Suppress("NAME_SHADOWING")
Expand All @@ -30,16 +28,6 @@ data class MoveQuote(
id = index.toString(),
insuranceName = "Insurance #$index",
moveIntentId = MoveIntentId(""),
address = Address(
id = AddressId(""),
apartmentNumber = "1$index",
bbrId = null,
city = null,
floor = null,
postalCode = "124$index",
street = "Froedingsvaegen $index",
),
numberInsured = index,
premium = UiMoney(99.0 * index, CurrencyCode.SEK),
startDate = LocalDate(2023, 5, 13),
isExpanded = index == 1,
Expand All @@ -58,9 +46,7 @@ data class MoveQuote(
),
documents = persistentListOf(),
),
ancillaryArea = 10,
yearOfConstruction = 1991,
squareMeters = 30,
displayItems = persistentListOf()
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,55 +168,10 @@ private fun ExpandedInformation(
quote: MoveQuote,
) {
Column {
HorizontalItemsWithMaximumSpaceTaken(
startSlot = { Text(stringResource(id = R.string.CHANGE_ADDRESS_NEW_ADDRESS_LABEL)) },
endSlot = { Text(quote.address.street, textAlign = TextAlign.End) },
spaceBetween = 4.dp,
)
HorizontalItemsWithMaximumSpaceTaken(
startSlot = { Text(stringResource(id = R.string.CHANGE_ADDRESS_NEW_POSTAL_CODE_LABEL)) },
endSlot = { Text(quote.address.postalCode, textAlign = TextAlign.End) },
spaceBetween = 4.dp,
)
quote.squareMeters?.let {
HorizontalItemsWithMaximumSpaceTaken(
startSlot = { Text(stringResource(id = R.string.CHANGE_ADDRESS_NEW_LIVING_SPACE_LABEL)) },
endSlot = {
Text(
it.toString() + " " + stringResource(id = R.string.CHANGE_ADDRESS_SIZE_SUFFIX),
textAlign = TextAlign.End,
)
},
spaceBetween = 4.dp,
)
}
quote.ancillaryArea?.let {
quote.displayItems.forEach {
HorizontalItemsWithMaximumSpaceTaken(
startSlot = { Text(stringResource(id = R.string.CHANGE_ADDRESS_ANCILLARY_AREA_LABEL)) },
endSlot = { Text(it.toString(), textAlign = TextAlign.End) },
spaceBetween = 4.dp,
)
}
quote.yearOfConstruction?.let {
HorizontalItemsWithMaximumSpaceTaken(
startSlot = { Text(stringResource(id = R.string.CHANGE_ADDRESS_YEAR_OF_CONSTRUCTION_LABEL)) },
endSlot = { Text(it.toString(), textAlign = TextAlign.End) },
spaceBetween = 4.dp,
)
}
quote.numberInsured?.let {
HorizontalItemsWithMaximumSpaceTaken(
startSlot = { Text(stringResource(id = R.string.CHANGE_ADDRESS_CO_INSURED_LABEL)) },
endSlot = {
Text(
if (it == 1) {
stringResource(id = R.string.CHANGE_ADDRESS_ONE_PERSON)
} else {
stringResource(id = R.string.CHANGE_ADDRESS_TOTAL_PERSONS, it)
},
textAlign = TextAlign.End,
)
},
startSlot = { Text(it.first) },
endSlot = { Text(it.second, textAlign = TextAlign.End) },
spaceBetween = 4.dp,
)
}
Expand Down