import type { LoaderFunctionArgs } from "@remix-run/node"; import { useLoaderData } from "@remix-run/react"; import { Page, Layout, Text, Card, BlockStack, EmptyState, InlineStack, Badge } from "@shopify/polaris"; import { TitleBar } from "@shopify/app-bridge-react"; import { authenticate } from "../shopify.server"; import db from "../db.server"; export const loader = async ({ request }: LoaderFunctionArgs) => { const { session } = await authenticate.admin(request); const locations = await db.location.findMany({ where: { shopDomain: session.shop }, include: { _count: { select: { slotTemplates: true } } }, }); return { locations }; }; export default function Index() { const { locations } = useLoaderData(); return ( {locations.length === 0 ? ( Set up a fulfillment location and its weekly slots to start taking scheduled Shipping, Local Delivery, or Pickup orders. ) : ( {locations.length} location{locations.length === 1 ? "" : "s"} configured {locations.map((location) => ( {location.name} {`${location._count.slotTemplates} slot templates`} ))} )} ); }