Skip to content

Commit 4f703e6

Browse files
committed
Allow boolean values in buildQuery
1 parent 1547c2c commit 4f703e6

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

frontend/lib/api/campaignWall.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { authenticatedFetch } from "@/lib/auth-helpers";
22
import { Campaign } from "@/types/campaign";
33

4-
const API_BASE_URL =
5-
process.env.NEXT_PUBLIC_API_URL || "http://localhost:8000";
4+
const API_BASE_URL = process.env.NEXT_PUBLIC_API_URL || "http://localhost:8000";
65

76
async function parseJson<T>(response: Response): Promise<T> {
87
if (!response.ok) {
@@ -18,11 +17,16 @@ async function parseJson<T>(response: Response): Promise<T> {
1817
return response.json();
1918
}
2019

21-
function buildQuery(params?: Record<string, string | number | undefined>) {
20+
function buildQuery(
21+
params?: Record<string, string | number | boolean | undefined>
22+
) {
2223
if (!params) return "";
2324
const query = Object.entries(params)
2425
.filter(([, value]) => value !== undefined && value !== "")
25-
.map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`)
26+
.map(
27+
([key, value]) =>
28+
`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`
29+
)
2630
.join("&");
2731
return query ? `?${query}` : "";
2832
}
@@ -77,7 +81,9 @@ export async function fetchPublicCampaigns(params?: {
7781
offset: params?.offset,
7882
});
7983
// Use authenticatedFetch even though endpoint is "public" - user needs to be authenticated for Supabase RLS
80-
const response = await authenticatedFetch(`${API_BASE_URL}/campaigns/public${query}`);
84+
const response = await authenticatedFetch(
85+
`${API_BASE_URL}/campaigns/public${query}`
86+
);
8187
return parseJson<Campaign[]>(response);
8288
}
8389

@@ -150,7 +156,9 @@ export async function createProposalFromApplication(
150156
method: "POST",
151157
}
152158
);
153-
return parseJson<{ proposal: any; application_id: string; message: string }>(response);
159+
return parseJson<{ proposal: any; application_id: string; message: string }>(
160+
response
161+
);
154162
}
155163

156164
export async function fetchCreatorApplications(
@@ -164,5 +172,3 @@ export async function fetchCreatorApplications(
164172
);
165173
return parseJson<CampaignApplication[]>(response);
166174
}
167-
168-

0 commit comments

Comments
 (0)