feat: whole shops listed on IMVU, and GET /imports/available (#16)
Release / release (push) Successful in 4s
CI / test (push) Successful in 1m35s
CI / image (apps/api/Dockerfile, t5de-hub-api) (push) Successful in 6s
CI / image (apps/web/Dockerfile, t5de-hub-web) (push) Successful in 14s

Co-authored-by: dhkatz <[email protected]>
This commit was merged in pull request #16.
This commit is contained in:
dhkatz authored and dhkatz committed 2026-11-08 00:51:00 +00:00
1 parent 8f6dacba10
commit efc7d6b808
15 files changed
+4954 -20

No files matched your search

@@ -10,7 +10,15 @@ import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@
import { api, unwrap, type ImportGrant } from "@/lib/api";
import { ConsoleNav, requireConsole } from "../../../console-nav";
import { shortFingerprint } from "@/lib/importer";
import { changeImporterAccount, decideGrant, retryJob, setImporter, setImporterSettings } from "../../actions";
import {
changeImporterAccount,
decideGrant,
listShop,
retryJob,
setImporter,
setImporterSettings,
} from "../../actions";
import { ShopListing } from "@/components/shop-listing";
import { ImporterAccountForm } from "./importer-account-form";
export const metadata: Metadata = { title: "Imports" };
@@ -325,7 +333,7 @@ export default async function CatalogImports({
</CardHeader>
<CardContent className="divide-y">
{others.map((g) => (
<GrantRow key={g.id} id={id} grant={g} accept={can.accept} withdraw={can.withdraw} />
<GrantRow key={g.id} id={id} grant={g} accept={can.accept} withdraw={can.withdraw} run={can.run} />
))}
</CardContent>
</Card>
@@ -415,11 +423,13 @@ function GrantRow({
grant: g,
accept,
withdraw,
run = false,
}: {
id: string;
grant: ImportGrant;
accept: boolean;
withdraw: boolean;
run?: boolean;
}) {
const open = g.status === "pending" || g.status === "active" || g.status === "suspended";
return (
@@ -440,8 +450,16 @@ function GrantRow({
? `The whole shop${g.exclude.length ? `, less ${g.exclude.length} left out` : ""}.`
: `${g.products.length} chosen product${g.products.length === 1 ? "" : "s"}: ${g.products.slice(0, 10).join(", ")}${g.products.length > 10 ? "…" : ""}.`}{" "}
{g.listed ? "Listed." : "Unlisted."}
<ShopListing grant={g} />
</p>
{g.statusReason && <p className="text-sm text-muted-foreground">{g.statusReason}</p>}
{run && g.status === "active" && g.scope === "shop" && (
<ActionForm action={listShop} fields={{ id, grant: g.id }}>
<SubmitButton size="sm" variant="outline" pendingLabel="Listing…">
{g.shopListedAt ? "List the shop again" : "List the shop now"}
</SubmitButton>
</ActionForm>
)}
{open && (accept || withdraw) && (
<ActionForm action={decideGrant} fields={{ id, grant: g.id }}>
<div className="flex max-w-2xl flex-wrap gap-2">
+13 -1
View File
@@ -156,7 +156,19 @@ export async function decideGrant(_: ActionState, form: FormData): Promise<Actio
.grants({ id: grant })({ decision })
.post(reason ? { reason } : {}),
);
return decision === "accept" ? `Accepted. ${r.queued} queued for the importer.` : "Declined.";
if (decision !== "accept") return "Declined.";
return r.grant.scope === "shop"
? `Accepted. ${r.queued} queued for the importer; the shop's other products follow once it's listed on IMVU.`
: `Accepted. ${r.queued} queued for the importer.`;
});
}
/** Lists a whole-shop grant's products on IMVU again (new ones are queued). */
export async function listShop(_: ActionState, form: FormData): Promise<ActionState> {
return onCatalog(form, async (id) => {
revalidatePath(`/console/catalogs/${id}/imports`);
const r = unwrap(await api.imports.grants({ id: field(form, "grant") }).list.post());
return `${r.listed} product${r.listed === 1 ? "" : "s"} on IMVU; ${r.queued} new queued.`;
});
}
+2
View File
@@ -2,6 +2,7 @@ import type { Metadata } from "next";
import { notFound } from "next/navigation";
import { ActionForm, SubmitButton } from "@/components/forms";
import { PageHeader, Tag } from "@/components/status";
import { ShopListing } from "@/components/shop-listing";
import { DateTime } from "@/components/time";
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
import { Field, FieldDescription, FieldLabel } from "@/components/ui/field";
@@ -222,6 +223,7 @@ function RecordedRow({ grant: g }: { grant: Recorded }) {
? `The whole shop${g.exclude.length ? `, less ${g.exclude.length} left out` : ""}.`
: `${g.products.length} chosen product${g.products.length === 1 ? "" : "s"}.`}{" "}
{g.listed ? "Listed." : "Unlisted."}
<ShopListing grant={g} />
</p>
{g.claimed ? (
<p className="text-sm text-muted-foreground">The creator claimed it: they manage it now.</p>