Update app to fetch correctly

This commit is contained in:
dvirlabs 2025-07-03 15:51:47 +03:00
parent fa26c24d15
commit 9f37cf6b58

View File

@ -1,22 +1,17 @@
// src/App.jsx
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import './App.css'; import './App.css';
import SectionGrid from './components/SectionGrid'; import SectionGrid from './components/SectionGrid';
import AddAppModal from './components/AddAppModal'; import AddAppModal from './components/AddAppModal';
import Clock from './components/Clock'; import Clock from './components/Clock';
import { fetchSections } from './services/api'; // שימוש בפונקציה הנכונה
function App() { function App() {
const [sections, setSections] = useState([]); const [sections, setSections] = useState([]);
const fetchSections = () => {
fetch('/api/apps')
.then(res => res.json())
.then(data => setSections(data.sections || []));
};
useEffect(() => { useEffect(() => {
fetchSections(); fetchSections()
.then(data => setSections(data.sections || []))
.catch(err => console.error('Failed to fetch sections:', err));
}, []); }, []);
return ( return (