privateuserh commited on
Commit
0be9c61
·
verified ·
1 Parent(s): 905ca9b

Update scripts/ui.js

Browse files
Files changed (1) hide show
  1. scripts/ui.js +32 -1
scripts/ui.js CHANGED
@@ -1,7 +1,38 @@
1
  // scripts/ui.js -- Final version with dropdown form and instant UI update
2
 
3
- const BACKEND_URL = 'https://stream-ai-backend.smplushypermedia.workers.dev';
 
4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  // --- Helper Functions ---
6
  const getElement = (id) => document.getElementById(id);
7
 
 
1
  // scripts/ui.js -- Final version with dropdown form and instant UI update
2
 
3
+ // --- THIS IS THE CRUCIAL UPDATE ---
4
+ const BACKEND_URL = 'https://streamai-backend-v2.smplushypermedia.workers.dev';
5
 
6
+ async function loadRecommendations() {
7
+ const container = document.getElementById('recommendations-container');
8
+ if (!container) return;
9
+
10
+ try {
11
+ // This now calls the NEW worker's recommendations endpoint
12
+ const response = await fetch(`${BACKEND_URL}/api/recommendations`);
13
+
14
+ if (!response.ok) {
15
+ throw new Error(`Network response was not ok. Status: ${response.status}`);
16
+ }
17
+
18
+ const listings = await response.json();
19
+ // ... (The rest of the rendering logic remains the same) ...
20
+ container.innerHTML = '';
21
+ listings.forEach(item => {
22
+ const card = document.createElement('div');
23
+ // ...card creation logic...
24
+ container.appendChild(card);
25
+ });
26
+
27
+ } catch (error) {
28
+ console.error("Failed to load recommendations:", error);
29
+ if (container) {
30
+ container.innerHTML = `<p class="text-center col-span-full text-red-500">Could not load recommendations.</p>`;
31
+ }
32
+ }
33
+ }
34
+
35
+ // ... (The rest of your ui.js file, including initUI, handleFormSubmit, etc., remains the same) ...
36
  // --- Helper Functions ---
37
  const getElement = (id) => document.getElementById(id);
38