feat(footer, header, landing): enhance UI components and improve navigation
- Updated Footer component with new links and dynamic year display. - Refactored Header component to improve mobile navigation and theme toggling. - Enhanced DonationSection and Features components with improved layout and animations. - Updated HowItWorks and Impact sections for better user engagement and clarity. - Improved product page layout and error handling in API interactions. - General UI refinements across various components for a cohesive user experience.
This commit is contained in:
1 parent
b0f95704e1
commit
f98c648311
21 files changed
+3335
-12057
No files matched your search
@@ -0,0 +1,25 @@
|
||||
"use client";
|
||||
|
||||
import { useState, useEffect } from "react";
|
||||
import { detectSearchType, isValidBarcode } from "@/lib/openFoodFactsApi";
|
||||
|
||||
// Definimos o tipo de união para garantir segurança de índice
|
||||
export type SearchType = "auto" | "barcode" | "name";
|
||||
|
||||
export function useSearchLogic(query: string) {
|
||||
const [searchType, setSearchType] = useState<SearchType>("auto");
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (query.trim()) {
|
||||
const detected = detectSearchType(query) as SearchType;
|
||||
setSearchType(detected);
|
||||
} else {
|
||||
setSearchType("auto");
|
||||
}
|
||||
}, [query]);
|
||||
|
||||
const isValid = searchType === "barcode" ? isValidBarcode(query) : true;
|
||||
|
||||
return { searchType, isValid, loading, setLoading };
|
||||
}
|
||||
Reference in new issue
Block a user