Compare commits
8 Commits
feat/fiat-
...
revert/bui
| Author | SHA1 | Date | |
|---|---|---|---|
| 6de7839107 | |||
| edcd168d48 | |||
| c20fc5462a | |||
| 2bf7525fe2 | |||
| bf49900b57 | |||
| ff96dcac1c | |||
| 5a3e1a2299 | |||
| 24495d8970 |
@@ -46,15 +46,6 @@ export const Route = createFileRoute("/dashboard/vehicles_/$id/")({
|
|||||||
|
|
||||||
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
||||||
|
|
||||||
// Short labels for the per-vehicle source switcher (eper-pekidi = the native ePER
|
|
||||||
// catalog; parts-catalogs = the broader fallback).
|
|
||||||
const SOURCE_LABELS: Record<string, string> = {
|
|
||||||
"eper-pekidi": "ePER",
|
|
||||||
"parts-catalogs": "Diğer",
|
|
||||||
emex: "Emex",
|
|
||||||
pl24: "PL24",
|
|
||||||
};
|
|
||||||
|
|
||||||
function VehicleDetailPage() {
|
function VehicleDetailPage() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { id } = Route.useParams();
|
const { id } = Route.useParams();
|
||||||
@@ -73,10 +64,6 @@ function VehicleDetailPage() {
|
|||||||
// drill fills them ("Aydınlatma — 0 kategori") — stays source-default until
|
// drill fills them ("Aydınlatma — 0 kategori") — stays source-default until
|
||||||
// per-bucket empty-state/drill-through UX is solved.
|
// per-bucket empty-state/drill-through UX is solved.
|
||||||
const [browseMode, setBrowseMode] = useState<"source" | "canonical">("source");
|
const [browseMode, setBrowseMode] = useState<"source" | "canonical">("source");
|
||||||
// Which per-source catalog "source" mode shows. Defaults to the vehicle's
|
|
||||||
// primary source — eper-pekidi first, the native ePER tree Fiat dealers know
|
|
||||||
// (fully populated + diagrams) over parts-catalogs' broader-but-lazy folders.
|
|
||||||
const [activeSource, setActiveSource] = useState<string | null>(null);
|
|
||||||
|
|
||||||
const changeViewMode = (mode: "grid" | "tree" | "columns") => {
|
const changeViewMode = (mode: "grid" | "tree" | "columns") => {
|
||||||
setViewMode(mode);
|
setViewMode(mode);
|
||||||
@@ -111,24 +98,23 @@ function VehicleDetailPage() {
|
|||||||
retry: (count, err) => !(err instanceof ApiError && err.status === 404) && count < 2,
|
retry: (count, err) => !(err instanceof ApiError && err.status === 404) && count < 2,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Fiat (any eper) vehicle: "Orijinal Katalog" shows the native ePER tree
|
||||||
|
// dealers know; "Birleşik" stays the canonical 20-bucket view (which folds the
|
||||||
|
// catalog into OUR structure), NOT the raw pcat tree. Non-eper vehicles keep
|
||||||
|
// the default source tree (treeSource undefined).
|
||||||
const { data: catalogSources } = useQuery({
|
const { data: catalogSources } = useQuery({
|
||||||
queryKey: ["catalog-sources", id],
|
queryKey: ["catalog-sources", id],
|
||||||
queryFn: () => api.get<string[]>(`/categories/tree/${id}/sources`),
|
queryFn: () => api.get<string[]>(`/categories/tree/${id}/sources`),
|
||||||
enabled: !!id && idValid,
|
enabled: !!id && idValid,
|
||||||
});
|
});
|
||||||
// Once the source list is known, default the active source to the first
|
const hasEper = catalogSources?.includes("eper-pekidi") ?? false;
|
||||||
// (eper-pekidi when present). Never override a source the user picked.
|
const treeSource = hasEper ? "eper-pekidi" : undefined;
|
||||||
useEffect(() => {
|
|
||||||
if (catalogSources && catalogSources.length > 0 && activeSource === null) {
|
|
||||||
setActiveSource(catalogSources[0]);
|
|
||||||
}
|
|
||||||
}, [catalogSources, activeSource]);
|
|
||||||
|
|
||||||
const { data: categoryTree, isLoading: categoriesLoading } = useQuery({
|
const { data: categoryTree, isLoading: categoriesLoading } = useQuery({
|
||||||
queryKey: ["category-tree", id, activeSource],
|
queryKey: ["category-tree", id, treeSource],
|
||||||
queryFn: () =>
|
queryFn: () =>
|
||||||
api.get<CategoryNode[]>(
|
api.get<CategoryNode[]>(
|
||||||
`/categories/tree/${id}${activeSource ? `?source=${encodeURIComponent(activeSource)}` : ""}`,
|
`/categories/tree/${id}${treeSource ? `?source=${encodeURIComponent(treeSource)}` : ""}`,
|
||||||
),
|
),
|
||||||
enabled: !!id && idValid,
|
enabled: !!id && idValid,
|
||||||
});
|
});
|
||||||
@@ -368,23 +354,6 @@ function VehicleDetailPage() {
|
|||||||
Orijinal Katalog
|
Orijinal Katalog
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
{browseMode === "source" && (catalogSources?.length ?? 0) > 1 && (
|
|
||||||
<div className="inline-flex rounded-md border border-border p-0.5">
|
|
||||||
{catalogSources?.map((src) => (
|
|
||||||
<button
|
|
||||||
key={src}
|
|
||||||
type="button"
|
|
||||||
onClick={() => {
|
|
||||||
setActiveSource(src);
|
|
||||||
capture("catalog_source_changed", { vehicle_id: id, source: src });
|
|
||||||
}}
|
|
||||||
className={`rounded px-2.5 py-1 text-xs font-medium transition-colors ${activeSource === src ? "bg-primary text-primary-foreground" : "text-muted-foreground hover:text-foreground"}`}
|
|
||||||
>
|
|
||||||
{SOURCE_LABELS[src] ?? src}
|
|
||||||
</button>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
<CategoryViewToggle value={viewMode} onChange={changeViewMode} />
|
<CategoryViewToggle value={viewMode} onChange={changeViewMode} />
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in New Issue
Block a user