import { IconCircleCheck, IconMapPin, IconSearch } from "@tabler/icons-react"; import type { NearMeStatus } from "@/hooks/use-near-me"; import { useI18n } from "@/lib/i18n"; type HeroSectionProps = { query: string; onQueryChange: (query: string) => void; nearMeStatus: NearMeStatus; onRequestLocation: () => void; }; /** ข้อความสถานะของปุ่ม "ใกล้ฉัน" — แสดงเฉพาะตอนกำลังหา/ผิดพลาด/พร้อมใช้ */ function statusMessage(status: NearMeStatus, messages: ReturnType["messages"]) { switch (status) { case "locating": return messages.search.locating; case "denied": return messages.search.denied; case "unsupported": return messages.search.unsupported; case "error": return messages.search.error; case "ready": return messages.search.sortedByDistance; default: return null; } } /** ฮีโร่หน้าแรก: หัวข้อ + ช่องค้นหา (ค้นทันทีขณะพิมพ์) + ปุ่มหาตำแหน่ง */ export function HeroSection({ query, onQueryChange, nearMeStatus, onRequestLocation, }: HeroSectionProps) { const { messages } = useI18n(); const status = statusMessage(nearMeStatus, messages); const isReady = nearMeStatus === "ready"; return (

{messages.hero.titlePrefix} {messages.hero.titleHighlight} {messages.hero.titleSuffix}

{messages.hero.subtitle}

onQueryChange(event.target.value)} placeholder={messages.search.placeholder} aria-label={messages.search.placeholder} className="min-w-0 flex-1 bg-transparent text-sm text-white outline-none placeholder:text-[#454545]" />
{status ? (

{status}

) : null}
); }