Commit ffe83289 authored by Vinicius Monteiro's avatar Vinicius Monteiro

cadastro grupo porta e editar funcionando corretamente agora

2 merge requests!34Resolve "Corringindo bugs após revisão",!32Draft: Resolve "Patch: Usuário"
......@@ -56,7 +56,7 @@ fun LoginScreen(navController: NavController) {
val autenticado by authViewModel.autenticado
var email by remember { mutableStateOf("dev@gmail.com") }
var senha by remember { mutableStateOf("123") }
var senha by remember { mutableStateOf("ABCD@abcd1234") }
var passwordVisibility by remember { mutableStateOf(false) }
Surface(
......
......@@ -266,10 +266,45 @@ fun CadastrarGrupoPorta(
color = Color.White
)
}
if(showBottomSheetPortas) {
when (portasState) {
is ApiState.Error -> {
// Exibir uma mensagem de erro ou uma tela de falha
Text("Erro ao carregar as portas.")
}
is ApiState.Created -> {}
is ApiState.Loading -> {
// Exibir uma tela de carregamento
LoadingScreen()
}
is ApiState.Success -> {
portasState.data?.let { responseData ->
ModalBottomSheetDados(
title = "Portas",
searchLabel = searchQueryPortas,
itemList = responseData.data,
selectedItems = selectedPortas.map { it.toString() },
onSelectItem = { selectedPortas += it },
onRemoveItem = { selectedPortas -= it },
onDismissRequest = { showBottomSheetPortas = false },
itemLabel = { it.descricao },
IdItem = {it._id},
itemDescription = { it.ambiente }
)
}
}
}
}
}
}
}
LaunchedEffect(Unit) {
portaViewModel.getAllPortas()
}
LaunchedEffect(postState) {
when (postState) {
is ApiState.Created -> {
......@@ -309,38 +344,5 @@ fun CadastrarGrupoPorta(
}
}
}
if(showBottomSheetPortas) {
when (portasState) {
is ApiState.Error -> {
// Exibir uma mensagem de erro ou uma tela de falha
Text("Erro ao carregar as portas.")
}
is ApiState.Created -> {}
is ApiState.Loading -> {
// Exibir uma tela de carregamento
LoadingScreen()
}
is ApiState.Success -> {
portasState.data?.let { responseData ->
ModalBottomSheetDados(
title = "Portas",
searchLabel = searchQueryPortas,
itemList = responseData.data,
selectedItems = selectedPortas.map { it.toString() },
onSelectItem = { selectedPortas += it },
onRemoveItem = { selectedPortas -= it },
onDismissRequest = { showBottomSheetPortas = false },
itemLabel = { it.descricao },
IdItem = {it._id},
itemDescription = { it.ambiente }
)
}
}
}
}
}
......@@ -231,10 +231,6 @@ fun EditarGrupoPorta(
Button(
onClick = {
println("Dado atualizado: ${nome}")
println("Dado atualizado: ${descricao}")
println("Dado atualizado: ${ativo}")
println("Dado atualizado: ${selectedPortas.toList()}")
val grupoEditaRequestBodyPatch = GrupoPortaRequestBodyPatch()
grupoEditaRequestBodyPatch.nome = nome
grupoEditaRequestBodyPatch.descricao = descricao
......@@ -258,6 +254,40 @@ fun EditarGrupoPorta(
color = Color.White
)
}
if(showBottomSheetPortas) {
when (portasState) {
is ApiState.Error -> {
// Exibir uma mensagem de erro ou uma tela de falha
Text("Erro ao carregar as portas.")
}
is ApiState.Created -> {}
is ApiState.Loading -> {
// Exibir uma tela de carregamento
LoadingScreen()
}
is ApiState.Success -> {
portasState.data?.let { responseData ->
responseData.data.forEach { porta ->
println("ID DA PORTA AQUI GRUPO: ${porta._id}")
}
ModalBottomSheetDados(
title = "Portas",
searchLabel = searchQueryPortas,
itemList = responseData.data,
selectedItems = selectedPortas.map { it.toString() },
onSelectItem = { selectedPortas += it },
onRemoveItem = { selectedPortas -= it },
onDismissRequest = { showBottomSheetPortas = false },
itemLabel = { it.descricao },
IdItem = {it._id},
itemDescription = { it.ambiente }
)
}
}
}
}
LaunchedEffect(grupoEditaState) {
when (grupoEditaState) {
is ApiState.Created -> {}
......@@ -304,7 +334,6 @@ fun EditarGrupoPorta(
is ApiState.Loading -> {}
is ApiState.Success -> {
grupoState.data?.let {
println("Dados que vieram: ${it.portas}")
nome = it.nome
descricao = it.descricao
ativo = it.ativo
......@@ -322,40 +351,5 @@ fun EditarGrupoPorta(
}
}
}
if(showBottomSheetPortas) {
when (portasState) {
is ApiState.Error -> {
// Exibir uma mensagem de erro ou uma tela de falha
Text("Erro ao carregar as portas.")
}
is ApiState.Created -> {}
is ApiState.Loading -> {
// Exibir uma tela de carregamento
LoadingScreen()
}
is ApiState.Success -> {
portasState.data?.let { responseData ->
responseData.data.forEach { porta ->
println("ID DA PORTA AQUI GRUPO: ${porta._id}")
}
ModalBottomSheetDados(
title = "Portas",
searchLabel = searchQueryPortas,
itemList = responseData.data,
selectedItems = selectedPortas.map { it.toString() },
onSelectItem = { selectedPortas += it },
onRemoveItem = { selectedPortas -= it },
onDismissRequest = { showBottomSheetPortas = false },
itemLabel = { it.descricao },
IdItem = {it._id},
itemDescription = { it.ambiente }
)
}
}
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment