package de.ivu.elect.presentation;

import javax.enterprise.inject.Specializes;
import javax.inject.Inject;

import de.ivu.elect.business.security.control.ElectCommonPrincipal;
import de.ivu.elect.jee.faces.Messages;
import de.ivu.elect.jee.faces.UserLocale;

@Specializes
public class NlWasAppFooter extends AppFooter {
  private static final long serialVersionUID = 1L;

  @Inject
  private transient ElectCommonPrincipal electCommonPrincipal;

  @Inject
  private transient NlSystemProperties nlSystemProperties;

  @Inject
  private transient Messages messages;

  @Inject
  private transient NlWasSystemProperties nlWasSystemProperties;

  @Inject
  private transient UserLocale userLocale;

  @Override
  public String getAdditionalUserInfo() {
    var electionLevel = messages.lokalisiere(nlSystemProperties.getDefaultElectionLevel(electCommonPrincipal.getMandant()));
    var defaultWahldatum = nlSystemProperties.getDefaultWahldatum(electCommonPrincipal.getMandant());
    var defaultWahlart = nlWasSystemProperties.getDefaultWahlart((electCommonPrincipal.getMandant()));
    var datum = defaultWahldatum.map(d -> userLocale.formatDate(d)).orElse("-");
    var category = defaultWahlart.map(Enum::name).orElse("-");
    return category + " / " + datum + " / " + electionLevel;
  }

}
