forked from openMF/android-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into loan_charges_dialog
- Loading branch information
Showing
55 changed files
with
3,362 additions
and
2,134 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
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
29 changes: 29 additions & 0 deletions
29
core/data/src/main/java/com/mifos/core/data/repository/PinPointClientRepository.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,29 @@ | ||
package com.mifos.core.data.repository | ||
|
||
import com.mifos.core.network.GenericResponse | ||
import com.mifos.core.objects.client.ClientAddressRequest | ||
import com.mifos.core.objects.client.ClientAddressResponse | ||
|
||
/** | ||
* Created by Aditya Gupta on 08/08/23. | ||
*/ | ||
interface PinPointClientRepository { | ||
|
||
suspend fun getClientPinpointLocations(clientId: Int): List<ClientAddressResponse> | ||
|
||
suspend fun addClientPinpointLocation( | ||
clientId: Int, | ||
address: ClientAddressRequest | ||
): GenericResponse | ||
|
||
suspend fun deleteClientAddressPinpointLocation( | ||
apptableId: Int, | ||
datatableId: Int | ||
): GenericResponse | ||
|
||
suspend fun updateClientPinpointLocation( | ||
apptableId: Int, | ||
datatableId: Int, | ||
address: ClientAddressRequest | ||
): GenericResponse | ||
} |
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
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
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
46 changes: 46 additions & 0 deletions
46
core/designsystem/src/main/java/com/mifos/core/designsystem/component/MifosEmptyContent.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,46 @@ | ||
package com.mifos.core.designsystem.component | ||
|
||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.filled.Error | ||
import androidx.compose.material3.Button | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.vector.ImageVector | ||
import androidx.compose.ui.res.vectorResource | ||
import androidx.compose.ui.unit.dp | ||
|
||
|
||
@Composable | ||
fun MifosErrorContent( | ||
message: String, | ||
isRefreshEnabled: Boolean = false, | ||
imageVector: ImageVector? = null, | ||
onRefresh: () -> Unit = {}, | ||
refreshButtonText: String = "" | ||
) { | ||
Column( | ||
modifier = Modifier.fillMaxSize(), | ||
horizontalAlignment = Alignment.CenterHorizontally, | ||
verticalArrangement = Arrangement.Center | ||
) { | ||
Icon( | ||
imageVector = imageVector ?: Icons.Default.Error, | ||
contentDescription = null, | ||
modifier = Modifier.size(48.dp) | ||
) | ||
if (isRefreshEnabled) { | ||
Text(text = message, modifier = Modifier.padding(vertical = 16.dp)) | ||
Button(onClick = onRefresh) { | ||
Text(text = refreshButtonText) | ||
} | ||
} | ||
} | ||
} |
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
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
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
26 changes: 26 additions & 0 deletions
26
.../domain/src/main/java/com/mifos/core/domain/use_cases/AddClientPinpointLocationUseCase.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,26 @@ | ||
package com.mifos.core.domain.use_cases | ||
|
||
import com.mifos.core.common.utils.Resource | ||
import com.mifos.core.data.repository.PinPointClientRepository | ||
import com.mifos.core.network.GenericResponse | ||
import com.mifos.core.objects.client.ClientAddressRequest | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.flow | ||
import javax.inject.Inject | ||
|
||
class AddClientPinpointLocationUseCase @Inject constructor(private val pinPointClientRepository: PinPointClientRepository) { | ||
|
||
suspend operator fun invoke( | ||
clientId: Int, | ||
address: ClientAddressRequest | ||
): Flow<Resource<GenericResponse>> = flow { | ||
try { | ||
emit(Resource.Loading()) | ||
val response = pinPointClientRepository.addClientPinpointLocation(clientId, address) | ||
emit(Resource.Success(response)) | ||
|
||
} catch (exception: Exception) { | ||
emit(Resource.Error(exception.message.toString())) | ||
} | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
core/domain/src/main/java/com/mifos/core/domain/use_cases/CreateGroupLoansAccountUseCase.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,42 @@ | ||
package com.mifos.core.domain.use_cases | ||
|
||
import com.mifos.core.common.utils.Resource | ||
import com.mifos.core.data.GroupLoanPayload | ||
import com.mifos.core.data.repository.GroupLoanAccountRepository | ||
import com.mifos.core.objects.accounts.loan.Loans | ||
import kotlinx.coroutines.channels.awaitClose | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.callbackFlow | ||
import rx.Subscriber | ||
import rx.android.schedulers.AndroidSchedulers | ||
import rx.schedulers.Schedulers | ||
import javax.inject.Inject | ||
|
||
class CreateGroupLoansAccountUseCase @Inject constructor(private val repository: GroupLoanAccountRepository) { | ||
|
||
suspend operator fun invoke(loansPayload: GroupLoanPayload): Flow<Resource<Loans>> = | ||
callbackFlow { | ||
try { | ||
trySend(Resource.Loading()) | ||
repository.createGroupLoansAccount(loansPayload) | ||
.observeOn(AndroidSchedulers.mainThread()) | ||
.subscribeOn(Schedulers.io()) | ||
.subscribe(object : Subscriber<Loans>() { | ||
override fun onCompleted() {} | ||
|
||
override fun onError(exception: Throwable) { | ||
trySend(Resource.Error(exception.message.toString())) | ||
} | ||
|
||
override fun onNext(response: Loans) { | ||
trySend(Resource.Success(response)) | ||
} | ||
}) | ||
awaitClose { channel.close() } | ||
} catch (exception: Exception) { | ||
trySend(Resource.Error(exception.message.toString())) | ||
} | ||
|
||
|
||
} | ||
} |
Oops, something went wrong.