Skip to content

Commit

Permalink
feat: Implemented fineract sdk cmp
Browse files Browse the repository at this point in the history
  • Loading branch information
Aditya-gupta99 committed Dec 15, 2024
1 parent af22111 commit c535672
Show file tree
Hide file tree
Showing 16 changed files with 68 additions and 65 deletions.
6 changes: 3 additions & 3 deletions core/data/src/main/java/com/mifos/core/data/di/DataModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,15 @@ import com.mifos.core.data.repository.SearchRepository
import com.mifos.core.data.repository.SignatureRepository
import com.mifos.core.data.repository.SurveyListRepository
import com.mifos.core.data.repository.SurveySubmitRepository
import com.mifos.core.data.repositoryImp.ActivateRepositoryImp
import com.mifos.core.data.repositoryImp.CenterDetailsRepositoryImp
import com.mifos.core.data.repositoryImp.CenterListRepositoryImp
import com.mifos.core.data.repositoryImp.ChargeDialogRepositoryImp
import com.mifos.core.data.repositoryImp.CheckerInboxRepositoryImp
import com.mifos.core.data.repositoryImp.CheckerInboxTasksRepositoryImp
import com.mifos.core.data.repositoryImp.ClientChargeRepositoryImp
import com.mifos.core.data.repositoryImp.ClientIdentifierDialogRepositoryImp
import com.mifos.core.data.repositoryImp.ClientIdentifiersRepositoryImp
import com.mifos.core.data.repositoryImp.CreateNewCenterRepositoryImp
import com.mifos.core.data.repositoryImp.CreateNewGroupRepositoryImp
import com.mifos.core.data.repositoryImp.DataTableDataRepositoryImp
import com.mifos.core.data.repositoryImp.DataTableListRepositoryImp
import com.mifos.core.data.repositoryImp.DataTableRepositoryImp
import com.mifos.core.data.repositoryImp.DataTableRowDialogRepositoryImp
Expand Down Expand Up @@ -89,6 +86,9 @@ import com.mifos.core.data.repositoryImp.SearchRepositoryImp
import com.mifos.core.data.repositoryImp.SignatureRepositoryImp
import com.mifos.core.data.repositoryImp.SurveyListRepositoryImp
import com.mifos.core.data.repositoryImp.SurveySubmitRepositoryImp
import com.mifos.core.data.repository_imp.ActivateRepositoryImp
import com.mifos.core.data.repository_imp.ClientIdentifiersRepositoryImp
import com.mifos.core.data.repository_imp.DataTableDataRepositoryImp
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.mifos.core.data.paging_source
package com.mifos.core.data.pagingSource

import androidx.paging.PagingSource
import androidx.paging.PagingState
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.mifos.core.data.paging_source
package com.mifos.core.data.pagingSource

import androidx.paging.PagingSource
import androidx.paging.PagingState
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.mifos.core.domain.use_cases
package com.mifos.core.domain.useCases

import com.mifos.core.common.utils.Resource
import com.mifos.core.data.repository.ActivateRepository
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.mifos.core.domain.use_cases
package com.mifos.core.domain.useCases

import com.mifos.core.common.utils.Resource
import com.mifos.core.data.repository.ActivateRepository
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.mifos.core.domain.use_cases
package com.mifos.core.domain.useCases

import com.mifos.core.common.utils.Resource
import com.mifos.core.data.repository.DataTableDataRepository
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.mifos.core.domain.use_cases
package com.mifos.core.domain.useCases

import com.mifos.core.common.utils.Resource
import com.mifos.core.data.repository.ClientIdentifiersRepository
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.mifos.core.domain.use_cases
package com.mifos.core.domain.useCases

import com.mifos.core.common.utils.Resource
import com.mifos.core.data.repository.ClientDetailsRepository
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.mifos.core.domain.use_cases
package com.mifos.core.domain.useCases

import com.mifos.core.common.utils.Resource
import com.mifos.core.data.repository.ClientIdentifiersRepository
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.mifos.core.domain.use_cases
package com.mifos.core.domain.useCases

import com.mifos.core.common.utils.Resource
import com.mifos.core.data.repository.CreateNewGroupRepository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.mifos.core.designsystem.component.MifosCircularProgress
import com.mifos.core.objects.group.Center
import com.mifos.feature.center.R
import com.mifos.feature.center.sync_centers_dialog.SyncCentersDialogViewModel

