---
/**
* The order request form: lines that can take an order now, the chosen
* line's options, quantity, details, notes, contact and the terms. When no
* category takes orders, or every open line is full, a notice shows instead.
*/
import Button from "@gk/ui/components/Button.astro";
import Notice from "@gk/ui/components/Notice.astro";
import PageShell from "@gk/ui/components/PageShell.astro";
import Star from "@gk/ui/components/Star.astro";
import TickScale from "@gk/ui/components/TickScale.astro";
import Breadcrumb from "../../components/store/Breadcrumb.astro";
import LineStatus from "../../components/store/LineStatus.astro";
import OrderForm from "../../components/store/OrderForm.astro";
import { site } from "../../lib/page.ts";
import { formatDate } from "../../lib/site.ts";
import { canOrder, channelOf, storeNav, storeState } from "../../lib/store.ts";
import { errorMessages, parseDraft, parseErrorCode } from "../../lib/forms.ts";
import { turnstileSiteKey } from "../../lib/forms-server.ts";
const s = await site();
const st = storeState(s);
// A post that was turned down comes back with its reason and the answers given.
const draft = parseDraft(Astro.cookies.get("gk-order-draft")?.value);
if (draft) {
Astro.cookies.delete("gk-order-draft", { path: "/" });
Astro.response.headers.set("Cache-Control", "private, no-store");
}
const errorCode = draft?.code ?? parseErrorCode(Astro.url.searchParams.get("error"));
const turnstileKey = turnstileSiteKey();
const selected = draft?.values.line ?? Astro.url.searchParams.get("line") ?? undefined;
const orderable = st.lines.filter((l) => canOrder(l, st));
const selling = st.lines.filter((l) => channelOf(l) === "here");
const shown = orderable.length ? orderable : selling;
const turnarounds = [...new Set(st.groups.map(([c]) => st.category(c).turnaround).filter((t): t is string => !!t))];
const reopens = st.closed.filter((c) => c.reopens).map((c) => `${c.name} reopens ${formatDate(c.reopens)}.`);
---
{turnstileKey && }
Order request
Send a request and I will confirm the details and the total with you. No payment is taken through the site.
{errorCode && (
{draft && Object.keys(draft.errors).length > 0 ? "The marked answers are below." : ""}
)}
{
orderable.length > 0 ? (
) : (
{st.anyOpen ? (
Slots reopen as current orders finish.
) : (
{reopens.join(" ")}
)}