fixing novo

This commit is contained in:
sdarbinyan
2026-04-13 22:39:33 +04:00
parent 6de461473e
commit 77737f0ba9
3 changed files with 17 additions and 10 deletions

View File

@@ -661,8 +661,10 @@ function getAllVisibleItems(): any[] {
return MOCK_ITEMS.filter(i => i.visible !== false);
}
function getItemsByCategoryId(categoryID: number): any[] {
return getAllVisibleItems().filter(i => i.categoryID === categoryID);
function getItemsByCategoryId(categoryID: number | string): any[] {
return getAllVisibleItems().filter(i =>
i.categoryID === categoryID || i.subcategoryId === categoryID
);
}
function respond<T>(body: T, delayMs = 150) {
@@ -689,18 +691,23 @@ export const mockDataInterceptor: HttpInterceptorFn = (req, next) => {
}
// ── GET /category/:id (items for a category)
const catItemsMatch = url.match(/\/category\/(\d+)$/);
const catItemsMatch = url.match(/\/category\/([^/?]+)$/);
if (catItemsMatch && req.method === 'GET') {
const catId = parseInt(catItemsMatch[1], 10);
const raw = catItemsMatch[1];
const num = Number(raw);
const catId = Number.isFinite(num) ? num : raw;
const items = getItemsByCategoryId(catId);
return respond(items);
}
// ── GET /item/:id
const itemMatch = url.match(/\/item\/(\d+)$/);
const itemMatch = url.match(/\/item\/([^/?]+)$/);
if (itemMatch && req.method === 'GET') {
const itemId = parseInt(itemMatch[1], 10);
const item = MOCK_ITEMS.find(i => i.itemID === itemId);
const raw = itemMatch[1];
const num = Number(raw);
const item = MOCK_ITEMS.find(i =>
Number.isFinite(num) ? i.itemID === num : i.id === raw
);
if (item) {
return respond(item);
}