export default defineNuxtRouteMiddleware((to, from) => {
  if (to.path != "/car/search") return;

  const dayjs = useDayjs();

  const startDate = to.query.startDate;
  const startPlace = to.query.startPlace;
  const days = to.query.days;

  if (startDate && startPlace && days) {
    return;
  }
  return navigateTo({
    path: "/car/search",
    query: {
      startDate: startDate || dayjs().format("YYYY-MM-DD"),
      startPlace: startPlace || 99,
      days: days || 1,
    },
  });
});
