Rust discount function (one automatic discount evaluating all offers in priority order, parity with the Odoo engine), React Router admin with Polaris, theme app extension and app proxy pages, webhooks incl. GDPR, managed-pricing limits, and a Docker Compose stack (Postgres + Caddy HTTPS) for a single VPS. 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 } 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(bundlesListLiquid(data.running, data.ctx, locale, base), { headers: { "Cache-Control": PROXY_CACHE } });
|
|
};
|