import { useState } from 'react'; import { Link } from 'react-router'; import RouteErrorState from '../../../components/ui/error/RouteErrorState'; import FeaturedBreweryCard from '../components/overview/FeaturedBreweryCard'; import NearbyBreweriesSection from '../components/overview/nearby/NearbyBreweriesSection'; import RecentBreweries from '../components/overview/RecentBreweries'; import { getBreweries } from '../breweries.server'; import type { Route } from './+types/breweries'; // No count endpoint exists yet - see BREWERY_HANDOFF.md. const FILLER_TOTAL_BREWERY_COUNT = 128; export const meta = ({}: Route.MetaArgs) => { return [{ title: 'Breweries | The Biergarten App' }]; }; export const loader = async () => { // "Featured" is just the most recently posted brewery for now - see BREWERY_HANDOFF.md. const [featured, ...recent] = await getBreweries(4, 0); return { featured: featured ?? null, recent }; }; const Breweries = ({ loaderData }: Route.ComponentProps) => { const { featured, recent } = loaderData; const [selectedId, setSelectedId] = useState(null); const featuredPin = featured?.location?.coordinates ? { id: featured.breweryPostId, name: featured.breweryName, latitude: featured.location.coordinates.latitude, longitude: featured.location.coordinates.longitude, } : null; const fallbackCenter = featured?.location?.coordinates ? { latitude: featured.location.coordinates.latitude, longitude: featured.location.coordinates.longitude, label: featured.location.cityName, } : null; return (

Breweries

Discover our partner breweries — start with this week's feature, then see what's pouring near you.

{featured && (

Featured brewery

This week
{ setSelectedId(featured.breweryPostId); document .getElementById('breweries-near-you') ?.scrollIntoView({ behavior: 'smooth' }); }} />
)}

Looking for something specific?

All {FILLER_TOTAL_BREWERY_COUNT} partner breweries, filterable by country, region, and beer style.

Browse the full directory
); }; export default Breweries; export const ErrorBoundary = ({ error }: Route.ErrorBoundaryProps) => ( );