package com.example.wabi.view.screeens.signIn.items

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.example.wabi.ui.theme.WabiTheme
import com.example.wabi.view.components.buttons.ButtonBack
import com.example.wabi.view.components.buttons.MainButton
import com.example.wabi.view.components.textFields.MainTextField
import com.example.wabi.view.components.texts.Error.ErrorList
import com.example.wabi.view.components.texts.Error.ErrorPrint
import com.example.wabi.view.components.texts.HeaderText
import com.example.wabi.view.components.texts.MainText
import com.example.wabi.view.screeens.signIn.SignInViewModel

@Composable
fun EmailForReset(email: String, vm: SignInViewModel, visible: MutableState<Boolean>) {
    var correctEmail = remember { mutableStateOf(false) }
    val currentEmail = remember { mutableStateOf(email) }
    Row(
        modifier = Modifier.fillMaxWidth()
    ) {
        ButtonBack(onClick = {
            visible.value = true
        }, modifier = Modifier.padding(10.dp))
    }
    HeaderText(text = "Восстановите\nпароль")

    MainText(
        text = "Для восстановления\n" + "пароля введите\n" + "свою почту"
    )

    ErrorPrint(text = if (correctEmail.value) ErrorList.emailNotExists else "")

    Column() {
        MainTextField(
            value = currentEmail.value,
            input = { currentEmail.value = it },
            placeholder = "Почта",
            lable = "Введите почту:",
            trailingText = ""
        )
    }

    MainButton(
        onClick = {},
        enabled = vm.validateEmail(currentEmail.value),
        textContent = "Отправить код",
        modifier = Modifier.padding(30.dp, 0.dp)
    )

}