Implements winofyfrontenddoc (1).md §3-4: unified guest-home/authenticated-home
screen (header with login chip vs cart badge, pill search bar, dismissible
location-reminder banner, category chips, store cards, interleaved seller
promo card, sticky bottom nav), plus the full post-OTP location-onboarding
sub-flow (geolocation permission -> error/retry -> manual neighborhood
search, unified idle/results/empty states per the doc's own recommendation).
Location state persists in a plain (non-httpOnly) cookie readable both
client- and server-side, since it drives SSR store queries (neighborhood
or lat/lng) as well as client interactions.
Moved cart/checkout/store/product/orders/addresses under a new (shop) route
group so the new home-shell header doesn't double up with the existing
simple nav header on inner pages.
Real bug caught via live staging data: Neighborhood.city is a nested
{uuid, name, slug} object, not a bare uuid string as typed -- broke both
the address form's city filter and the new neighborhood search. Fixed and
verified against real API responses, not just assumed from the guide.
14 lines
412 B
TypeScript
14 lines
412 B
TypeScript
import "server-only";
|
|
import { cookies } from "next/headers";
|
|
import { LOCATION_COOKIE_NAME, type LocationState } from "./types";
|
|
|
|
export async function getLocationServer(): Promise<LocationState | null> {
|
|
const store = await cookies();
|
|
const value = store.get(LOCATION_COOKIE_NAME)?.value;
|
|
if (!value) return null;
|
|
try {
|
|
return JSON.parse(value) as LocationState;
|
|
} catch {
|
|
return null;
|
|
}
|
|
}
|