Skip to content

Commit

Permalink
Create App.js
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Oct 20, 2024
1 parent 13f2e52 commit a875489
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions frontend/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import React from 'react';
import Lesson from './Lesson';
import Badge from './Badge';

const App = () => {
const [lessons, setLessons] = useState([]);
const [badges, setBadges] = useState([]);

useEffect(() => {
// Get the lessons and badges from the contract
blockchainBasicsContract.methods .getLessons().call().then((lessons) => {
setLessons(lessons);
});
blockchainBasicsContract.methods.getBadges().call().then((badges) => {
setBadges(badges);
});
}, []);

return (
<div>
<h1>Blockchain Basics</h1>
<ul>
{lessons.map((lesson) => (
<li key={lesson.id}>
<Lesson lesson={lesson} />
</li>
))}
</ul>
<h1>Badges</h1>
<ul>
{badges.map((badge) => (
<li key={badge.id}>
<Badge badge={badge} />
</li>
))}
</ul>
</div>
);
};

export default App;

0 comments on commit a875489

Please sign in to comment.