package de.assecutor.votianlt.pages.view;

import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import org.springframework.core.io.ClassPathResource;
import com.vaadin.flow.router.PageTitle;
import com.vaadin.flow.router.Route;
import jakarta.annotation.security.PermitAll;

@PageTitle("Impressum")
@Route(value = "impressum", layout = de.assecutor.votianlt.pages.base.ui.view.MainLayout.class)
@PermitAll
public class ImprintView extends VerticalLayout {
    public ImprintView() {
        setSizeFull();
        setPadding(true);
        setSpacing(true);
        setAlignItems(Alignment.CENTER);

        try {
            // Load HTML content from resources
            ClassPathResource resource = new ClassPathResource("html/imprint.html");
            String htmlContent = new String(resource.getInputStream().readAllBytes());

            // Create a Div to hold the HTML content
            Div imprintDiv = new Div();
            imprintDiv.getElement().setProperty("innerHTML", htmlContent);

            add(imprintDiv);

        } catch (Exception e) {
            // Fallback content in case of error
            Div errorDiv = new Div();
            errorDiv.setText("Fehler beim Laden des Impressums: " + e.getMessage());
            add(errorDiv);
        }
    }
}
