Bundle pages stay styled and functional when the app embed is off (e.g. on a draft theme). Listing screenshots captured from the dev store and rendered at 1600x900. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
17 lines
1.0 KiB
TypeScript
17 lines
1.0 KiB
TypeScript
// /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 } });
|
|
};
|