Skip to content
Open
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 @@ -442,6 +442,22 @@ type AgreementDisplayItem {
displaySubtitle: String
displayValue: String!
}
input AnswersInput {
relationship: String
isPregnant: Boolean
hasKids: Boolean
hasCat: Boolean
hasDog: Boolean
yourAge: String
partnerAge: String
isStudent: Boolean
housingType: String
houseAge: String
isRental: Boolean
hasCar: Boolean
carAge: String
wantsAllRisk: Boolean
}
enum AppPlatform {
IOS
ANDROID
Expand Down Expand Up @@ -1003,7 +1019,7 @@ type ClaimIntentStep {
"""
A union of all the different kinds of "step content".
"""
union ClaimIntentStepContent = ClaimIntentStepContentForm|ClaimIntentStepContentSelect|ClaimIntentStepContentTask|ClaimIntentStepContentAudioRecording|ClaimIntentStepContentFileUpload|ClaimIntentStepContentSummary|ClaimIntentStepContentDeflection|ClaimIntentStepContentDeflectionMessage
union ClaimIntentStepContent = ClaimIntentStepContentForm|ClaimIntentStepContentSelect|ClaimIntentStepContentTask|ClaimIntentStepContentAudioRecording|ClaimIntentStepContentFileUpload|ClaimIntentStepContentSummary|ClaimIntentStepContentDeflection|ClaimIntentStepContentDeflectionMessage|ClaimIntentStepContentInformation
"""
An audio recording step is one where the user is meant to record some audio.
Submitted using `Mutation.claimIntentSubmitAudio`.
Expand Down Expand Up @@ -1181,6 +1197,22 @@ This typically will be backed by a String - but other formats could appear.
"""
scalar ClaimIntentStepContentFormFieldValue
"""
A read and acknowledge notice if the member needs to be shown some urgent information (if water is still leaking -> turn off the pipe). Not terminal
Submitted using `Mutation.claimIntentSubmitInformation`.
"""
type ClaimIntentStepContentInformation {
notice: String!
"""
So we can show a white/red border if info/critical respectively.
"""
severity: ClaimIntentStepContentInformationSeverity!
buttonTitle: String!
}
enum ClaimIntentStepContentInformationSeverity {
INFO
CRITICAL
}
"""
A select step is one that contains a choice to select one of several alternatives.
It can be seen as a special-case form with nicer rendering.
Submitted using `Mutation.claimIntentSubmitSelect`.
Expand Down Expand Up @@ -1268,6 +1300,9 @@ input ClaimIntentSubmitFormInput {
stepId: ID!
fields: [ClaimIntentFormSubmitInputField!]!
}
input ClaimIntentSubmitInformationInput {
stepId: ID!
}
input ClaimIntentSubmitSelectInput {
stepId: ID!
selectedId: ID!
Expand Down Expand Up @@ -2433,6 +2468,28 @@ type InsuranceEvidenceOutput {
insuranceEvidenceInformation: InsuranceEvidenceInformation
userError: UserError
}
input InsuranceGuideInput {
"""
Email of the user.
"""
email: String
"""
Id of the insurance guide shopSession.
"""
shopSessionId: UUID!
"""
Insurance recommendation form answers.
"""
answers: AnswersInput!
"""
Insurance recommendations.
"""
recommendations: [RecommendationInput!]!
}
type InsuranceGuideOutput {
success: Boolean!
userError: UserError
}
input InsurelyInitiateIframeDataCollectionInput {
collectionId: String!
partner: String
Expand Down Expand Up @@ -3655,6 +3712,10 @@ type Mutation {
"""
claimIntentSubmitTask(input: ClaimIntentSubmitTaskInput!): ClaimIntentMutationOutput!
"""
Acknowledge a step containing a `ClaimIntentStepContentInformation`, continuing the flow.
"""
claimIntentSubmitInformation(input: ClaimIntentSubmitInformationInput!): ClaimIntentMutationOutput!
"""
Submit a step containing a `ClaimIntentStepContentSummary`.
"""
claimIntentSubmitSummary(input: ClaimIntentSubmitSummaryInput!): ClaimIntentMutationOutput!
Expand Down Expand Up @@ -3729,6 +3790,10 @@ type Mutation {
"""
productOffersCancellationRequestedUpdate(productOfferIds: [UUID!]!, requested: Boolean!): ProductOffersMutationOutput!
"""
Called to save insurance recommendation form and save recommendation email.
"""
insuranceGuide(input: InsuranceGuideInput!): InsuranceGuideOutput!
"""
Create a `PriceIntent`.
The `input.productName` has to be the name of a product among the ones listed at `Query.availableProducts`. The
choice of product also affects which data will be needed for the intent to be confirmed and to produce offers.
Expand Down Expand Up @@ -4305,6 +4370,10 @@ type ProductOffer {
"""
priceIntentId: UUID
"""
Link to the price calculator for this offer (resumes the shop session).
"""
priceCalculatorLink: String
"""
UI-safe masked form data used to generate the offer. PII fields (street, zipCode, city) are masked when address came from registration address lookup.
"""
priceIntentData: PricingFormData!
Expand Down Expand Up @@ -4706,6 +4775,13 @@ type RecommendationExternalInsurance {
"""
dataCollectionId: String!
}
input RecommendationInput {
productId: String!
name: String!
tier: String
productPageUrl: String!
priceCalculatorUrl: String!
}
type RecommendedCrossSell {
crossSell: CrossSell!
bannerText: String!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ fragment ClaimIntentStepContentFragment on ClaimIntentStepContent {
...SummaryFragment
...DeflectionFragment
...DeflectionMessageFragment
...InformationFragment
}

fragment DeflectionMessageFragment on ClaimIntentStepContentDeflectionMessage {
Expand Down Expand Up @@ -132,3 +133,9 @@ fragment DeflectionInfoBlockFragment on ClaimIntentStepContentDeflectionInfoBloc
title
description
}

fragment InformationFragment on ClaimIntentStepContentInformation {
notice
buttonTitle
severity
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
mutation ClaimIntentSubmitInformation($input: ClaimIntentSubmitInformationInput!) {
claimIntentSubmitInformation(input: $input) {
...ClaimIntentMutationOutputFragment
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import com.hedvig.feature.claim.chat.data.StepId
import com.hedvig.feature.claim.chat.data.SubmitAudioRecordingUseCase
import com.hedvig.feature.claim.chat.data.SubmitFileUploadUseCase
import com.hedvig.feature.claim.chat.data.SubmitFormUseCase
import com.hedvig.feature.claim.chat.data.SubmitInformationUseCase
import com.hedvig.feature.claim.chat.data.SubmitSelectUseCase
import com.hedvig.feature.claim.chat.data.SubmitSummaryUseCase
import com.hedvig.feature.claim.chat.data.SubmitTaskUseCase
Expand Down Expand Up @@ -96,6 +97,8 @@ internal sealed interface ClaimChatEvent {

data object DismissConfirmEditDialog : ClaimChatEvent

data class SubmitInformation(val id: StepId): ClaimChatEvent

data class SubmitForm(
val stepId: StepId,
) : ClaimChatEvent
Expand Down Expand Up @@ -177,6 +180,7 @@ internal class ClaimChatViewModel(
regretStepUseCase: RegretStepUseCase,
formFieldSearchUseCase: FormFieldSearchUseCase,
fileService: FileService,
submitInformationUseCase: SubmitInformationUseCase
) : MoleculeViewModel<ClaimChatEvent, ClaimChatUiState>(
ClaimChatUiState.Initializing,
ClaimChatPresenter(
Expand All @@ -194,6 +198,7 @@ internal class ClaimChatViewModel(
fileService,
regretStepUseCase,
formFieldSearchUseCase,
submitInformationUseCase
),
) {
override fun onCleared() {
Expand All @@ -217,6 +222,7 @@ internal class ClaimChatPresenter(
private val fileService: FileService,
private val regretStepUseCase: RegretStepUseCase,
private val formFieldSearchUseCase: FormFieldSearchUseCase,
private val submitInformationUseCase: SubmitInformationUseCase
) : MoleculePresenter<ClaimChatEvent, ClaimChatUiState> {
@Composable
override fun MoleculePresenterScope<ClaimChatEvent>.present(lastState: ClaimChatUiState): ClaimChatUiState {
Expand Down Expand Up @@ -936,6 +942,34 @@ internal class ClaimChatPresenter(
)
}
}

is ClaimChatEvent.SubmitInformation -> {
val stepContent = steps.find { it.id == event.id }?.stepContent as? StepContent.Information
if (stepContent == null) {
logcat { "Step content not found or not Information" }
return@CollectEvents
}
currentContinueButtonLoading = true
launch {
submitInformationUseCase
.invoke(event.id)
.fold(
ifLeft = {
errorSubmittingStep = it
currentContinueButtonLoading = false
logcat { "ClaimChatEvent.SubmitInformation error: $it" }
},
ifRight = { claimIntent ->
currentContinueButtonLoading = false
handleNext(
steps,
setOutcome,
claimIntent,
) { progress = it }
},
)
}
}
}
}

Expand Down Expand Up @@ -1112,7 +1146,8 @@ private fun ClaimIntentStep.clearContent(): ClaimIntentStep = when (val content
is StepContent.Task,
is StepContent.Deflect,
is StepContent.DeflectMessage,
StepContent.Unknown,
is StepContent.Information,
StepContent.Unknown
-> this
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import kotlin.jvm.JvmInline
import kotlin.time.Instant
import kotlinx.serialization.Contextual
import kotlinx.serialization.Serializable
import octopus.type.ClaimIntentStepContentInformationSeverity

@JvmInline
value class ClaimIntentId(val value: String)
Expand Down Expand Up @@ -179,6 +180,20 @@ internal sealed interface StepContent {
object Unknown : StepContent {
override val isSkippable: Boolean = false
}

@Serializable
data class Information(
val notice: String,
val buttonTitle: String,
val severity: InformationSeverity,
): StepContent {
override val isSkippable: Boolean = false
}
}


enum class InformationSeverity {
Critical, Info
}

sealed interface AudioRecordingStepState {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ import octopus.fragment.DeflectionInfoBlockFragment
import octopus.fragment.DeflectionMessageFragment
import octopus.fragment.FileUploadFragment
import octopus.fragment.FormFragment
import octopus.fragment.InformationFragment
import octopus.fragment.SummaryFragment
import octopus.fragment.TaskFragment
import octopus.type.ClaimIntentStepContentFormFieldType
import octopus.type.ClaimIntentStepContentInformationSeverity
import octopus.type.ClaimIntentStepContentSelectStyle

context(raise: Raise<ClaimChatErrorMessage>)
Expand Down Expand Up @@ -186,6 +188,15 @@ private fun ClaimIntentStepContentFragment.toStepContent(locale: CommonLocale):
message = message
)

is InformationFragment -> StepContent.Information(
notice = notice,
buttonTitle = buttonTitle,
severity = when (severity) {
ClaimIntentStepContentInformationSeverity.CRITICAL -> InformationSeverity.Critical
else -> InformationSeverity.Info
}
)

else -> {
logcat { "ClaimIntentStepContentFragment: Unknown step" }
raise(ClaimChatErrorMessage.NeedsUpdate)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.hedvig.feature.claim.chat.data

import arrow.core.Either
import arrow.core.raise.either
import com.apollographql.apollo.ApolloClient
import com.hedvig.android.apollo.safeExecute
import com.hedvig.android.core.common.di.AppScope
import com.hedvig.android.language.LanguageService
import com.hedvig.android.logger.logcat
import dev.zacsweers.metro.Inject
import dev.zacsweers.metro.SingleIn
import octopus.ClaimIntentSubmitInformationMutation
import octopus.type.ClaimIntentSubmitInformationInput

@SingleIn(AppScope::class)
@Inject
internal class SubmitInformationUseCase(
private val apolloClient: ApolloClient,
private val languageService: LanguageService,
) {
suspend fun invoke(id: StepId): Either<ClaimChatErrorMessage, ClaimIntent> {
return either {
apolloClient
.mutation(
ClaimIntentSubmitInformationMutation(
input = ClaimIntentSubmitInformationInput(
stepId = id.value,
),
),
)
.safeExecute()
.mapLeft {
logcat { "SubmitInformationUseCase error: $it" }
ClaimChatErrorMessage.GeneralError
}
.bind()
.claimIntentSubmitInformation
.toClaimIntent(languageService.getLocale())
}
}
}
Loading
Loading