'use client'
import { useEffect, useState } from 'react'
import { motion, AnimatePresence } from 'framer-motion'
import { RefreshCw, X, Download } from 'lucide-react'
import { Button } from '@/components/ui/button'
import { Card, CardContent } from '@/components/ui/card'
import { Badge } from '@/components/ui/badge'
import { registerUpdateHandler, forceReload } from '@/lib/cache-manager'
interface UpdateNotificationProps {
autoShow?: boolean
position?: 'top' | 'bottom'
}
export default function UpdateNotification({
autoShow = true,
position = 'bottom'
}: UpdateNotificationProps) {
const [showUpdate, setShowUpdate] = useState(false)
const [isUpdating, setIsUpdating] = useState(false)
useEffect(() => {
if (autoShow) {
// Register for update notifications
registerUpdateHandler(() => {
setShowUpdate(true)
})
}
}, [autoShow])
const handleUpdate = async () => {
setIsUpdating(true)
try {
// Force reload with cache clear
forceReload()
} catch (error) {
console.error('Update failed:', error)
setIsUpdating(false)
}
}
const handleDismiss = () => {
setShowUpdate(false)
}
const positionStyles = position === 'top'
? 'top-4 left-4 right-4'
: 'bottom-4 left-4 right-4'
return (
A new version is available with improved features and bug fixes.
Refresh to get the latest updates.
Update Available!