Skip to content

Commit

Permalink
refactor: refactor Individual collection sheet details fragment to co…
Browse files Browse the repository at this point in the history
…mpose
  • Loading branch information
Aditya-gupta99 committed Jul 13, 2024
1 parent 5705fb7 commit 7e09ec3
Show file tree
Hide file tree
Showing 17 changed files with 512 additions and 271 deletions.
7 changes: 6 additions & 1 deletion core/data/src/main/java/com/mifos/core/data/di/DataModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.mifos.core.data.repository.CreateNewCenterRepository
import com.mifos.core.data.repository.DocumentListRepository
import com.mifos.core.data.repository.GroupDetailsRepository
import com.mifos.core.data.repository.GroupsListRepository
import com.mifos.core.data.repository.IndividualCollectionSheetDetailsRepository
import com.mifos.core.data.repository.LoanAccountRepository
import com.mifos.core.data.repository.NewIndividualCollectionSheetRepository
import com.mifos.core.data.repository.PathTrackingRepository
Expand All @@ -26,6 +27,7 @@ import com.mifos.core.data.repository_imp.CreateNewCenterRepositoryImp
import com.mifos.core.data.repository_imp.DocumentListRepositoryImp
import com.mifos.core.data.repository_imp.GroupDetailsRepositoryImp
import com.mifos.core.data.repository_imp.GroupsListRepositoryImpl
import com.mifos.core.data.repository_imp.IndividualCollectionSheetDetailsRepositoryImp
import com.mifos.core.data.repository_imp.LoanAccountRepositoryImp
import com.mifos.core.data.repository_imp.NewIndividualCollectionSheetRepositoryImp
import com.mifos.core.data.repository_imp.PathTrackingRepositoryImp
Expand Down Expand Up @@ -80,10 +82,13 @@ abstract class DataModule {

@Binds
internal abstract fun bindReportDetailRepository(impl: ReportDetailRepositoryImp): ReportDetailRepository

@Binds
internal abstract fun bindLoanAccountRepository(impl: LoanAccountRepositoryImp): LoanAccountRepository

@Binds
internal abstract fun bindDocumentListRepository(impl: DocumentListRepositoryImp): DocumentListRepository

@Binds
internal abstract fun bindIndividualCollectionSheetDetailsRepositoryImp(impl: IndividualCollectionSheetDetailsRepositoryImp): IndividualCollectionSheetDetailsRepository
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.mifos.mifosxdroid.online.collectionsheetindividualdetails
package com.mifos.core.data.repository

import com.mifos.core.network.GenericResponse
import com.mifos.core.network.model.IndividualCollectionSheetPayload
Expand All @@ -9,8 +9,8 @@ import rx.Observable
*/
interface IndividualCollectionSheetDetailsRepository {

fun saveIndividualCollectionSheet(
payload: IndividualCollectionSheetPayload?
): Observable<GenericResponse>
suspend fun saveIndividualCollectionSheet(
payload: IndividualCollectionSheetPayload
): GenericResponse

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.mifos.mifosxdroid.online.collectionsheetindividualdetails
package com.mifos.core.data.repository_imp

import com.mifos.core.data.repository.IndividualCollectionSheetDetailsRepository
import com.mifos.core.network.GenericResponse
import com.mifos.core.network.datamanager.DataManagerCollectionSheet
import com.mifos.core.network.model.IndividualCollectionSheetPayload
Expand All @@ -12,7 +13,7 @@ import javax.inject.Inject
class IndividualCollectionSheetDetailsRepositoryImp @Inject constructor(private val dataManagerCollection: DataManagerCollectionSheet) :
IndividualCollectionSheetDetailsRepository {

override fun saveIndividualCollectionSheet(payload: IndividualCollectionSheetPayload?): Observable<GenericResponse> {
override suspend fun saveIndividualCollectionSheet(payload: IndividualCollectionSheetPayload): GenericResponse {
return dataManagerCollection.saveIndividualCollectionSheet(payload)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import androidx.compose.material.icons.rounded.ArrowBackIosNew
import androidx.compose.material.icons.rounded.Check
import androidx.compose.material.icons.rounded.Close
import androidx.compose.material.icons.rounded.Delete
import androidx.compose.material.icons.rounded.Download
import androidx.compose.material.icons.rounded.FilterList
import androidx.compose.material.icons.rounded.KeyboardArrowDown
import androidx.compose.material.icons.rounded.KeyboardArrowUp
Expand All @@ -37,4 +38,5 @@ object MifosIcons {
val moreVert = Icons.Rounded.MoreVert
val fileTask = Icons.Default.AssignmentTurnedIn
val cloudDownload = Icons.Default.CloudDownload
val save = Icons.Rounded.Download
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.mifos.core.domain.use_cases

import com.mifos.core.common.utils.Resource
import com.mifos.core.data.repository.IndividualCollectionSheetDetailsRepository
import com.mifos.core.network.GenericResponse
import com.mifos.core.network.model.IndividualCollectionSheetPayload
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import javax.inject.Inject

class SaveIndividualCollectionSheetUseCase @Inject constructor(private val repository: IndividualCollectionSheetDetailsRepository) {

suspend operator fun invoke(payload: IndividualCollectionSheetPayload): Flow<Resource<GenericResponse>> =
flow {
try {
emit(Resource.Loading())
val response = repository.saveIndividualCollectionSheet(payload)
emit(Resource.Success(response))
} catch (exception: Exception) {
emit(Resource.Error(exception.message.toString()))
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ class DataManagerCollectionSheet @Inject constructor(
return mBaseApiManager.collectionSheetApi.getIndividualCollectionSheet(payload)
}

fun saveIndividualCollectionSheet(
suspend fun saveIndividualCollectionSheet(
payload: IndividualCollectionSheetPayload?
): Observable<GenericResponse> {
): GenericResponse {
return mBaseApiManager.collectionSheetApi.saveindividualCollectionSheet(payload)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ interface CollectionSheetService {
): IndividualCollectionSheet

@POST(APIEndPoint.COLLECTION_SHEET + "?command=saveCollectionSheet")
fun saveindividualCollectionSheet(
suspend fun saveindividualCollectionSheet(
@Body payload: IndividualCollectionSheetPayload?
): Observable<GenericResponse>
): GenericResponse
//Productive CollectionSheet Endpoints
/**
* Endpoint to fetch Productive CollectionSheet
Expand Down
2 changes: 2 additions & 0 deletions feature/collection-sheet/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ dependencies {

implementation(projects.core.domain)

implementation(libs.coil.kt.compose)

//DBFlow dependencies
kapt(libs.dbflow.processor)
implementation(libs.dbflow)
Expand Down
Loading

0 comments on commit 7e09ec3

Please sign in to comment.