Your IP : 216.73.216.1


Current Path : /proc/self/cwd/wp-content/plugins/leadin/scripts/constants/
Upload File :
Current File : //proc/self/cwd/wp-content/plugins/leadin/scripts/constants/urlsMap.ts

import { routes } from './leadinConfig';

const flatUrls = (
  key: string,
  route: any | string
): {
  [routeKey: string]: string;
} => {
  if (typeof route === 'string') {
    return {
      [key]: route,
    };
  }
  return Object.keys(route).reduce((agg: any, childKey: string) => {
    const childRoute = route[childKey];
    return {
      ...agg,
      ...flatUrls(key + childKey, childRoute),
    };
  }, {});
};

const urlsMap: {
  [key: string]: string;
} = Object.keys(routes).reduce(
  (agg, key) => ({
    ...agg,
    ...flatUrls(key, routes[key]),
  }),
  {}
);

export default urlsMap;