Skip to content

Commit 6d76659

Browse files
simplify: add small test API button in footer
- Remove all debug clutter from Results tab - Add simple Test API button in footer (always visible) - Clean up the UI to be minimal again
1 parent a3cec8e commit 6d76659

File tree

2 files changed

+26
-95
lines changed

2 files changed

+26
-95
lines changed

app/page.tsx

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,35 @@ export default function Home() {
4848
{activeTab === 'survey' && <SurveyTab />}
4949
{activeTab === 'results' && <ResultsTab />}
5050

51-
<div className="mt-8">
51+
<div className="mt-8 flex justify-between items-center">
5252
<p className="text-sm text-gray-600" style={{ fontFamily: 'var(--font-roboto-mono)' }}>
5353
Meeting started at {new Date().toLocaleTimeString('en-GB', {
5454
hour: '2-digit',
5555
minute: '2-digit'
5656
})}
5757
</p>
58+
<button
59+
onClick={async () => {
60+
try {
61+
const response = await fetch('https://mbhrkgzrswaysrmpdehz.supabase.co/rest/v1/survey_responses?select=*', {
62+
headers: {
63+
'apikey': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im1iaHJrZ3pyc3dheXNybXBkZWh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTQ1MTU2NjAsImV4cCI6MjA3MDA5MTY2MH0._JP4S6jVxYt0w7mSL2Rci59pSii0kDK1g9qfgFFtXKI',
64+
'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im1iaHJrZ3pyc3dheXNybXBkZWh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTQ1MTU2NjAsImV4cCI6MjA3MDA5MTY2MH0._JP4S6jVxYt0w7mSL2Rci59pSii0kDK1g9qfgFFtXKI'
65+
}
66+
});
67+
const data = await response.json();
68+
alert(`API Test: ${response.ok ? 'Success' : 'Failed'}\nStatus: ${response.status}\nData: ${JSON.stringify(data).substring(0, 100)}`);
69+
console.log('API Test:', data);
70+
} catch (err) {
71+
alert('API Test Error: ' + err);
72+
console.error('API Test Error:', err);
73+
}
74+
}}
75+
className="text-xs px-3 py-1 bg-gray-200 hover:bg-gray-300 rounded transition-colors"
76+
style={{ fontFamily: 'var(--font-roboto-mono)' }}
77+
>
78+
Test API
79+
</button>
5880
</div>
5981
</div>
6082
</div>

components/ResultsTab.tsx

Lines changed: 3 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -21,34 +21,21 @@ interface SurveyResponse {
2121
export default function ResultsTab() {
2222
const [responses, setResponses] = useState<SurveyResponse[]>([]);
2323
const [loading, setLoading] = useState(true);
24-
const [error, setError] = useState<string | null>(null);
25-
const [debugInfo, setDebugInfo] = useState<string>('');
2624

2725
const chartContainerRef = useRef<HTMLDivElement>(null);
2826

2927
useEffect(() => {
30-
console.log('ResultsTab mounted');
31-
setDebugInfo(prev => prev + '\nResultsTab mounted');
3228
fetchResponses();
3329
}, []);
3430

3531
const fetchResponses = async () => {
36-
console.log('fetchResponses called');
37-
setDebugInfo(prev => prev + '\nfetchResponses called');
3832
try {
39-
console.log('About to call dataService.getSurveyData()');
40-
setDebugInfo(prev => prev + '\nCalling dataService...');
4133
const data = await dataService.getSurveyData();
42-
console.log('Fetched survey data:', data);
43-
setDebugInfo(prev => prev + '\nGot data: ' + JSON.stringify(data).substring(0, 100));
4434
setResponses(data.responses || []);
4535
} catch (error) {
4636
console.error('Error fetching responses:', error);
47-
setError(String(error));
48-
setDebugInfo(prev => prev + '\nError: ' + String(error));
4937
} finally {
5038
setLoading(false);
51-
setDebugInfo(prev => prev + '\nLoading complete');
5239
}
5340
};
5441

@@ -300,7 +287,6 @@ export default function ResultsTab() {
300287
return (
301288
<div className="bg-white rounded-xl shadow-lg p-8">
302289
<div className="py-12 text-gray-500">Loading survey results...</div>
303-
<pre className="mt-4 p-4 bg-gray-100 text-xs">{debugInfo}</pre>
304290
</div>
305291
);
306292
}
@@ -311,92 +297,15 @@ export default function ResultsTab() {
311297
<div className="py-12 text-gray-500">
312298
No survey responses yet.
313299
</div>
314-
{error && (
315-
<div className="mt-4 p-4 bg-red-50 border border-red-200 rounded">
316-
<p className="text-red-700">Error: {error}</p>
317-
</div>
318-
)}
319-
<pre className="mt-4 p-4 bg-gray-100 text-xs overflow-auto">Debug info:{debugInfo}</pre>
320-
<div className="mt-4 flex gap-2">
321-
<button
322-
onClick={async () => {
323-
console.log('Direct test clicked');
324-
setDebugInfo(prev => prev + '\nDirect test clicked');
325-
try {
326-
const response = await fetch('https://mbhrkgzrswaysrmpdehz.supabase.co/rest/v1/survey_responses', {
327-
headers: {
328-
'apikey': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im1iaHJrZ3pyc3dheXNybXBkZWh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTQ1MTU2NjAsImV4cCI6MjA3MDA5MTY2MH0._JP4S6jVxYt0w7mSL2Rci59pSii0kDK1g9qfgFFtXKI',
329-
'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im1iaHJrZ3pyc3dheXNybXBkZWh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTQ1MTU2NjAsImV4cCI6MjA3MDA5MTY2MH0._JP4S6jVxYt0w7mSL2Rci59pSii0kDK1g9qfgFFtXKI'
330-
}
331-
});
332-
const data = await response.json();
333-
setDebugInfo(prev => prev + '\nDirect fetch: ' + JSON.stringify(data).substring(0, 200));
334-
alert('Got ' + (Array.isArray(data) ? data.length : 0) + ' records');
335-
} catch (err) {
336-
setDebugInfo(prev => prev + '\nDirect fetch error: ' + String(err));
337-
}
338-
}}
339-
className="px-4 py-2 bg-green-600 text-white rounded-lg"
340-
>
341-
Test Direct Fetch
342-
</button>
343-
<button
344-
onClick={() => {
345-
setLoading(true);
346-
fetchResponses();
347-
}}
348-
className="px-4 py-2 bg-blue-600 text-white rounded-lg"
349-
>
350-
Retry with Supabase Client
351-
</button>
352-
</div>
353300
</div>
354301
);
355302
}
356303

357304
return (
358305
<div className="bg-white rounded-xl shadow-lg p-8">
359-
<div className="flex justify-between items-center mb-6">
360-
<h2 className="text-2xl font-semibold text-gray-800" style={{ fontFamily: 'var(--font-roboto-serif)' }}>
361-
Team health metrics over time
362-
</h2>
363-
<div className="flex gap-2">
364-
<button
365-
onClick={async () => {
366-
console.log('Test button clicked');
367-
try {
368-
console.log('Making direct Supabase call...');
369-
const response = await fetch('https://mbhrkgzrswaysrmpdehz.supabase.co/rest/v1/survey_responses', {
370-
headers: {
371-
'apikey': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im1iaHJrZ3pyc3dheXNybXBkZWh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTQ1MTU2NjAsImV4cCI6MjA3MDA5MTY2MH0._JP4S6jVxYt0w7mSL2Rci59pSii0kDK1g9qfgFFtXKI',
372-
'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im1iaHJrZ3pyc3dheXNybXBkZWh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTQ1MTU2NjAsImV4cCI6MjA3MDA5MTY2MH0._JP4S6jVxYt0w7mSL2Rci59pSii0kDK1g9qfgFFtXKI'
373-
}
374-
});
375-
const data = await response.json();
376-
console.log('Direct fetch result:', data);
377-
alert('Check console - got ' + (Array.isArray(data) ? data.length : 0) + ' records');
378-
} catch (err) {
379-
console.error('Direct fetch error:', err);
380-
alert('Error: ' + err);
381-
}
382-
}}
383-
className="px-4 py-2 bg-green-600 text-white rounded-lg hover:bg-green-700 transition-colors"
384-
style={{ fontFamily: 'var(--font-roboto)' }}
385-
>
386-
Test API
387-
</button>
388-
<button
389-
onClick={() => {
390-
setLoading(true);
391-
fetchResponses();
392-
}}
393-
className="px-4 py-2 bg-[#2C6496] text-white rounded-lg hover:bg-[#1e4268] transition-colors"
394-
style={{ fontFamily: 'var(--font-roboto)' }}
395-
>
396-
Refresh
397-
</button>
398-
</div>
399-
</div>
306+
<h2 className="text-2xl font-semibold text-gray-800 mb-6" style={{ fontFamily: 'var(--font-roboto-serif)' }}>
307+
Team health metrics over time
308+
</h2>
400309

401310
<div ref={chartContainerRef}></div>
402311
</div>

0 commit comments

Comments
 (0)