Skip to content

refactor(feature:client): merge ViewModels, add charge validation, fix empty chargeOptions crash - #2430

Merged
niyajali merged 13 commits into
openMF:kmp-implfrom
biplab1:MIFOSAC-458-client-charge-dialog
Jul 15, 2025
Merged

refactor(feature:client): merge ViewModels, add charge validation, fix empty chargeOptions crash#2430
niyajali merged 13 commits into
openMF:kmp-implfrom
biplab1:MIFOSAC-458-client-charge-dialog

Conversation

@biplab1

@biplab1 biplab1 commented Jul 7, 2025

Copy link
Copy Markdown
Contributor

Fixes - Jira-#458

Summary of Changes:

  • Fix crash by adding default selected charge values to ChargeDialogUiState.AllChargesV2 when chargeOptions is empty.
  • Merge two dialog view model into client charge view model
  • Show snackbar message on successful charge creation
  • Add input validation dialog input fields and enable/disable button accordingly
  • Make 'ChargeOptions` fields nullable to handle missing field in API response

Before Fix (without charges setup in web-app):

before-fix-client-charges-dialog.mp4

Before Fix (with charges setup in web-app and no database bypass):

before-fix-client-charges-dialog-no-charge-setup-no-database-bypass.webm

After Fix:
Note:

  • The newly created charge appears second from the top in the screen recording
  • The charges list is fetched directly from API, bypassing the database
    (the database handling is a work in progress in another PR)
Client-Charges-Dialog-Merge-Viewmodels.mp4

Please make sure these boxes are checked before submitting your pull request - thanks!

  • Run the static analysis check ./gradlew check or ci-prepush.sh to make sure you didn't break anything

  • If you have multiple commits please combine them into one commit by squashing them.

@biplab1 biplab1 changed the title Mifosac 458 client charge dialog fix(feature:client): fix bugs, improve charge dialog UX and state handling Jul 7, 2025
@biplab1

biplab1 commented Jul 7, 2025

Copy link
Copy Markdown
Contributor Author

Note: Merge this after #2428

@biplab1
biplab1 marked this pull request as ready for review July 7, 2025 09:53
@Nagarjuna0033

Nagarjuna0033 commented Jul 7, 2025

Copy link
Copy Markdown
Contributor

@biplab1 I think for now we can focus only on the issues that are crashing the application or any api error handling things, because Show snackbar message on successful charge creation, Refactor dialog screen content for better readability and reuse,
Add resetUiState to handle dialog state after successful submission are not that much important as the feature is working. As you know we will be getting new mockups you can take a look into those. we may need to refactor lot of things and may be need to remove current ui components and if necessary, screens also. Then this work will be waste of time. So, it would be better we can fastly wrap up cleaning kmp-impl branch and merging into dev branch. correct me if I am wrong.

@niyajali @revanthkumarJ @itsPronay your thoughts on this

@revanthkumarJ

revanthkumarJ commented Jul 7, 2025

Copy link
Copy Markdown
Contributor

@biplab1 I think for now we can focus only on the issues that are crashing the application or any api error handling things, because Show snackbar message on successful charge creation, Refactor dialog screen content for better readability and reuse, Add resetUiState to handle dialog state after successful submission are not that much important as the feature is working. As you know we will be getting new mockups you can take a look into those. we may need to refactor lot of things and may be need to remove current ui components and if necessary, screens also. Then this work will be waste of time. So, it would be better we can fastly wrap up cleaning kmp-impl branch and merging into dev branch. correct me if I am wrong.

@niyajali @revanthkumarJ @itsPronay your thoughts on this

I also think same like when i see mifos-mobile or template we have used Actions , Events , BaseViewModel and some neat architecture
if we are going to implement similarly here in android client while implementing mockups then,
how we handled snackbars , states everything should be moved to viewmodel and change current implementation completely, so may be we can fix small small ui fixes there

@biplab1

biplab1 commented Jul 7, 2025

Copy link
Copy Markdown
Contributor Author

@Nagarjuna0033 @revanthkumarJ Just to clarify — the feature wasn’t fully working before.

It was crashing when chargeOptions came back empty. I added the necessary chargeOptions data so the API response works as expected, and updated the dialog to handle nullable entries to prevent it getting stuck on load.

So the snackbar, state reset, and dialog refactor are not just polish — they fix real flow blockers and ensure the screen stays stable as we transition to the new UI.

Skipping these now risks the same crash or broken flow later.

@biplab1
biplab1 force-pushed the MIFOSAC-458-client-charge-dialog branch from 5e097f3 to 9d9ecff Compare July 9, 2025 17:00
@biplab1
biplab1 force-pushed the MIFOSAC-458-client-charge-dialog branch from 9d9ecff to 7d190f5 Compare July 9, 2025 17:23
@biplab1
biplab1 force-pushed the MIFOSAC-458-client-charge-dialog branch from cd3abe6 to 11b3b28 Compare July 11, 2025 01:45
@biplab1
biplab1 force-pushed the MIFOSAC-458-client-charge-dialog branch from 430bda4 to fd12819 Compare July 11, 2025 19:58
@niyajali

Copy link
Copy Markdown
Collaborator

@biplab1
biplab1 force-pushed the MIFOSAC-458-client-charge-dialog branch from fc35b6d to 5d91342 Compare July 13, 2025 20:29
@biplab1 biplab1 changed the title fix(feature:client): fix bugs, improve charge dialog UX and state handling refactor(feature:client): merge ViewModels, add charge validation, fix empty chargeOptions crash Jul 14, 2025
@biplab1

biplab1 commented Jul 15, 2025

Copy link
Copy Markdown
Contributor Author

@niyajali I’ve merged the two view models as discussed. Please let me know if anything else needs to be done. If everything looks good, kindly go ahead and merge it.

@niyajali
niyajali merged commit f007495 into openMF:kmp-impl Jul 15, 2025
1 check passed
itsPronay pushed a commit to itsPronay/android-client that referenced this pull request Aug 5, 2025
…x empty chargeOptions crash (openMF#2430)

Co-authored-by: Sk Niyaj Ali <niyaj639@gmail.com>
itsPronay pushed a commit to itsPronay/android-client that referenced this pull request Aug 5, 2025
…x empty chargeOptions crash (openMF#2430)

Co-authored-by: Sk Niyaj Ali <niyaj639@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants