'use client'; import React, { useState } from 'react'; import { Camera, Zap } from 'lucide-react'; import { motion, AnimatePresence } from 'framer-motion'; import { useSession } from '@/context/SessionContext'; import BulkScanSheet from './BulkScanSheet'; interface FloatingScannerButtonProps { onImageSelected: (base64Image: string) => void; } export default function FloatingScannerButton({ onImageSelected }: FloatingScannerButtonProps) { const fileInputRef = React.useRef(null); const { activeSession } = useSession(); const [isBulkOpen, setIsBulkOpen] = useState(false); const [isExpanded, setIsExpanded] = useState(false); const handleFileChange = (e: React.ChangeEvent) => { const file = e.target.files?.[0]; if (!file) return; const reader = new FileReader(); reader.onloadend = () => { const base64String = reader.result as string; onImageSelected(base64String); }; reader.readAsDataURL(file); }; const handleMainClick = () => { if (activeSession) { setIsExpanded(!isExpanded); } else { fileInputRef.current?.click(); } }; return ( <>
{/* Expanded Options */} {isExpanded && activeSession && ( {/* Single Scan */} { setIsExpanded(false); fileInputRef.current?.click(); }} className="flex flex-col items-center gap-1.5 px-4 py-3 bg-zinc-900 border border-zinc-700 rounded-2xl shadow-xl" > Einzel {/* Bulk Scan */} { setIsExpanded(false); setIsBulkOpen(true); }} className="flex flex-col items-center gap-1.5 px-4 py-3 bg-orange-600 rounded-2xl shadow-xl shadow-orange-950/30" > Bulk )} {/* Main Button */} {/* Shine Animation */} {!isExpanded && ( )} {/* Active Session Indicator */} {activeSession && !isExpanded && (
)} {/* Pulse ring */} {!isExpanded && ( )}
{/* Bulk Scan Sheet */} {activeSession && ( setIsBulkOpen(false)} sessionId={activeSession.id} sessionName={activeSession.name} onSuccess={() => setIsBulkOpen(false)} /> )} ); }