feat: optimize scan flow with WebP compression and fix admin metrics visibility

This commit is contained in:
2025-12-22 10:15:29 +01:00
parent f0588418c8
commit 5e35710b67
19 changed files with 477 additions and 332 deletions

View File

@@ -12,7 +12,7 @@ import LanguageSwitcher from "@/components/LanguageSwitcher";
import OfflineIndicator from "@/components/OfflineIndicator";
import { useI18n } from "@/i18n/I18nContext";
import { useSession } from "@/context/SessionContext";
import { Sparkles, X } from "lucide-react";
import { Sparkles, X, Loader2 } from "lucide-react";
import { BottomNavigation } from '@/components/BottomNavigation';
import ScanAndTasteFlow from '@/components/ScanAndTasteFlow';
@@ -25,10 +25,15 @@ export default function Home() {
const { t } = useI18n();
const { activeSession } = useSession();
const [isFlowOpen, setIsFlowOpen] = useState(false);
const [capturedImage, setCapturedImage] = useState<string | null>(null);
const [capturedFile, setCapturedFile] = useState<File | null>(null);
const [hasMounted, setHasMounted] = useState(false);
const handleImageSelected = (base64: string) => {
setCapturedImage(base64);
useEffect(() => {
setHasMounted(true);
}, []);
const handleImageSelected = (file: File) => {
setCapturedFile(file);
setIsFlowOpen(true);
};
@@ -149,6 +154,14 @@ export default function Home() {
await supabase.auth.signOut();
};
if (!hasMounted) {
return (
<main className="flex min-h-screen flex-col items-center justify-center bg-zinc-950">
<Loader2 className="animate-spin text-orange-600" size={40} />
</main>
);
}
if (!user) {
return (
<main className="flex min-h-screen flex-col items-center justify-center p-6 bg-zinc-950">
@@ -257,7 +270,7 @@ export default function Home() {
<ScanAndTasteFlow
isOpen={isFlowOpen}
onClose={() => setIsFlowOpen(false)}
base64Image={capturedImage}
imageFile={capturedFile}
/>
</main>
);