-
Notifications
You must be signed in to change notification settings - Fork 601
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: refactor checker inbox to compose (#2111)
* refactor: refactor checker inbox to compose * feat: added alert dailog * feat: added alert dailog * refactor: refactor checker inbox to compose * fix: code clean up * fix: fix merge conflict
- Loading branch information
1 parent
6b9fd65
commit f421d3a
Showing
35 changed files
with
1,118 additions
and
852 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
core/data/src/main/java/com/mifos/core/data/repository/CheckerInboxRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.mifos.core.data.repository | ||
|
||
import com.mifos.core.network.GenericResponse | ||
import com.mifos.core.objects.checkerinboxandtasks.CheckerInboxSearchTemplate | ||
import com.mifos.core.objects.checkerinboxandtasks.CheckerTask | ||
import kotlinx.coroutines.flow.Flow | ||
|
||
interface CheckerInboxRepository { | ||
|
||
suspend fun loadCheckerTasks( | ||
actionName: String? = null, entityName: String? = null, | ||
resourceId: Int? = null | ||
): List<CheckerTask> | ||
|
||
suspend fun approveCheckerEntry(auditId: Int): GenericResponse | ||
|
||
suspend fun rejectCheckerEntry(auditId: Int): GenericResponse | ||
|
||
suspend fun deleteCheckerEntry(auditId: Int): GenericResponse | ||
|
||
suspend fun loadSearchTemplate(): CheckerInboxSearchTemplate | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
core/data/src/main/java/com/mifos/core/data/repository_imp/CheckerInboxRepositoryImp.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.mifos.core.data.repository_imp | ||
|
||
import com.mifos.core.data.repository.CheckerInboxRepository | ||
import com.mifos.core.network.GenericResponse | ||
import com.mifos.core.network.datamanager.DataManagerCheckerInbox | ||
import com.mifos.core.objects.checkerinboxandtasks.CheckerInboxSearchTemplate | ||
import com.mifos.core.objects.checkerinboxandtasks.CheckerTask | ||
import javax.inject.Inject | ||
|
||
class CheckerInboxRepositoryImp @Inject constructor( | ||
private val dataManagerCheckerInbox: DataManagerCheckerInbox | ||
) : CheckerInboxRepository { | ||
|
||
override suspend fun loadCheckerTasks( | ||
actionName: String?, | ||
entityName: String?, | ||
resourceId: Int? | ||
): List<CheckerTask> { | ||
return dataManagerCheckerInbox.getCheckerTaskList() | ||
} | ||
|
||
override suspend fun approveCheckerEntry(auditId: Int): GenericResponse { | ||
return dataManagerCheckerInbox.approveCheckerEntry(auditId) | ||
} | ||
|
||
override suspend fun rejectCheckerEntry(auditId: Int): GenericResponse { | ||
return dataManagerCheckerInbox.rejectCheckerEntry(auditId) | ||
} | ||
|
||
override suspend fun deleteCheckerEntry(auditId: Int): GenericResponse { | ||
return dataManagerCheckerInbox.deleteCheckerEntry(auditId) | ||
} | ||
|
||
override suspend fun loadSearchTemplate(): CheckerInboxSearchTemplate { | ||
TODO("Not yet implemented") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 12 additions & 8 deletions
20
core/database/src/main/java/com/mifos/core/objects/checkerinboxandtasks/CheckerTask.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 11 additions & 7 deletions
18
...database/src/main/java/com/mifos/core/objects/checkerinboxandtasks/RescheduleLoansTask.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,15 @@ | ||
package com.mifos.core.objects.checkerinboxandtasks | ||
|
||
import android.os.Parcelable | ||
import com.google.gson.annotations.SerializedName | ||
import kotlinx.parcelize.Parcelize | ||
|
||
data class RescheduleLoansTask (@SerializedName("id") var id: Int, | ||
@SerializedName("clientName") var clientName: String, | ||
@SerializedName("loanAccountNumber") var loanAccountNo: String, | ||
@SerializedName("rescheduleFromDate") var rescheduleFromDate: Array<Int>, | ||
@SerializedName("actionName") var action: String, | ||
@SerializedName("rescheduleReasonCodeValue") | ||
var rescheduleReasonCodeValue: RescheduleReasonCodeValue) | ||
@Parcelize | ||
data class RescheduleLoansTask( | ||
var id: Int, | ||
var clientName: String, | ||
var loanAccountNumber: String, | ||
var rescheduleFromDate: Array<Int>, | ||
var actionName: String, | ||
var rescheduleReasonCodeValue: RescheduleReasonCodeValue | ||
) : Parcelable |
12 changes: 10 additions & 2 deletions
12
...se/src/main/java/com/mifos/core/objects/checkerinboxandtasks/RescheduleReasonCodeValue.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,12 @@ | ||
package com.mifos.core.objects.checkerinboxandtasks | ||
|
||
data class RescheduleReasonCodeValue (var id : Int, var name : String, | ||
var active : Boolean, var mandatory : Boolean) | ||
import android.os.Parcelable | ||
import kotlinx.parcelize.Parcelize | ||
|
||
@Parcelize | ||
data class RescheduleReasonCodeValue( | ||
var id: Int, | ||
var name: String, | ||
var active: Boolean, | ||
var mandatory: Boolean | ||
) : Parcelable |
44 changes: 44 additions & 0 deletions
44
core/designsystem/src/main/java/com/mifos/core/designsystem/component/MifosAlertDailog.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.mifos.core.designsystem.component | ||
|
||
import androidx.compose.material3.AlertDialog | ||
import androidx.compose.material3.Text | ||
import androidx.compose.material3.TextButton | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.res.stringResource | ||
|
||
@Composable | ||
fun MifosDialogBox( | ||
showDialogState: Boolean, | ||
onDismiss: () -> Unit, | ||
title: Int, | ||
message: Int? = null, | ||
confirmButtonText: Int, | ||
onConfirm: () -> Unit, | ||
dismissButtonText: Int | ||
) { | ||
if (showDialogState) { | ||
AlertDialog( | ||
onDismissRequest = onDismiss, | ||
title = { Text(text = stringResource(id = title)) }, | ||
text = { | ||
if (message != null) { | ||
Text(text = stringResource(id = message)) | ||
} | ||
}, | ||
confirmButton = { | ||
TextButton( | ||
onClick = { | ||
onConfirm() | ||
} | ||
) { | ||
Text(stringResource(id = confirmButtonText)) | ||
} | ||
}, | ||
dismissButton = { | ||
TextButton(onClick = onDismiss) { | ||
Text(stringResource(id = dismissButtonText)) | ||
} | ||
} | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
core/domain/src/main/java/com/mifos/core/domain/use_cases/ApproveCheckerUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.mifos.core.domain.use_cases | ||
|
||
import com.mifos.core.common.utils.Resource | ||
import com.mifos.core.data.repository.CheckerInboxRepository | ||
import com.mifos.core.network.GenericResponse | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.flow | ||
import javax.inject.Inject | ||
|
||
class ApproveCheckerUseCase @Inject constructor(val repository: CheckerInboxRepository) { | ||
|
||
suspend operator fun invoke(auditId: Int): Flow<Resource<GenericResponse>> = flow { | ||
try { | ||
emit(Resource.Loading()) | ||
val response = repository.approveCheckerEntry(auditId) | ||
emit(Resource.Success(response)) | ||
} catch (exception: Exception) { | ||
emit(Resource.Error(exception.message.toString())) | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
core/domain/src/main/java/com/mifos/core/domain/use_cases/DeleteCheckerUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.mifos.core.domain.use_cases | ||
|
||
import com.mifos.core.common.utils.Resource | ||
import com.mifos.core.data.repository.CheckerInboxRepository | ||
import com.mifos.core.network.GenericResponse | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.flow | ||
import javax.inject.Inject | ||
|
||
class DeleteCheckerUseCase @Inject constructor(private val repository: CheckerInboxRepository) { | ||
|
||
operator fun invoke(auditId: Int): Flow<Resource<GenericResponse>> = flow { | ||
try { | ||
emit(Resource.Loading()) | ||
val response = repository.deleteCheckerEntry(auditId) | ||
emit(Resource.Success(response)) | ||
} catch (exception: Exception) { | ||
emit(Resource.Error(exception.message.toString())) | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.