Skip to content

Commit

Permalink
fix: Handle unverified account error (#2286)
Browse files Browse the repository at this point in the history
  • Loading branch information
liveHarshit committed Aug 18, 2019
1 parent 5edbc55 commit 2545c64
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,14 @@ class AttendeeFragment : Fragment(), ComplexBackPressFragment {
progressDialog.show(it)
})

attendeeViewModel.redirectToProfile
.observe(viewLifecycleOwner, Observer {
rootView.longSnackbar(getString(R.string.verify_your_profile))
findNavController(rootView).navigate(
AttendeeFragmentDirections.actionTicketsToProfile()
)
})

rootView.sameBuyerCheckBox.setOnCheckedChangeListener { _, isChecked ->
if (isChecked) {
val firstName = rootView.firstName.text.toString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ class AttendeeViewModel(
val stripeOrderMade: LiveData<Boolean> = mutableStripeOrderMade
private val mutableOrderExpiryTime = MutableLiveData<Int>()
val orderExpiryTime: LiveData<Int> = mutableOrderExpiryTime
private val mutableRedirectToProfile = SingleLiveEvent<Boolean>()
val redirectToProfile = mutableRedirectToProfile

val attendees = ArrayList<Attendee>()
private val attendeesForOrder = ArrayList<Attendee>()
Expand Down Expand Up @@ -165,6 +167,11 @@ class AttendeeViewModel(
mutablePendingOrder.value = it
orderIdentifier = it.identifier.toString()
}, {
if (it is HttpException) {
if (it.code() == HttpErrors.UNPROCESSABLE_ENTITY) {
mutableRedirectToProfile.value = true
}
}
Timber.e(it, "Fail on creating pending order")
})
}
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/navigation/navigation_graph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,15 @@
app:enterAnim="@anim/fade_in"
app:exitAnim="@anim/fade_out"/>

<action
android:id="@+id/action_tickets_to_profile"
app:destination="@id/profileFragment"
app:popUpTo="@id/eventDetailsFragment"
app:popEnterAnim="@anim/fade_in"
app:popExitAnim="@anim/fade_out"
app:enterAnim="@anim/fade_in"
app:exitAnim="@anim/fade_out"/>

<action
android:id="@+id/action_attendee_to_ticket_pop"
app:popUpToInclusive="true"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
<string name="verified">Verified</string>
<string name="not_verified">Account not verified. Click to verify</string>
<string name="verification_error_message">Error in verifying email</string>
<string name="verify_your_profile">Please verify your email to buy free tickets</string>

<!--eventyay-->
<string name="eventyay_logo" translatable="false">eventyay</string>
Expand Down

0 comments on commit 2545c64

Please sign in to comment.