// Plans use Shopify managed pricing: Shopify hosts the plan page, trials, approval and proration. // The app layout loader keeps the stored plan in sync with the subscription. import type { HeadersFunction, LoaderFunctionArgs } from "react-router"; import { useLoaderData } from "react-router"; import { boundary } from "@shopify/shopify-app-react-router/server"; import { adminContext } from "../lib/admin.server"; import { pricingUrl } from "../lib/partner.server"; import { PLAN_COPY } from "../services/plans"; export const loader = async ({ request }: LoaderFunctionArgs) => { const { cfg, session } = await adminContext(request, { fresh: true }); return { plan: cfg.shop.plan, pricingUrl: pricingUrl(session.shop) }; }; export default function Plans() { const { plan, pricingUrl } = useLoaderData(); const current = PLAN_COPY.find((p) => p.id === plan) ?? PLAN_COPY[0]; return ( Change plan You're on the {current.name} plan. Paid plans include a 14-day free trial; development stores are free. {PLAN_COPY.map((p) => ( {p.name} {p.price} {p.points.map((x) => {x})} {plan === p.id ? Current plan : null} ))} ); } export const headers: HeadersFunction = (headersArgs) => boundary.headers(headersArgs);