-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9888155
commit a111e09
Showing
2 changed files
with
52 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,49 @@ | ||
import React from 'react'; | ||
import Container from 'react-bootstrap/Container'; | ||
import Row from 'react-bootstrap/Row'; | ||
import Col from 'react-bootstrap/Col'; | ||
import React, { useState, useEffect } from 'react'; | ||
import axios from 'axios'; | ||
import FileUpload from './components/FileUpload'; | ||
import FileList from './components/FileList'; | ||
import 'bootstrap/dist/css/bootstrap.min.css'; // Import Bootstrap CSS | ||
import './App.css'; // Import custom CSS | ||
import { Container } from 'react-bootstrap'; | ||
|
||
function App() { | ||
return ( | ||
<Container fluid className="App"> | ||
<header className="App-header py-3"> | ||
<h1>File Management App</h1> | ||
</header> | ||
<main className="py-3"> | ||
<Row> | ||
<Col md={6} className="mb-4"> | ||
<FileUpload /> | ||
</Col> | ||
<Col md={6}> | ||
<FileList /> | ||
</Col> | ||
</Row> | ||
</main> | ||
</Container> | ||
); | ||
} | ||
const App = () => { | ||
const [files, setFiles] = useState([]); | ||
const [loadingFiles, setLoadingFiles] = useState(false); | ||
const apiUrl = process.env.REACT_APP_API_GATEWAY_URL; | ||
|
||
useEffect(() => { | ||
fetchFiles(); | ||
}, []); | ||
|
||
const fetchFiles = async () => { | ||
setLoadingFiles(true); | ||
try { | ||
const response = await axios.get(`${apiUrl}listFiles`); | ||
if (response.status === 200) { | ||
setFiles(response.data); | ||
} else { | ||
console.error('Unexpected status code:', response.status); | ||
} | ||
} catch (error) { | ||
console.error('Error fetching files:', error); | ||
} finally { | ||
setLoadingFiles(false); | ||
} | ||
}; | ||
|
||
const handleFileUploadSuccess = () => { | ||
fetchFiles(); // Reload the file list | ||
}; | ||
|
||
return ( | ||
<Container className="mt-5"> | ||
<h1 className="text-center mb-4">File Management App</h1> | ||
<FileUpload apiUrl={apiUrl} onUploadSuccess={handleFileUploadSuccess} /> | ||
{loadingFiles ? ( | ||
<p>Loading files...</p> | ||
) : ( | ||
<FileList files={files} apiUrl={apiUrl} /> | ||
)} | ||
</Container> | ||
); | ||
}; | ||
|
||
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters