import { Component, ViewChild, OnInit } from '@angular/core'
import { ActivatedRoute } from '@angular/router'

import { AdminListComponent } from './admin-list/admin-list.component'
import { AdminBasket, SurveyMeta } from '../openapi'

@Component({
    selector: 'gisaf-admin',
    templateUrl: './admin.component.html',
    styleUrls: ['./admin.component.css'],
})
export class AdminComponent implements OnInit {
    adminModelsMenuItems: Object[] = []
    @ViewChild(AdminListComponent, {static: true}) adminList: AdminListComponent
    baskets: AdminBasket[]
    surveyMeta: SurveyMeta

    constructor(
        private route: ActivatedRoute,
    ) {}

    ngOnInit() {
        this.route.data.subscribe(
            resp => {
                this.baskets = resp['item'][0]
                this.surveyMeta = resp['item'][1]
                this.adminModelsMenuItems = resp['item'][2]
            }
        )
    }
}
