import { Maybe } from '@/core';
import { ActivatedRoute } from '@angular/router';

export default (activatedRoute: ActivatedRoute) => {
  let currentRoute = activatedRoute as Maybe<ActivatedRoute>;
  let allParams: Record<string, string> = {};

  while (currentRoute) {
    allParams = { ...allParams, ...currentRoute.snapshot.params };

    if (currentRoute.parent) {
      currentRoute = currentRoute.parent;
    } else {
      currentRoute = null;
    }
  }

  return allParams;
};
