export const getRouteItem = (match, routes) => {
  const matchParams = match.params || {};
  let routeItem = routes.find((v) => v.path === match.url);
  if (routeItem) {
    return routeItem;
  } else {
    const keys = Object.keys(matchParams);
    const tempPaths = routes.map((v) => v.path);
    tempPaths.forEach((path, index) => {
      let newPath = path;
      keys.forEach((key) => {
        if (path.includes(`:${key}`)) {
          newPath = path.replace(`:${key}`, matchParams[key]);
        }
      });
      tempPaths[index] = newPath;
    });
    const index = tempPaths.findIndex((v) => v === match.url);
    return routes[index];
  }
};
