"use client"; /* eslint-disable @typescript-eslint/no-misused-promises */ import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { getBrowserDisplayName } from "@/lib/browser-utils"; import React from "react"; import { FaDownload, FaTimes } from "react-icons/fa"; import { LuDownload } from "react-icons/lu"; interface UpdateNotification { id: string; browser: string; current_version: string; new_version: string; affected_profiles: string[]; is_stable_update: boolean; timestamp: number; } interface UpdateNotificationProps { notification: UpdateNotification; onUpdate: (browser: string, newVersion: string) => Promise; onDismiss: (notificationId: string) => Promise; isUpdating?: boolean; } export function UpdateNotificationComponent({ notification, onUpdate, onDismiss, isUpdating = false, }: UpdateNotificationProps) { const browserDisplayName = getBrowserDisplayName(notification.browser); const profileText = notification.affected_profiles.length === 1 ? `profile "${notification.affected_profiles[0]}"` : `${notification.affected_profiles.length} profiles`; const handleUpdateClick = async () => { // Dismiss the notification immediately to close the modal await onDismiss(notification.id); // Then start the update process await onUpdate(notification.browser, notification.new_version); }; return (
{browserDisplayName} Update Available {notification.is_stable_update ? "Stable" : "Nightly"}
Update {profileText} from {notification.current_version} to{" "} {notification.new_version}
{notification.affected_profiles.length > 1 && (
Affected profiles: {notification.affected_profiles.join(", ")}
)}
); }