|
|
|
@ -8,8 +8,11 @@ import androidx.compose.runtime.mutableStateOf
|
|
|
|
|
import androidx.compose.runtime.remember
|
|
|
|
|
import androidx.compose.runtime.setValue
|
|
|
|
|
import arrow.core.Either
|
|
|
|
|
import com.iqball.app.api.service.AuthService
|
|
|
|
|
import com.iqball.app.api.service.AuthService.RegisterRequest
|
|
|
|
|
import com.iqball.app.api.service.IQBallService
|
|
|
|
|
import com.iqball.app.session.Authentication
|
|
|
|
|
import com.iqball.app.session.MutableSession
|
|
|
|
|
import kotlinx.coroutines.Dispatchers
|
|
|
|
|
import kotlinx.coroutines.coroutineScope
|
|
|
|
|
import kotlinx.coroutines.delay
|
|
|
|
@ -22,26 +25,30 @@ fun RegisterPage(service: IQBallService) {
|
|
|
|
|
|
|
|
|
|
var text by remember { mutableStateOf("No message !") }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
runBlocking {
|
|
|
|
|
val result = service.register(RegisterRequest("abcdefg", "a@m.com", "123456"))
|
|
|
|
|
val result = service.login(AuthService.LoginRequest("maxime@mail.com", "123456"))
|
|
|
|
|
|
|
|
|
|
when (result) {
|
|
|
|
|
is Either.Left -> println("Error : " + result.value)
|
|
|
|
|
is Either.Right -> println("Success : " + result.value)
|
|
|
|
|
is Either.Left -> {
|
|
|
|
|
println("Error : " + result.value)
|
|
|
|
|
text = result.toString()
|
|
|
|
|
}
|
|
|
|
|
is Either.Right -> {
|
|
|
|
|
val token = result.value.token
|
|
|
|
|
val userDataResponse = service.getUserData(token)
|
|
|
|
|
|
|
|
|
|
when (userDataResponse) {
|
|
|
|
|
is Either.Left -> println("Error User Data : " + userDataResponse.value)
|
|
|
|
|
is Either.Right -> println("Success User Data : " + userDataResponse.value)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
text = userDataResponse.toString()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
println(result)
|
|
|
|
|
text = result.toString()
|
|
|
|
|
Log.i("%", result.toString())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Text(text = text)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
suspend fun updateTextIn5Sec(setText: (String) -> Unit) = coroutineScope {
|
|
|
|
|
launch(Dispatchers.IO) {
|
|
|
|
|
delay(5000)
|
|
|
|
|
setText("test")
|
|
|
|
|
}
|
|
|
|
|
}
|