// /apps/bundles (app proxy): grid of all running offers (F12). import type { LoaderFunctionArgs } from "react-router"; import { authenticate } from "../shopify.server"; import { PROXY_CACHE, runningOffersForShop } from "../lib/proxy.server"; import { bundlesListLiquid, proxyBase, selfContained } from "../lib/storefront.server"; export const loader = async ({ request }: LoaderFunctionArgs) => { const { liquid } = await authenticate.public.appProxy(request); const url = new URL(request.url); const shop = url.searchParams.get("shop") || ""; const base = proxyBase(url.searchParams.get("path_prefix")); const locale = request.headers.get("accept-language")?.split(",")[0]?.split("-")[0] || null; const data = await runningOffersForShop(shop, request.headers.get("x-shopify-country") || null); if (!data) return liquid(bundlesListLiquid([], { currency: "USD", timezone: "UTC", branding: false }, null, base)); return liquid(selfContained(bundlesListLiquid(data.running, data.ctx, locale, base)), { headers: { "Cache-Control": PROXY_CACHE } }); };