import { Component, OnInit } from "@angular/core";
import {
    TranslateModule,
    TranslatePipe,
    TranslateService,
} from "@ngx-translate/core";

import { MatSelectModule } from "@angular/material/select";
import { MatOptionModule } from "@angular/material/core";
import { MatCardModule } from "@angular/material/card";
import { MatTabsModule } from "@angular/material/tabs";

import { LoginUserComponent } from "../login-user/login-user.component";
import { CreateUserComponent } from "../create-user/create-user.component";
import { ConfigurationHelper } from "../../services/configuration-helper";

@Component({
    selector: "app-login",
    templateUrl: "./login.component.html",
    styleUrls: ["./login.component.css"],
    imports: [
        TranslateModule,
        MatSelectModule,
        MatOptionModule,
        MatCardModule,
        MatTabsModule,
        LoginUserComponent,
        CreateUserComponent,
        TranslateModule,
    ],
})
export class LoginComponent implements OnInit {
    public selectedLanguageFlag: string;
    public version: string;

    constructor(private translate: TranslateService) {
        this.selectedLanguageFlag = "en";

        ConfigurationHelper.settings.subscribe((settings) => {
            if (settings != null) {
                this.version = settings.version;
            }
        });
    }

    ngOnInit() {}

    public switchLang(event: any) {
        this.translate.use(event.value);
        this.selectedLanguageFlag = event.value;
    }
}
