import { Injectable } from '@angular/core'
import { Router, RouterStateSnapshot, ActivatedRouteSnapshot } from '@angular/router'
import { Observable } from 'rxjs'
import { map } from 'rxjs/operators'

import { AdminManageDataService, Category } from '../data.service'


@Injectable()
export class CategoryResolver  {
    constructor(
        private adminManageDataService: AdminManageDataService,
        private router: Router
    ) {}

    resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<Category[]> {
        return this.adminManageDataService.getCategories()
    }
}
