Skip to content

Commit

Permalink
MIFOSAC-249 Moved createNewClient & SyncClientsDialog to client Module (
Browse files Browse the repository at this point in the history
openMF#2185)

moved create new client to module

MIFOSAC-249 Moved createNewClient & SyncClientsDialog to client Module
  • Loading branch information
itsPronay authored Aug 14, 2024
1 parent 419b8ff commit de6f0bc
Show file tree
Hide file tree
Showing 21 changed files with 326 additions and 914 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.mifos.mifosxdroid.online.createnewclient
package com.mifos.core.data.repository

import com.mifos.core.objects.client.Client
import com.mifos.core.objects.client.ClientPayload
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.mifos.mifosxdroid.dialogfragments.syncclientsdialog
package com.mifos.core.data.repository

import com.mifos.core.objects.accounts.ClientAccounts
import com.mifos.core.objects.accounts.loan.LoanWithAssociations
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.mifos.mifosxdroid.online.createnewclient
package com.mifos.core.data.repository_imp

import com.mifos.core.data.repository.CreateNewClientRepository
import com.mifos.core.network.datamanager.DataManagerClient
import com.mifos.core.network.datamanager.DataManagerOffices
import com.mifos.core.network.datamanager.DataManagerStaff
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.mifos.mifosxdroid.dialogfragments.syncclientsdialog
package com.mifos.core.data.repository_imp

import com.mifos.core.data.repository.SyncClientsDialogRepository
import com.mifos.core.network.datamanager.DataManagerClient
import com.mifos.core.network.datamanager.DataManagerLoan
import com.mifos.core.network.datamanager.DataManagerSavings
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.mifos.core.domain.use_cases

import com.mifos.core.common.utils.Resource
import com.mifos.core.data.repository.CreateNewClientRepository
import com.mifos.core.objects.templates.clients.ClientsTemplate
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

/**
* Created by Pronay Sarker on 10/08/2024 (8:27 PM)
*/
class ClientTemplateUseCase @Inject constructor(private val repository: CreateNewClientRepository) {

suspend operator fun invoke(): Flow<Resource<ClientsTemplate>> =
callbackFlow {
try {
trySend(Resource.Loading())

repository.clientTemplate()
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
.subscribe(object : Subscriber<ClientsTemplate>() {
override fun onCompleted() {}

override fun onError(e: Throwable) {
trySend(Resource.Error(e.message.toString()))
}

override fun onNext(clientsTemplate: ClientsTemplate) {
trySend(Resource.Success(clientsTemplate))
}
})

awaitClose { channel.close() }
} catch (e: Exception) {
trySend(Resource.Error(e.message.toString()))
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.mifos.core.domain.use_cases

import com.mifos.core.common.utils.Resource
import com.mifos.core.data.repository.CreateNewClientRepository
import com.mifos.core.objects.organisation.Staff
import com.mifos.core.objects.templates.clients.ClientsTemplate
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

/**
* Created by Pronay Sarker on 10/08/2024 (8:43 PM)
*/
class GetStaffInOfficeForCreateNewClientUseCase @Inject constructor(private val repository: CreateNewClientRepository) {

suspend operator fun invoke(officeId: Int): Flow<Resource<List<Staff>>> =
callbackFlow {
try {
trySend(Resource.Loading())

repository.getStaffInOffice(officeId)
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
.subscribe(object : Subscriber<List<Staff>>() {
override fun onCompleted() {}

override fun onError(e: Throwable) {
trySend(Resource.Error(e.message.toString()))
}

override fun onNext(staffList: List<Staff>) {
trySend(Resource.Success(staffList))
}
})

awaitClose { channel.close() }
} catch (e: Exception) {
trySend(Resource.Error(e.message.toString()))
}
}
}
14 changes: 14 additions & 0 deletions feature/client/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,18 @@
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="28" />
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />

<application>
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="com.mifos.mifosxdroid.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/feature_client_path_provider" />
</provider>
</application>

</manifest>
Loading

0 comments on commit de6f0bc

Please sign in to comment.