diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index 745a8ae..b935790 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -27,7 +27,7 @@ function App() { - } /> + } /> } /> diff --git a/frontend/src/components/Dashboard.jsx b/frontend/src/components/Dashboard.jsx index d37f867..6320251 100644 --- a/frontend/src/components/Dashboard.jsx +++ b/frontend/src/components/Dashboard.jsx @@ -14,7 +14,7 @@ function getCosts(d) { return { nbUsers, doms, ksuite, site, extra, domCost, total: ksuite + site + extra + domCost } } -export default function Dashboard({ token, user }) { +export default function Dashboard({ token, user, onLogout }) { const [domains, setDomains] = useState([]) const [activeTab, setActiveTab] = useState(-1) const [loading, setLoading] = useState(true) @@ -23,7 +23,12 @@ export default function Dashboard({ token, user }) { useEffect(() => { fetch('/api/domains', { headers: { Authorization: 'Bearer ' + token } }) - .then(r => r.json()).then(d => { + .then(r => { + if (r.status === 401) { onLogout && onLogout(); return null } + return r.json() + }) + .then(d => { + if (!d) return const all = d.parent ? [d.parent, ...d.children] : d.children setDomains(all) setLoading(false)