import { inject } from '@angular/core';
import { ActivatedRouteSnapshot, ResolveFn } from '@angular/router';
import { take } from 'rxjs/operators';

import { Qcm } from '@models';
import { QcmService } from '@services';

export const qcmResolver: ResolveFn<Qcm> = (
    route: ActivatedRouteSnapshot
) => {
    return inject(QcmService).get(route.params['type']).pipe(take(1));
};