Skip to content

Conversation

@WizCoderr
Copy link
Contributor

@WizCoderr WizCoderr commented Oct 31, 2025

Fixes - Jira-#Issue_Number

Didn't create a Jira ticket, click here to create new.

Please Add Screenshots If there are any UI changes.

Before After

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.

Summary by CodeRabbit

  • New Features

    • Added share application fill screen with dedicated navigation flow.
    • Added overlay loading indicator during application submission.
    • Introduced application date tracking for share submissions.
  • Improvements

    • Enhanced form validation to support larger share quantities.
    • Improved error handling and data fetching for client and share product information.

@coderabbitai
Copy link

coderabbitai bot commented Oct 31, 2025

Walkthrough

The changes introduce a consolidated navigation and state management structure for the Share Application feature. New serializable routes enable type-safe navigation between screens. ViewModel signatures expand to support additional UI callbacks, overlay state management, and a combined data-fetch flow. Input validation widens to accept larger share quantities. Navigation callbacks now thread through the entire graph for consistent flow management.

Changes

Cohort / File(s) Summary
Navigation Routes & Graph Setup
feature/share-application/src/commonMain/kotlin/org/mifos/mobile/feature/share/application/fillApplication/FillApplicationRoute.kt, feature/share-application/src/commonMain/kotlin/org/mifos/mobile/feature/share/application/shareApplication/ShareApplyRoute.kt, feature/share-application/src/commonMain/kotlin/org/mifos/mobile/feature/share/application/navigation/ShareApplicationNavGraph.kt
Added serializable route data classes for ShareFillApplicationRoute and ShareApplyRoute. Introduced NavController extensions (navigateToShareFillApplicationScreen, navigateToShareApplyScreen, navigateToShareApplicationGraph) and NavGraphBuilder destinations (shareFillApplicationDestination, shareApplyDestination). Expanded shareApplicationNavGraph to pass navigateToStatusScreen callback through the graph.
Screen Components
feature/share-application/src/commonMain/kotlin/org/mifos/mobile/feature/share/application/fillApplication/FillApplicationScreen.kt, feature/share-application/src/commonMain/kotlin/org/mifos/mobile/feature/share/application/shareApplication/ShareApplyScreen.kt
Updated function signatures: ShareFillApplicationScreen and ShareApplyScreen now accept additional navigation callbacks (navigateToStatusScreen, navigateToAuthenticateScreen, navigateToFillDetailsScreen) and ViewModel parameters with defaults. Added modifier: Modifier = Modifier parameter to ShareFillApplicationContent, ShareFillApplicationForm, ShareApplicationContent, and ShareApplicationForm. Added KDoc documentation blocks.
ViewModel & State Management
feature/share-application/src/commonMain/kotlin/org/mifos/mobile/feature/share/application/fillApplication/FillApplicationViewModel.kt, feature/share-application/src/commonMain/kotlin/org/mifos/mobile/feature/share/application/shareApplication/ShareApplyViewModel.kt
Extended ShareApplicationState with showOverlay: Boolean flag and submittedOnDate: String property. Updated share quantity validation from toIntOrNull() to toLongOrNull(). Introduced ReceiveClientAndTemplateResult action carrying both client and template data states. Added consolidated getClientDataAndTemplate() fetch flow. Removed debug print statements. Added AccountingMappings.toAccountList() extension. Improved error handling to capture exceptions.
Dependency Injection
feature/share-application/src/commonMain/kotlin/org/mifos/mobile/feature/share/application/di/ShareApplicationModule.kt
Added KDoc comment block describing the Koin module for Share Application feature. No behavioral changes to module definitions.

Sequence Diagram

sequenceDiagram
    participant User
    participant ShareApplyScreen
    participant FillApplicationScreen
    participant StatusScreen
    participant ViewModel as FillApplicationViewModel

    User->>ShareApplyScreen: Select Share Product
    ShareApplyScreen->>FillApplicationScreen: navigateToShareFillApplicationScreen(productId)
    FillApplicationScreen->>ViewModel: Load client data & template
    ViewModel->>ViewModel: Validate & process form
    User->>FillApplicationScreen: Submit application
    FillApplicationScreen->>ViewModel: Submit with overlay
    ViewModel->>ViewModel: Process submission
    alt Success
        FillApplicationScreen->>StatusScreen: navigateToStatusScreen(params...)
    else Authenticate Required
        FillApplicationScreen->>ShareApplyScreen: navigateToAuthenticateScreen()
    end
    User->>StatusScreen: View result
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–25 minutes

  • Areas requiring extra attention:
    • Validation logic change from toIntOrNull() to toLongOrNull() in FillApplicationViewModel.kt — verify integer overflow/limits and upstream impacts
    • New ReceiveClientAndTemplateResult action structure in ShareApplyViewModel.kt — ensure all callsites properly construct both client and template DataState payloads
    • Navigation callback threading (navigateToStatusScreen) through ShareApplicationNavGraph.kt — confirm all screen layers receive and invoke callbacks correctly
    • submittedOnDate date formatting logic — validate date format consistency with backend expectations
    • Duplicate AccountingMappings.toAccountList() extension across scopes — verify intended scope and usage patterns

