| Server IP : 217.154.3.148 / Your IP : 216.73.216.90 Web Server : nginx/1.30.3 System : Linux blissful-wright.217-154-3-148.plesk.page 6.8.0-124-generic #124-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 13:00:45 UTC 2026 x86_64 User : gracious-boyd_hfhh1h8vo9n ( 10000) PHP Version : 8.3.31 Disable Function : opcache_get_status MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/vhosts/gracious-boyd.217-154-3-148.plesk.page/nextjs/components/ |
Upload File : |
"use client";
import { useSearchParams } from "next/navigation";
import { useEffect, useMemo } from "react";
import dynamic from "next/dynamic";
const TileSwapApp = dynamic(() => import("./TileSwapApp"), { ssr: false });
function toNumMaybe(v: string | null): number | undefined {
if (v == null) return undefined;
// Dezimalkomma erlauben
const cleaned = v.replace(",", ".");
const n = Number(cleaned);
return Number.isFinite(n) ? n : undefined;
}
function pickFirst(sp: URLSearchParams, keys: string[]): string | null {
for (const k of keys) {
const v = sp.get(k);
if (v !== null && v !== "") return v;
}
return null;
}
export default function VisualizerClient() {
const sp = useSearchParams();
const searchParams = useMemo(() => sp ?? new URLSearchParams(), [sp]);
useEffect(() => {
const entries = Array.from(searchParams.entries());
console.log("Visualizer query entries:", entries);
}, [searchParams]);
const params = useMemo(() => {
// Akzeptiere mehrere Schreibweisen
const wRaw = pickFirst(searchParams, ["tile_w", "tileW", "w", "width"]);
const hRaw = pickFirst(searchParams, ["tile_h", "tileH", "h", "height"]);
const gRaw = pickFirst(searchParams, ["grout", "grout_w", "g", "gap"]);
return {
tile_w: toNumMaybe(wRaw),
tile_h: toNumMaybe(hRaw),
grout: toNumMaybe(gRaw),
};
}, [searchParams]);
return (
<div className="p-4 space-y-4">
<div className="rounded-xl border p-3 bg-white shadow-sm">
<div className="text-sm font-medium mb-1">Service: tile_w / tile_h / grout</div>
<div className="text-sm text-gray-700">
{String(params.tile_w)} / {String(params.tile_h)} / {String(params.grout)}
</div>
</div>
<div className="rounded-xl border p-3">
<div className="text-xs text-gray-500 mb-1">Debug (alle Query-Parameter):</div>
<pre className="text-xs overflow-auto">
{JSON.stringify(Array.from(searchParams.entries()), null, 2)}
</pre>
</div>
{/* Falls TileSwapApp Props erwartet, hier übergeben */}
{/* <TileSwapApp initialTileW={params.tile_w} initialTileH={params.tile_h} initialGrout={params.grout} /> */}
<TileSwapApp />
</div>
);
}