package com.example.wabi.view.screens.signIn.states

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.common_elements.button.ButtonBack
import com.example.wabi.view.common_elements.button.MainButton
import com.example.wabi.view.common_elements.text.error.ErrorList
import com.example.wabi.view.common_elements.text.error.ErrorPrint
import com.example.wabi.view.common_elements.textfields.MainTextField
import com.example.wabi.view.screens.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))
    }
    Text(
        text = "Восстановите\nпароль",
        style = WabiTheme.fonts.headerFont,
        maxLines = 2,
        minLines = 2,
        color = WabiTheme.colors.mainColor
    )
    Text(
        text = "Для восстановления\nпароля введите\nсвою почту",
        style = WabiTheme.fonts.mainFont,
        color = WabiTheme.colors.mainColor
    )
    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 = "Отправить код",
        modifierButton = Modifier
            .padding(30.dp, 0.dp)
            .fillMaxWidth()
    )

}