import { Component, OnInit } from '@angular/core';
import { CurrenciesComponent } from '../tabs/currencies/currencies.component';
import { SignUpFormComponent } from '../tabs/sign-up/sign-up-form.component';
import { AuthenticationComponent } from '../tabs/authentication/authentication.component';
import { TermsOfServiceComponent } from '../tabs/terms-of-service/terms-of-service.component';
import { LicenseComponent } from '../tabs/license/license.component';
import { IObjectController } from '@objects-view/interfaces/object-controller';
import { StaticObjectController } from '@objects-view/static-object-controller';
import { AdvancedSettingsComponent } from '../tabs/advanced-settings/advanced-settings.component';
import { FormattingSettingsComponent } from '../tabs/formatting-settings/formatting-settings.component';
import { SingleSignOnComponent } from '../tabs/single-sign-on/single-sign-on.component';
import { AuthService } from '@shared/auth/auth.service';
import { ReferralSettingsComponent } from '../tabs/referral-settings/referral-settings.component';

@Component({
  selector: 'app-settings-general',
  templateUrl: './settings-general.component.html',
  styleUrls: ['./settings-general.component.scss']
})

export class SettingsGeneralComponent implements OnInit {
  public objectController: IObjectController;

  constructor(
    private auth: AuthService
  ) {
    const tabs = [];
    tabs.push(
      {
        tabName: $localize`Currencies`,
        tabIdentifier: 'currencies',
        component: CurrenciesComponent,
      });
    tabs.push({
      tabName: $localize`Sign up`,
      tabIdentifier: 'sign-up',
      component: SignUpFormComponent,
    });

    if (this.auth.userData.user.is_superuser) {
      tabs.push({
        tabName: $localize`Single sign-on`,
        tabIdentifier: 'single-sign-on',
        component: SingleSignOnComponent,
        featureName: 'settings.general.single-sign-on',
      });
    }
    tabs.push({
      tabName: $localize`Authentication`,
      tabIdentifier: 'authentication',
      component: AuthenticationComponent,
    });
    tabs.push({
      tabName: $localize`Terms of service`,
      tabIdentifier: 'terms-of-service',
      component: TermsOfServiceComponent,
    });
    tabs.push({
      tabName: $localize`License`,
      tabIdentifier: 'license',
      component: LicenseComponent,
    });
    tabs.push({
      tabName: $localize`Formatting`,
      tabIdentifier: 'formatting',
      component: FormattingSettingsComponent,
    });
    tabs.push({
      tabName: $localize`Referral`,
      tabIdentifier: 'referral',
      component: ReferralSettingsComponent,
    });
    tabs.push({
      tabName: $localize`Advanced settings`,
      tabIdentifier: 'advanced-settings',
      component: AdvancedSettingsComponent,
    });

    this.objectController = new StaticObjectController({
      header: {
        title: {
          text: $localize`General settings`,
        }
      },
      tabs
    });

  }

  ngOnInit() {
  }
}
