import type { ReactNode } from "react";
import { PERMS } from "@/lib/permission-slugs";
import type { HousekeepingPageInput } from "../../../route-handlers";
import { economyQuery } from "../queries/catalog";
import { EconomyCommandForm } from "./economy-command-form";
import {
EconomyPageFrame,
type EconomyPageProps,
parseEconomyListInput,
} from "./economy-page-frame";
function forms({ context, routeId }: EconomyPageProps) {
if (!context.has(PERMS.CATALOG_EDIT)) return null;
if (routeId === "economy.catalog.maintenance") {
return (
{[
["fix-offers", "Fix catalog offers"],
["fix-everything", "Run complete catalog repair"],
["fix-sprite-ids", "Fix sprite identifiers"],
["reconcile-ids", "Reconcile identifiers"],
["align-ids", "Align identifiers"],
["remove-duplicates", "Remove duplicate base items"],
].map(([operation, label]) => (
))}
);
}
const builderClub = routeId === "economy.catalog.builder-club-detail";
return (
);
}
export function EconomyCatalogPage(
props: EconomyPageProps & { readonly editor?: ReactNode },
) {
return (
);
}
export async function renderEconomyCatalogPage(input: HousekeepingPageInput) {
const routeId = input.match.routeId as EconomyPageProps["routeId"];
const result = await economyQuery.run(input.context, {
routeId: routeId ?? "economy.catalog.overview",
params: input.match.params,
list: parseEconomyListInput(input.searchParams ?? {}),
});
const editor =
result.ok &&
(routeId === "economy.catalog.detail" ||
routeId === "economy.catalog.builder-club-detail")
? await (
await import("./specialized-catalog-editor")
).renderSpecializedCatalogEditor(
routeId,
input.match.params,
input.context,
)
: null;
return (
);
}