|
301 | 301 | try { |
302 | 302 | if (state.favorites.has(propertyId)) { |
303 | 303 | 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 | + } |
309 | 316 | } else { |
310 | 317 | const res = await fetch(`${API_BASE}/v1/favorites`, { |
311 | 318 | method: "POST", |
|
315 | 322 | if (res.ok) { |
316 | 323 | const json = await res.json(); |
317 | 324 | state.favorites.set(propertyId, json.data.id); |
| 325 | + } else { |
| 326 | + console.error("Failed to add favorite:", res.status); |
318 | 327 | } |
319 | 328 | } |
320 | 329 | renderAuth(); |
|
701 | 710 | : '<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>'; |
702 | 711 |
|
703 | 712 | 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 ${ |
707 | 716 | isFav ? "heart-pop" : "" |
708 | 717 | }" aria-label="${isFav ? "Remove from" : "Add to"} favorites"> |
709 | 718 | <svg class="w-5 h-5 ${ |
|
0 commit comments