Initial commit

This commit is contained in:
payacom
2026-07-08 21:01:18 +03:30
parent 78decbba05
commit d2d3398471
1210 changed files with 9645 additions and 2522 deletions

View File

@@ -41,12 +41,16 @@ export async function fetchBillboards(
Authorization: token ? `Bearer ${token}` : "",
},
});
} catch (error) {
console.error("[fetchBillboards] fetch failed:", apiUrl, error);
return { advertisings: [], totalItems: 0, totalPages: 0 };
} finally {
clearTimeout(timeoutId);
}
if (!response.ok) {
throw new Error("Network response was not ok");
console.error("[fetchBillboards] bad response:", response.status, apiUrl);
return { advertisings: [], totalItems: 0, totalPages: 0 };
}
return response.json();

View File

@@ -1,4 +1,5 @@
import { BASE_URL } from "@/components/main/BaseUrl";
import { normalizeUserLevel } from "@/lib/userLevel";
export async function fetchPosts(
page: number,
@@ -14,7 +15,12 @@ export async function fetchPosts(
},
token: string
) {
const validFilters = Object.entries(filters || {})
const normalizedFilters = { ...filters };
if (normalizedFilters.userLevel) {
normalizedFilters.userLevel = normalizeUserLevel(normalizedFilters.userLevel);
}
const validFilters = Object.entries(normalizedFilters || {})
.filter(([value]) => value !== undefined && value !== "")
.reduce((acc, [key, value]) => {
acc[key] = value;