'use client'
import Link from 'next/link'
import {
IconAlertCircle as AlertCircle,
IconClock as Clock,
IconRefresh as RefreshCw
} from '@tabler/icons-react'
import { Button } from '@/components/ui/button'
import {
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle
} from '@/components/ui/dialog'
interface ErrorModalProps {
open: boolean
onOpenChange: (open: boolean) => void
error: {
type: 'rate-limit' | 'auth' | 'forbidden' | 'general'
message: string
details?: string
}
onRetry?: () => void
onAuthClose?: () => void
}
export function ErrorModal({
open,
onOpenChange,
error,
onRetry,
onAuthClose
}: ErrorModalProps) {
const handleAuthClose = () => {
onOpenChange(false)
onAuthClose?.()
}
const getErrorIcon = () => {
switch (error.type) {
case 'rate-limit':
return
case 'auth':
case 'forbidden':
return
default:
return
}
}
const getErrorTitle = () => {
switch (error.type) {
case 'rate-limit':
return 'Rate Limit Exceeded'
case 'auth':
return 'Continue with Morphic'
case 'forbidden':
return 'Access Denied'
default:
return 'Error Occurred'
}
}
const getErrorDescription = () => {
switch (error.type) {
case 'rate-limit':
return (
error.message ||
'You have made too many requests. Please wait a moment before trying again.'
)
case 'auth':
return (
error.message ||
'To use Morphic, sign in to your account or create a new one.'
)
case 'forbidden':
return 'You do not have permission to access this resource.'
default:
return (
error.message || 'An unexpected error occurred. Please try again.'
)
}
}
const getErrorDetails = () => {
if (error.type === 'rate-limit') {
return error.details || 'The limit resets at midnight UTC.'
}
return error.details
}
return (
)
}