import { authErrorTypes } from '@context-providers/auth-context-provider'
import { AuthErrorPage } from '@pages/error/auth-error.page'
import { createFileRoute } from '@tanstack/react-router'

import { z } from 'zod'

const authErrorSearchSchema = z.object({
  type: z.enum(authErrorTypes).optional(),
})

export const Route = createFileRoute('/auth-error')({
  validateSearch: authErrorSearchSchema,
  component: RouteComponent,
})

function RouteComponent() {
  const { type } = Route.useSearch()
  return <AuthErrorPage errorType={type} />
}
