refactor(storefront): replace supabase shim in storefront pages

The legacy lib/supabase.ts shim returns { data: null } for every query,
which silently broke the tuxedo and indian-river-direct storefronts:
they displayed 'No stops on the calendar just yet' regardless of the
real data in Postgres.

Added src/actions/storefront.ts as a new "use server" module with
typed actions that hit the shared pg pool directly:
  - getStorefrontData(slug) — brand + stops + products in one call
  - getStorefrontStopBySlug(slug) — single stop + its products
  - getStorefrontWholesaleSettings(slug) — public invoice/business info

Updated to use these actions instead of the shim:
  - src/app/tuxedo/page.tsx
  - src/app/tuxedo/stops/[slug]/page.tsx
  - src/app/tuxedo/contact/ContactClientPage.tsx
  - src/app/indian-river-direct/page.tsx
  - src/app/indian-river-direct/stops/[slug]/page.tsx

The shim file itself is still imported by other pages and API routes
that will be migrated in follow-up steps.
This commit is contained in:
Nora
2026-06-25 17:04:53 -06:00
parent 6452363989
commit 9f3dc9b68e
6 changed files with 219 additions and 62 deletions
+5 -17
View File
@@ -8,7 +8,7 @@ import StopSetEffect from "@/components/storefront/StopSetEffect";
import StorefrontHeader from "@/components/storefront/StorefrontHeader";
import StorefrontFooter from "@/components/storefront/StorefrontFooter";
import LayoutContainer from "@/components/layout/LayoutContainer";
import { supabase } from "@/lib/supabase";
import { getStorefrontStopBySlug } from "@/actions/storefront";
import { formatDate } from "@/lib/format-date";
type Product = {
@@ -52,26 +52,14 @@ export default function StopPage() {
useEffect(() => {
async function load() {
const { data: stopData } = await supabase
.from("stops")
.select("*")
.eq("slug", slug)
.eq("active", true)
.single() as unknown as { data: Stop | null };
const result = await getStorefrontStopBySlug(slug);
if (!result) return;
if (!stopData) return;
setStop(stopData);
setStop(result.stop as unknown as Stop);
const isIndian = slug.includes("indian");
setBrandSlug(isIndian ? "indian-river-direct" : "tuxedo");
setBrandAccent(isIndian ? "blue" : "green");
const { data: productsData } = await supabase
.from("products")
.select("*")
.eq("brand_id", stopData.brand_id)
.eq("active", true) as unknown as { data: Product[] | null };
setProducts(productsData ?? []);
setProducts(result.products as unknown as Product[]);
}
load();
}, [slug]);