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>
41 lines
1.3 KiB
TypeScript
41 lines
1.3 KiB
TypeScript
import type { HeadersFunction, LoaderFunctionArgs } from "react-router";
|
|
import { Outlet, useLoaderData, useRouteError } from "react-router";
|
|
import { boundary } from "@shopify/shopify-app-react-router/server";
|
|
import { AppProvider } from "@shopify/shopify-app-react-router/react";
|
|
|
|
import { authenticate } from "../shopify.server";
|
|
|
|
export const loader = async ({ request }: LoaderFunctionArgs) => {
|
|
await authenticate.admin(request);
|
|
|
|
// eslint-disable-next-line no-undef
|
|
return { apiKey: process.env.SHOPIFY_API_KEY || "" };
|
|
};
|
|
|
|
export default function App() {
|
|
const { apiKey } = useLoaderData<typeof loader>();
|
|
|
|
return (
|
|
<AppProvider apiKey={apiKey}>
|
|
<s-app-nav>
|
|
<s-link href="/app">Home</s-link>
|
|
<s-link href="/app/offers">Offers</s-link>
|
|
<s-link href="/app/templates">Festival templates</s-link>
|
|
<s-link href="/app/analytics">Analytics</s-link>
|
|
<s-link href="/app/settings">Settings</s-link>
|
|
<s-link href="/app/plans">Plans</s-link>
|
|
</s-app-nav>
|
|
<Outlet />
|
|
</AppProvider>
|
|
);
|
|
}
|
|
|
|
// Shopify needs React Router to catch some thrown responses, so that their headers are included in the response.
|
|
export function ErrorBoundary() {
|
|
return boundary.error(useRouteError());
|
|
}
|
|
|
|
export const headers: HeadersFunction = (headersArgs) => {
|
|
return boundary.headers(headersArgs);
|
|
};
|