import { createFileRoute, redirect } from '@tanstack/react-router'
import { NO_INDEX_METADATA } from '@/lib/seo'
import { metadataToHead } from '@/lib/head'

export const Route = createFileRoute('/$lang/_main/jobs/result')({
  head: () => metadataToHead(NO_INDEX_METADATA),
  beforeLoad: ({ params, location }) => {
    if (location.pathname === `/${params.lang}/jobs/result/demo`) {
      return
    }

    throw redirect({
      to: '/$lang/jobs/apply',
      params: { lang: params.lang },
    })
  },
})