@Composable
internal fun SyncCenterDialogScreen(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.mifos.core.common.utils.Resource
import com.mifos.core.data.repository.CreateNewClientRepository
import com.mifos.core.domain.use_cases.ClientTemplateUseCase
import com.mifos.core.domain.use_cases.GetOfficeListUseCase
import com.mifos.core.domain.useCases.ClientTemplateUseCase
import com.mifos.core.domain.useCases.GetOfficeListUseCase
import com.mifos.core.domain.use_cases.GetStaffInOfficeForCreateNewClientUseCase
import com.mifos.core.objects.client.Client
import com.mifos.core.objects.client.ClientPayload
Expand Down Expand Up @@ -39,7 +39,7 @@ class CreateNewClientViewModel @Inject constructor(
private val repository: CreateNewClientRepository,
private val clientTemplateUseCase: ClientTemplateUseCase,
private val getStaffInOffice: GetStaffInOfficeForCreateNewClientUseCase,
private val getOfficeListUseCase: GetOfficeListUseCase
private val getOfficeListUseCase: GetOfficeListUseCase,
) : ViewModel() {

private val _createNewClientUiState =
Expand Down Expand Up @@ -109,46 +109,48 @@ class CreateNewClientViewModel @Inject constructor(
repository.createClient(clientPayload)
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
.subscribe(object : Subscriber<Client>() {
override fun onCompleted() {
}

override fun onError(e: Throwable) {
try {
if (e is HttpException) {
val errorMessage = e.response()?.errorBody()
?.string() ?: ""
Log.d("error", errorMessage)
_createNewClientUiState.value =
CreateNewClientUiState.ShowStringError(errorMessage)
.subscribe(
object : Subscriber<Client>() {
override fun onCompleted() {
}

override fun onError(e: Throwable) {
try {
if (e is HttpException) {
val errorMessage = e.response()?.errorBody()
?.string() ?: ""
Log.d("error", errorMessage)
_createNewClientUiState.value =
CreateNewClientUiState.ShowStringError(errorMessage)

}
} catch (throwable: Throwable) {
RxJavaPlugins.getInstance().errorHandler.handleError(e)
}
} catch (throwable: Throwable) {
RxJavaPlugins.getInstance().errorHandler.handleError(e)
}
}

override fun onNext(client: Client?) {
if (client != null) {
if (client.clientId != null) {
_createNewClientUiState.value =
CreateNewClientUiState.ShowClientCreatedSuccessfully(R.string.feature_client_client_created_successfully)

_createNewClientUiState.value = client.clientId?.let {
CreateNewClientUiState.SetClientId(
it
)
}!!
} else {
_createNewClientUiState.value = client.clientId?.let {
CreateNewClientUiState.ShowWaitingForCheckerApproval(
it
)
}!!
override fun onNext(client: Client?) {
if (client != null) {
if (client.clientId != null) {
_createNewClientUiState.value =
CreateNewClientUiState.ShowClientCreatedSuccessfully(R.string.feature_client_client_created_successfully)

_createNewClientUiState.value = client.clientId?.let {
CreateNewClientUiState.SetClientId(
it,
)
}!!
} else {
_createNewClientUiState.value = client.clientId?.let {
CreateNewClientUiState.ShowWaitingForCheckerApproval(
it,
)
}!!
}
}
}
}
})
},
)
}

fun uploadImage(id: Int, pngFile: File) {
Expand All @@ -164,19 +166,21 @@ class CreateNewClientViewModel @Inject constructor(
repository.uploadClientImage(id, body)
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
.subscribe(object : Subscriber<ResponseBody>() {
override fun onCompleted() {
}
.subscribe(
object : Subscriber<ResponseBody>() {
override fun onCompleted() {
}

override fun onError(e: Throwable) {
_createNewClientUiState.value =
CreateNewClientUiState.ShowError(R.string.feature_client_Image_Upload_Failed)
}
override fun onError(e: Throwable) {
_createNewClientUiState.value =
CreateNewClientUiState.ShowError(R.string.feature_client_Image_Upload_Failed)
}

override fun onNext(t: ResponseBody) {
_createNewClientUiState.value =
CreateNewClientUiState.OnImageUploadSuccess(R.string.feature_client_Image_Upload_Successful)
}
})
override fun onNext(t: ResponseBody) {
_createNewClientUiState.value =
CreateNewClientUiState.OnImageUploadSuccess(R.string.feature_client_Image_Upload_Successful)
}
},
)
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.mifos.feature.client.sync_client_dialog
package com.mifos.feature.client.syncClientDialog

import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.mifos.feature.groups.sync_group_dialog
package com.mifos.feature.groups.syncGroupDialog

import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import com.mifos.mifosxdroid.AndroidClientActivity
import com.mifos.mifosxdroid.R
import com.mifos.mifosxdroid.passcode.PassCodeActivity
import com.mifos.utils.Constants
import com.mifos.utils.LanguageHelper
import com.mifos.utils.PrefManager
Expand Down
1 change: 0 additions & 1 deletion mifosng-android/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
<dimen name="datatable_name_heading">18sp</dimen>
<dimen name="dimension_72_dp">72dp</dimen>
<dimen name="dimension_32_dp">32dp</dimen>
<dimen name="fab_margin">32dp</dimen>

<dimen name="marginItemsInSectionSmall">16dp</dimen>
<dimen name="marginItemsInSectionMedium">20dp</dimen>
Expand Down

0 comments on commit c535672

Please sign in to comment.