Initial commit
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user