package com.example.application.views.login;

import com.vaadin.flow.component.html.Image;
import com.vaadin.flow.component.login.LoginForm;
import com.vaadin.flow.component.login.LoginI18n;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.router.PageTitle;
import com.vaadin.flow.router.Route;
import com.vaadin.flow.server.auth.AnonymousAllowed;

@Route("login")
@PageTitle("Login")
@AnonymousAllowed
public class LoginView extends VerticalLayout {


    public LoginView() {
        addClassName("login-view");
        setSizeFull();
        setAlignItems(Alignment.CENTER);
        setJustifyContentMode(JustifyContentMode.CENTER);

        Image imgLogo = new Image("images/NVO_JUMAPA.png", "Logo JUMAPA");
        imgLogo.setWidth("300px");


        LoginI18n i18n = LoginI18n.createDefault();

        LoginI18n.Form i18nForm = i18n.getForm();
        i18nForm.setTitle("Bienvenidos");
        i18nForm.setUsername("Usuario");
        i18nForm.setPassword("Contraseña");
        i18n.setForm(i18nForm);


        var vLogin = new LoginForm();
        vLogin.setAction("login");
        vLogin.setForgotPasswordButtonVisible(false);

        vLogin.setI18n(i18n);
        add(imgLogo, vLogin);
    }


    /*@Override
    public void beforeEnter(BeforeEnterEvent beforeEnterEvent) {
        if (beforeEnterEvent.getLocation()
                .getQueryParameters()
                .getParameters()
                .containsKey("error")) {
                vLogin.setError(true);
                }
    }*/
}