Poem

🐰 Routes now serialize, states overlay bright,
Share products flow gracefully left and right,
Validation counts high, callbacks thread through,
Navigation paths clear—the feature is new! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Title Check ⚠️ Warning The PR title "Documentation Done for feature/share-application" is misleading regarding the actual scope of changes. While documentation and KDoc blocks were indeed added to several files, the raw summary reveals substantial functional modifications as the primary focus, including new serializable route data classes, expanded ViewModel signatures with state extensions (showOverlay, submittedOnDate), updated validation logic (toIntOrNull to toLongOrNull), navigation function additions, error handling improvements, and a consolidated data fetch flow. A developer scanning commit history based on this title would incorrectly assume this is a documentation-only PR rather than a feature/refactoring PR.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 88.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
feature/share-application/src/commonMain/kotlin/org/mifos/mobile/feature/share/application/fillApplication/FillApplicationViewModel.kt (1)

666-677: Clear the overlay before emitting success.

On the success branch we never reset showOverlay to false, so the overlay remains stuck if navigation fails or the user pops back to this screen. Please drop the overlay before firing the status event.

-        is DataState.Success -> sendEvent(
-            ShareApplicationEvent.NavigateToStatus(
-                eventType = EventType.SUCCESS.name,
-                eventDestination = StatusNavigationDestination.SHARE_APPLICATION.name,
-                title = getString(Res.string.feature_apply_share_status_success),
-                subtitle = getString(
-                    Res.string.feature_apply_share_status_success_tip,
-                    state.shareProductName,
-                ),
-                buttonText = getString(Res.string.feature_apply_share_status_success_action),
-            ),
-        )
+        is DataState.Success -> {
+            updateState { it.copy(showOverlay = false) }
+            sendEvent(
+                ShareApplicationEvent.NavigateToStatus(
+                    eventType = EventType.SUCCESS.name,
+                    eventDestination = StatusNavigationDestination.SHARE_APPLICATION.name,
+                    title = getString(Res.string.feature_apply_share_status_success),
+                    subtitle = getString(
+                        Res.string.feature_apply_share_status_success_tip,
+                        state.shareProductName,
+                    ),
+                    buttonText = getString(Res.string.feature_apply_share_status_success_action),
+                ),
+            )
+        }
🧹 Nitpick comments (2)
feature/share-application/src/commonMain/kotlin/org/mifos/mobile/feature/share/application/di/ShareApplicationModule.kt (1)

17-21: Consider optional enhancement: List specific ViewModels in the documentation.

For completeness, the KDoc could optionally list the specific ViewModels provided (ShareApplyViewModel and ShareFillApplicationViewModel). This would improve discoverability for developers using the module, though the current documentation is sufficient as-is.

Example enhancement:

 /**
  * Koin module for the Share Application feature.
  *
- * This module provides the ViewModels required for the share application screens.
+ * This module provides the ViewModels required for the share application screens:
+ * - [ShareApplyViewModel]
+ * - [ShareFillApplicationViewModel]
  */
feature/share-application/src/commonMain/kotlin/org/mifos/mobile/feature/share/application/shareApplication/ShareApplyViewModel.kt (1)

387-395: Consider capturing submission date at a specific point in time.

The submittedOnDate property dynamically computes the current date on each access. If accessed multiple times during form submission (e.g., for display and then for actual submission), it could theoretically return different dates if the user submits near midnight.

For consistency and audit purposes, consider capturing the submission date at a specific moment (e.g., when the form is initialized or when the submit action is triggered) rather than computing it dynamically.

For example, you could capture it when the submit action is initiated:

// In ShareApplicationState, change to a regular property
val submittedOnDate: String

And set it explicitly in handleSubmit():

