fix: use configured furni source and catalog assets

This commit is contained in:
Simo committed 2026-08-02 14:22:05 +02:00
1 parent aed70db81f
commit c78f8812ad
25 files changed
+368 -129

No files matched your search

@@ -7,8 +7,10 @@ import {
Check,
CheckCheck,
Download,
ExternalLink,
FileWarning,
FolderSync,
Globe2,
LayoutGrid,
List,
Loader2,
@@ -52,6 +54,7 @@ import {
SelectValue,
} from "@/components/ui/select";
import { adminFetch } from "@/lib/admin-fetch";
import type { FurniImportSource } from "@/lib/habbo-gamedata-hotel";
import { NitroEditorDialog } from "./nitro-editor-dialog";
interface FurniItem {
@@ -146,7 +149,7 @@ const STATUS_LABELS: Record<string, string> = {
failed: "Failed",
};
export function ImportFurniClient() {
export function ImportFurniClient({ source }: { source: FurniImportSource }) {
const [searchTerm, setSearchTerm] = useState("");
const [activeSearch, setActiveSearch] = useState("");
const [items, setItems] = useState<FurniItem[]>([]);
@@ -936,6 +939,31 @@ export function ImportFurniClient() {
return (
<div className="space-y-4">
<div className="flex flex-wrap items-center justify-between gap-3 rounded-lg border bg-card px-4 py-3">
<div className="flex items-center gap-3">
<div className="rounded-md bg-primary/10 p-2 text-primary">
<Globe2 className="h-4 w-4" />
</div>
<div>
<p className="text-xs text-muted-foreground">
Official furnidata source
</p>
<p className="text-sm font-medium">{source.label}</p>
<p className="text-[10px] text-muted-foreground">
Furniture assets: {source.assetCdnHost}
</p>
</div>
</div>
<a
href={source.furnidataUrl}
target="_blank"
rel="noreferrer"
className="inline-flex items-center gap-1 text-xs font-medium text-primary hover:underline"
>
{source.host}
<ExternalLink className="h-3 w-3" />
</a>
</div>
{/* Dashboard Statistics */}
{!stats && (
<div className="grid grid-cols-2 md:grid-cols-5 gap-3">
@@ -0,0 +1,38 @@
// @vitest-environment node
import { describe, expect, it } from "vitest";
import * as hotelHelpers from "@/lib/habbo-gamedata-hotel";
describe("furni import source metadata", () => {
it("describes the configured hotel without changing the global asset CDN", () => {
const helpers = hotelHelpers as unknown as {
buildFurniImportSource?: (hotel: string) => {
hotel: string;
label: string;
host: string;
furnidataUrl: string;
assetCdnHost: string;
};
officialHabboEnrichmentWarning?: (hotel: string, name: string) => string;
};
expect(helpers.buildFurniImportSource).toBeTypeOf("function");
expect(helpers.officialHabboEnrichmentWarning).toBeTypeOf("function");
if (
!helpers.buildFurniImportSource ||
!helpers.officialHabboEnrichmentWarning
) {
return;
}
expect(helpers.buildFurniImportSource("nl")).toEqual({
hotel: "nl",
label: "Netherlands (habbo.nl)",
host: "habbo.nl",
furnidataUrl: "https://www.habbo.nl/gamedata/furnidata_json/1",
assetCdnHost: "images.habbo.com",
});
expect(helpers.officialHabboEnrichmentWarning("nl", "Stoel")).toBe(
'Enriched from habbo.nl: "Stoel"',
);
});
});
+4 -1
View File
@@ -1,5 +1,7 @@
import { redirect } from "next/navigation";
import { buildFurniImportSource } from "@/lib/habbo-gamedata-hotel";
import { canAccess, getAdminContext, PERMS } from "@/lib/permissions";
import { getHabboGamedataHotel } from "@/lib/services/habbo-gamedata-hotel";
import { ImportFurniClient } from "./import-furni-client";
export default async function ImportFurniPage(_props: {
@@ -10,5 +12,6 @@ export default async function ImportFurniPage(_props: {
redirect("/admin");
}
return <ImportFurniClient />;
const hotel = await getHabboGamedataHotel();
return <ImportFurniClient source={buildFurniImportSource(hotel)} />;
}