Skip to content

Commit 1db1408

Browse files
pr feedback
Signed-off-by: Jason McCallister <jason@mccallister.dev>
1 parent bd35603 commit 1db1408

2 files changed

Lines changed: 20 additions & 9 deletions

File tree

index.html

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -301,11 +301,18 @@
301301
try {
302302
if (state.favorites.has(propertyId)) {
303303
const favId = state.favorites.get(propertyId);
304-
await fetch(`${API_BASE}/v1/favorites/${favId}`, {
305-
method: "DELETE",
306-
headers: headers(true),
307-
});
308-
state.favorites.delete(propertyId);
304+
const res = await fetch(
305+
`${API_BASE}/v1/favorites/${favId}`,
306+
{
307+
method: "DELETE",
308+
headers: headers(true),
309+
},
310+
);
311+
if (res.ok) {
312+
state.favorites.delete(propertyId);
313+
} else {
314+
console.error("Failed to delete favorite:", res.status);
315+
}
309316
} else {
310317
const res = await fetch(`${API_BASE}/v1/favorites`, {
311318
method: "POST",
@@ -315,6 +322,8 @@
315322
if (res.ok) {
316323
const json = await res.json();
317324
state.favorites.set(propertyId, json.data.id);
325+
} else {
326+
console.error("Failed to add favorite:", res.status);
318327
}
319328
}
320329
renderAuth();
@@ -701,9 +710,9 @@
701710
: '<span class="text-xs font-medium px-2 py-0.5 rounded-full bg-stone-100 text-stone-600 ring-1 ring-black/5">Sold</span>';
702711

703712
const heartBtn = state.connected
704-
? `<button onclick="event.stopPropagation(); toggleFavorite('${
705-
esc(item.id)
706-
}')" class="absolute top-3 right-3 w-9 h-9 flex items-center justify-center rounded-full bg-white/90 hover:bg-white shadow-sm transition-colors ${
713+
? `<button onclick='event.stopPropagation(); toggleFavorite(${
714+
JSON.stringify(item.id)
715+
})' class="absolute top-3 right-3 w-9 h-9 flex items-center justify-center rounded-full bg-white/90 hover:bg-white shadow-sm transition-colors ${
707716
isFav ? "heart-pop" : ""
708717
}" aria-label="${isFav ? "Remove from" : "Add to"} favorites">
709718
<svg class="w-5 h-5 ${

serve.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
const apiBase = Deno.env.get("API_BASE") ?? "http://localhost:5173";
22

3+
const escapedApiBase = JSON.stringify(apiBase).slice(1, -1);
4+
35
const html = (
46
await Deno.readTextFile(new URL("./index.html", import.meta.url))
5-
).replace("__API_BASE__", apiBase);
7+
).replace("__API_BASE__", escapedApiBase);
68

79
Deno.serve({ port: 8080 }, (_req) => {
810
return new Response(html, {

0 commit comments

Comments
 (0)