-
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
28940e2
commit f05d098
Showing
7 changed files
with
145 additions
and
7 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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export async function handler(event, context) { | ||
// ... your scanning logic which determines the total and scanned items | ||
// For demonstration, here's a static response: | ||
return { | ||
statusCode: 200, | ||
body: JSON.stringify({ | ||
scanned: 20, // update dynamically | ||
total: 100, // update dynamically | ||
}), | ||
}; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import React from 'react'; | ||
import ScannerUI from './ScannerUI'; | ||
|
||
const Home = () => { | ||
return ( | ||
<div className="min-h-screen bg-gray-900 transition-colors duration-200"> | ||
<div className="container mx-auto px-4"> | ||
<ScannerUI /> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Home; |
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import React, { useState, useEffect } from 'react'; | ||
|
||
function ProgressBar() { | ||
// Initialize with 0. Ensure your API returns non-zero total when scanning starts. | ||
const [progress, setProgress] = useState({ scanned: 0, total: 0 }); | ||
|
||
useEffect(() => { | ||
async function fetchProgress() { | ||
try { | ||
// Assuming your Netlify function or API endpoint is at /api/progress | ||
const response = await fetch('/api/progress'); | ||
const data = await response.json(); | ||
console.log('Progress API response:', data); | ||
// Make sure data.scanned and data.total are valid numbers | ||
setProgress({ | ||
scanned: typeof data.scanned === 'number' ? data.scanned : 0, | ||
total: typeof data.total === 'number' ? data.total : 0, | ||
}); | ||
} catch (error) { | ||
console.error('Error fetching progress:', error); | ||
} | ||
} | ||
|
||
// Poll every 2 seconds (adjust as needed) | ||
const intervalId = setInterval(fetchProgress, 2000); | ||
|
||
// Clean up on unmount | ||
return () => clearInterval(intervalId); | ||
}, []); | ||
|
||
return ( | ||
<div> | ||
<p>{`fetching: ${progress.scanned} of ${progress.total}`}</p> | ||
{/* Add any additional UI, like a visual progress bar */} | ||
</div> | ||
); | ||
} | ||
|
||
export default ProgressBar; |