diff --git a/authentication/src/components/accountSessions.tsx b/authentication/src/components/accountSessions.tsx index 8f6d3d8..094a8c2 100644 --- a/authentication/src/components/accountSessions.tsx +++ b/authentication/src/components/accountSessions.tsx @@ -7,27 +7,10 @@ import SessionItem from '@/components/sessionItem'; import { Separator } from '@/components/ui/separator'; export default function AccountSessions() { - const [current, setCurrent] = useState(); const [sessions, setSessions] = useState(); - const invalidateSession = useCallback(async (id: string) => { - - console.log('Disabling session with id', id); - - kratos.disableMySession({ id: id }) - .then(() => console.log('Disabled session with id', id)) - .catch(() => console.error('Error while disabling session with id', id)) - .finally(() => { - loadSessions().then((response) => { - setCurrent(response.current); - setSessions(response.sessions); - }); - }); - }, []); - const loadSessions = useCallback(async () => { - console.log('Refreshing sessions'); const current = await kratos.toSession(); @@ -42,38 +25,49 @@ export default function AccountSessions() { }; }, []); + const invalidateSession = useCallback( + async (id: string) => { + console.log('Disabling session with id', id); + + kratos + .disableMySession({ id: id }) + .then(() => console.log('Disabled session with id', id)) + .catch(() => console.error('Error while disabling session with id', id)) + .finally(() => { + loadSessions().then((response) => { + setCurrent(response.current); + setSessions(response.sessions); + }); + }); + }, + [loadSessions] + ); + useEffect(() => { - loadSessions().then(response => { + loadSessions().then((response) => { setCurrent(response.current); setSessions(response.sessions); }); - }, []); + }, [loadSessions]); return (
- { - current ? - - : - <> - } - { - sessions && sessions.length > 0 ? - - : - <> - } - { - sessions?.map(item => { - return ( - - ); - }) - } + {current ? ( + + ) : ( + <> + )} + {sessions && sessions.length > 0 ? : <>} + {sessions?.map((item) => { + return ( + + ); + })}
); }