private fun handleSubmit() {
    viewModelScope.launch {
        try {
            val submissionDate = DateHelper.getDateMonthYearString(
                Clock.System.now().toEpochMilliseconds()
            )
            updateState {
                it.copy(
                    hasChanges = false,
                    uiState = ShareApplicationUiState.Success,
                    submittedOnDate = submissionDate
                )
            }
            sendEvent(ShareApplicationEvent.NavigateToConfirmDetailsScreen)
        } catch (e: Exception) {
            showErrorState(Res.string.feature_apply_share_error_submit_failed)
        }
    }
}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 70c39c6 and a3340d2.

📒 Files selected for processing (8)
  • feature/share-application/src/commonMain/kotlin/org/mifos/mobile/feature/share/application/di/ShareApplicationModule.kt (1 hunks)
  • feature/share-application/src/commonMain/kotlin/org/mifos/mobile/feature/share/application/fillApplication/FillApplicationRoute.kt (1 hunks)
  • feature/share-application/src/commonMain/kotlin/org/mifos/mobile/feature/share/application/fillApplication/FillApplicationScreen.kt (4 hunks)
  • feature/share-application/src/commonMain/kotlin/org/mifos/mobile/feature/share/application/fillApplication/FillApplicationViewModel.kt (3 hunks)
  • feature/share-application/src/commonMain/kotlin/org/mifos/mobile/feature/share/application/navigation/ShareApplicationNavGraph.kt (1 hunks)
  • feature/share-application/src/commonMain/kotlin/org/mifos/mobile/feature/share/application/shareApplication/ShareApplyRoute.kt (1 hunks)
  • feature/share-application/src/commonMain/kotlin/org/mifos/mobile/feature/share/application/shareApplication/ShareApplyScreen.kt (4 hunks)
  • feature/share-application/src/commonMain/kotlin/org/mifos/mobile/feature/share/application/shareApplication/ShareApplyViewModel.kt (8 hunks)
🔇 Additional comments (7)
feature/share-application/src/commonMain/kotlin/org/mifos/mobile/feature/share/application/di/ShareApplicationModule.kt (1)

17-21: Well-documented KDoc for the Koin module.

The KDoc accurately describes the module's role and is properly formatted. The documentation appropriately identifies the module's responsibility for providing ViewModels for share application screens.

feature/share-application/src/commonMain/kotlin/org/mifos/mobile/feature/share/application/shareApplication/ShareApplyRoute.kt (1)

40-49: Navigation destination wiring looks solid.

The shareApplyDestination hook cleanly threads the callbacks through the graph with the slide transition helper. Nicely done.

feature/share-application/src/commonMain/kotlin/org/mifos/mobile/feature/share/application/navigation/ShareApplicationNavGraph.kt (1)

44-61: Graph wiring reads clean.

The top-level graph now forwards both authentication and status callbacks cleanly into the fill destination while keeping back navigation centralized. Looks good.

feature/share-application/src/commonMain/kotlin/org/mifos/mobile/feature/share/application/fillApplication/FillApplicationScreen.kt (1)

194-199: Overlay handling in the UI matches the new state.

Conditionally showing MifosProgressIndicatorOverlay() when showOverlay is true gives us a clear visual block during submission. Nice integration with the updated ViewModel state.

feature/share-application/src/commonMain/kotlin/org/mifos/mobile/feature/share/application/shareApplication/ShareApplyScreen.kt (1)

72-76: Passing the selected product id through navigation looks correct.

Threading state.selectedShareProductId into navigateToFillDetailsScreen keeps the navigation strongly typed without exposing internals to the caller. Good update.

feature/share-application/src/commonMain/kotlin/org/mifos/mobile/feature/share/application/fillApplication/FillApplicationRoute.kt (1)

20-62: LGTM! Well-documented navigation setup.

The serializable route, navigation extension, and destination registration follow standard Compose Navigation patterns. The documentation is clear and comprehensive.

feature/share-application/src/commonMain/kotlin/org/mifos/mobile/feature/share/application/shareApplication/ShareApplyViewModel.kt (1)

97-97: Documentation updates look good.

The updated comments and documentation accurately reflect the consolidated data fetch flow and clarify the relationship between client data and template handling.

Also applies to: 124-126, 164-165, 201-201, 278-278, 346-348

@therajanmaurya therajanmaurya merged commit 6268b3b into openMF:development Oct 31, 2025
8 checks passed
@WizCoderr WizCoderr deleted the MM-444 branch October 31, 2025 17:14
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.

2 participants