export default defineNuxtRouteMiddleware(async (to, from) => {
  // Check if user is authenticated
  const { data: validateUser } = await useFetch("/api/auth/validate", {
    method: "GET",
  });

  // If user is authenticated, redirect to DMS
  if (validateUser.value.statusCode === 200) {
    return navigateTo("/dms");
  }
  
  // If user is not authenticated, redirect to login
  return navigateTo("/login");
});