Bootstraps from Shopify's official shopify-app-template-remix (cloned directly rather than via `shopify app init`, which requires an interactive Partner login unavailable in this session): - Prisma (SQLite dev / Postgres-ready) with baseline Session model + migration - Vitest configured for unit tests, Playwright configured for E2E - Redis client + BullMQ worker skeleton (app/lib/redis.server.ts, jobs/worker.ts) - shopify.app.toml: minimal scopes, GDPR + orders webhooks wired (stub handlers), app proxy config for the future storefront widget - Stripped template-repo-only meta files (CLA, issue templates, demo product page) and replaced CI with a lint+typecheck+test workflow - Bumped @shopify/shopify-app-session-storage-prisma to resolve a duplicate @shopify/shopify-api install that broke typecheck - Dropped the Jest-only ESLint config (template default) since the project standardizes on Vitest per IMPLEMENTATION_PLAN.md Verified: npm install, lint, typecheck, unit tests, prisma migrate dev, and npm run build all pass on Node 22 LTS. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
69 lines
1.9 KiB
TypeScript
69 lines
1.9 KiB
TypeScript
import { useState } from "react";
|
|
import type { ActionFunctionArgs, LoaderFunctionArgs } from "@remix-run/node";
|
|
import { Form, useActionData, useLoaderData } from "@remix-run/react";
|
|
import {
|
|
AppProvider as PolarisAppProvider,
|
|
Button,
|
|
Card,
|
|
FormLayout,
|
|
Page,
|
|
Text,
|
|
TextField,
|
|
} from "@shopify/polaris";
|
|
import polarisTranslations from "@shopify/polaris/locales/en.json";
|
|
import polarisStyles from "@shopify/polaris/build/esm/styles.css?url";
|
|
|
|
import { login } from "../../shopify.server";
|
|
|
|
import { loginErrorMessage } from "./error.server";
|
|
|
|
export const links = () => [{ rel: "stylesheet", href: polarisStyles }];
|
|
|
|
export const loader = async ({ request }: LoaderFunctionArgs) => {
|
|
const errors = loginErrorMessage(await login(request));
|
|
|
|
return { errors, polarisTranslations };
|
|
};
|
|
|
|
export const action = async ({ request }: ActionFunctionArgs) => {
|
|
const errors = loginErrorMessage(await login(request));
|
|
|
|
return {
|
|
errors,
|
|
};
|
|
};
|
|
|
|
export default function Auth() {
|
|
const loaderData = useLoaderData<typeof loader>();
|
|
const actionData = useActionData<typeof action>();
|
|
const [shop, setShop] = useState("");
|
|
const { errors } = actionData || loaderData;
|
|
|
|
return (
|
|
<PolarisAppProvider i18n={loaderData.polarisTranslations}>
|
|
<Page>
|
|
<Card>
|
|
<Form method="post">
|
|
<FormLayout>
|
|
<Text variant="headingMd" as="h2">
|
|
Log in
|
|
</Text>
|
|
<TextField
|
|
type="text"
|
|
name="shop"
|
|
label="Shop domain"
|
|
helpText="example.myshopify.com"
|
|
value={shop}
|
|
onChange={setShop}
|
|
autoComplete="on"
|
|
error={errors.shop}
|
|
/>
|
|
<Button submit>Log in</Button>
|
|
</FormLayout>
|
|
</Form>
|
|
</Card>
|
|
</Page>
|
|
</PolarisAppProvider>
|
|
);
|
|
}
|