Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/components/App/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React, { useState, useEffect } from 'react';

import Login from '../Login';
import Dashboard from '../Dashboard';

const App = () => {
const [isAuthenticated, setIsAuthenticated] = useState(null);

useEffect(() => {
setIsAuthenticated(JSON.parse(localStorage.getItem('is_authenticated')));
}, []);

return (
<>
{isAuthenticated ? (
<Dashboard setIsAuthenticated={setIsAuthenticated} />
) : (
<Login setIsAuthenticated={setIsAuthenticated} />
)}
</>
);
};

export default App;
8 changes: 8 additions & 0 deletions src/components/App/index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from 'react';
import { render } from '@testing-library/react';
import App from '.';

test('renders without crashing', () => {
const { unmount } = render(<App />);
unmount();
});