Skip to content

Commit

Permalink
103 chaning support phone number (#104)
Browse files Browse the repository at this point in the history
* added the right support number

* Update LoginViewModel.kt

* update

* Update LoginScreen.kt

* Update LoginScreen.kt

* Update LoginScreen.kt
  • Loading branch information
BuchiNy authored Aug 22, 2024
1 parent 31e60ec commit 22180b3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ fun LoginScreen(loginViewModel: LoginViewModel) {
val password by loginViewModel.password.observeAsState("")
val loginErrorState by loginViewModel.loginErrorState.observeAsState(null)
val showProgressBar by loginViewModel.showProgressBar.observeAsState(false)
val applicationConfiguration by loginViewModel.applicationConfiguration.observeAsState()
val context = LocalContext.current
val phoneNumber = applicationConfiguration?.supportPhoneNumber

LoginPage(
username = username,
Expand All @@ -109,6 +111,7 @@ fun LoginScreen(loginViewModel: LoginViewModel) {
onLoginButtonClicked = { loginViewModel.login(context = context) },
loginErrorState = loginErrorState,
showProgressBar = showProgressBar,
phoneNumber = phoneNumber,
)
}

Expand All @@ -123,6 +126,7 @@ fun LoginPage(
modifier: Modifier = Modifier,
loginErrorState: LoginErrorState? = null,
showProgressBar: Boolean = false,
phoneNumber: String? = null,
) {
var showPassword by remember { mutableStateOf(false) }
val backgroundColor = Color.White
Expand All @@ -146,6 +150,7 @@ fun LoginPage(
ForgotPasswordDialog(
forgotPassword = forgotPassword,
onDismissDialog = { showForgotPasswordDialog = false },
phoneNumber = phoneNumber,
)
}
Column(
Expand Down Expand Up @@ -347,6 +352,7 @@ fun LoginPage(
fun ForgotPasswordDialog(
forgotPassword: () -> Unit,
onDismissDialog: () -> Unit,
phoneNumber: String?,
modifier: Modifier = Modifier,
) {
AlertDialog(
Expand All @@ -359,7 +365,9 @@ fun ForgotPasswordDialog(
)
},
text = {
Text(text = stringResource(R.string.call_supervisor, "012-3456-789"), fontSize = 16.sp)
if (phoneNumber != null) {
Text(text = stringResource(R.string.call_supervisor, phoneNumber), fontSize = 16.sp)
}
},
buttons = {
Row(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import org.jetbrains.annotations.TestOnly
import org.smartregister.fhircore.engine.auth.AccountAuthenticator
import org.smartregister.fhircore.engine.configuration.ConfigurationRegistry
import org.smartregister.fhircore.engine.configuration.app.AppConfigService
import org.smartregister.fhircore.engine.configuration.app.ApplicationConfiguration
import org.smartregister.fhircore.engine.data.local.DefaultRepository
import org.smartregister.fhircore.engine.data.remote.fhir.resource.FhirResourceDataSource
import org.smartregister.fhircore.engine.data.remote.fhir.resource.FhirResourceService
Expand Down Expand Up @@ -106,6 +107,14 @@ constructor(
val loadingConfig: LiveData<Boolean>
get() = _loadingConfig

private val _applicationConfiguration = MutableLiveData<ApplicationConfiguration>()
val applicationConfiguration: LiveData<ApplicationConfiguration>
get() = _applicationConfiguration

init {
_applicationConfiguration.value = configurationRegistry.getAppConfigs()
}

private suspend fun fetchAccessToken(
username: String,
password: CharArray,
Expand Down Expand Up @@ -265,8 +274,9 @@ constructor(
}

fun forgotPassword() {
// TODO load supervisor contact e.g.
_launchDialPad.value = "tel:0123456789"
applicationConfiguration.value?.let { config ->
_launchDialPad.value = "tel:${config.supportPhoneNumber}"
}
}

@TestOnly
Expand Down

0 comments on commit 22180b3

Please sign in to comment.