Compare commits
2 Commits
105aa2e30b
...
d4d2ded45c
Author | SHA1 | Date |
---|---|---|
Ron Reciproco | d4d2ded45c | 1 year ago |
Ron Reciproco | 0157a25e81 | 1 year ago |
@ -0,0 +1,54 @@
|
||||
import { Button, Card } from "react-bootstrap";
|
||||
import PropTypes from 'prop-types';
|
||||
import { useState } from 'react'
|
||||
|
||||
export default function CourseCard({ courseProp }) {
|
||||
|
||||
const { name, description, price } = courseProp;
|
||||
|
||||
// Use the state hook to be able to store state (data) in this component
|
||||
// States are used to keep track of information related to individual component
|
||||
// Syntax:
|
||||
/**
|
||||
* const [ getter, setterFunction ] = useState(initialGetterValue)
|
||||
*/
|
||||
|
||||
const [ count, setCount ] = useState(30);
|
||||
const enroll = () => {
|
||||
if (count > 0) {
|
||||
setCount(count - 1);
|
||||
} else {
|
||||
alert('No More Seats');
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
return (
|
||||
<Card>
|
||||
<Card.Body>
|
||||
<Card.Title>{name}</Card.Title>
|
||||
<Card.Title>Description</Card.Title>
|
||||
<Card.Text>{description}</Card.Text>
|
||||
<Card.Title>Price:</Card.Title>
|
||||
<Card.Text>Php {price}</Card.Text>
|
||||
<Card.Text>Enrollees: {count}</Card.Text>
|
||||
<Button variant="primary" onClick={enroll}>
|
||||
Enroll
|
||||
</Button>
|
||||
</Card.Body>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
// Check if the CourseCard component is getting the correct prop types
|
||||
// PropTypes are used for validating information passed to a component.
|
||||
CourseCard.propTypes = {
|
||||
// The 'shape' method is used to check if a prop object conforms to a specific "shape"
|
||||
courseProp: PropTypes.shape({
|
||||
// Define the properties and their expected types
|
||||
name: PropTypes.string.isRequired,
|
||||
description: PropTypes.string.isRequired,
|
||||
price: PropTypes.number.isRequired
|
||||
}).isRequired // Make sure the entire courseProp object is required
|
||||
};
|
@ -0,0 +1,39 @@
|
||||
const coursesData = [
|
||||
{
|
||||
id: "wdc001",
|
||||
name: "PHP - Laravel",
|
||||
description: "Nostrud velit dolor excepteur ullamco consectetur aliquip tempor. Consectetur occaecat laborum exercitation sint reprehenderit irure nulla mollit. Do dolore sint deserunt quis ut sunt ad nulla est consectetur culpa. Est esse dolore nisi consequat nostrud id nostrud sint sint deserunt dolore.",
|
||||
price: 45000,
|
||||
onOffer: true
|
||||
},
|
||||
{
|
||||
id: "wdc002",
|
||||
name: "Python - Django",
|
||||
description: "Eu non commodo et eu ex incididunt minim aliquip anim. Aliquip voluptate ut velit fugiat laborum. Laborum dolore anim pariatur pariatur commodo minim ut officia mollit ad ipsum ex. Laborum veniam cupidatat veniam minim occaecat veniam deserunt nulla irure. Enim elit sint magna incididunt occaecat in dolor amet dolore consectetur ad mollit. Exercitation sunt occaecat labore irure proident consectetur commodo ad anim ea tempor irure.",
|
||||
price: 50000,
|
||||
onOffer: true
|
||||
},
|
||||
{
|
||||
id: "wdc003",
|
||||
name: "Java - Springboot",
|
||||
description: "Proident est adipisicing est deserunt cillum dolore. Fugiat incididunt quis aliquip ut aliquip est mollit officia dolor ea cupidatat velit. Consectetur aute velit aute ipsum quis. Eiusmod dolor exercitation dolor mollit duis velit aliquip dolor proident ex exercitation labore cupidatat. Eu aliquip mollit labore do.",
|
||||
price: 55000,
|
||||
onOffer: true
|
||||
},
|
||||
{
|
||||
id: "wdc003",
|
||||
name: "Java - React",
|
||||
description: "Proident est adipisicing est deserunt cillum dolore. Fugiat incididunt quis aliquip ut aliquip est mollit officia dolor ea cupidatat velit. Consectetur aute velit aute ipsum quis. Eiusmod dolor exercitation dolor mollit duis velit aliquip dolor proident ex exercitation labore cupidatat. Eu aliquip mollit labore do.",
|
||||
price: 55000,
|
||||
onOffer: true
|
||||
},
|
||||
{
|
||||
id: "wdc003",
|
||||
name: "Java - Express",
|
||||
description: "Proident est adipisicing est deserunt cillum dolore. Fugiat incididunt quis aliquip ut aliquip est mollit officia dolor ea cupidatat velit. Consectetur aute velit aute ipsum quis. Eiusmod dolor exercitation dolor mollit duis velit aliquip dolor proident ex exercitation labore cupidatat. Eu aliquip mollit labore do.",
|
||||
price: 55000,
|
||||
onOffer: true
|
||||
}
|
||||
]
|
||||
|
||||
export default coursesData;
|
@ -0,0 +1,21 @@
|
||||
|
||||
import CourseCard from "../components/CourseCard"
|
||||
import coursesData from "../data/courseData"
|
||||
export default function Courses() {
|
||||
|
||||
console.log(coursesData);
|
||||
console.log(coursesData[0]);
|
||||
|
||||
const courses = coursesData.map(course => {
|
||||
return (
|
||||
<CourseCard courseProp={course} />
|
||||
)
|
||||
})
|
||||
|
||||
// Component Body
|
||||
return (
|
||||
<>
|
||||
{courses}
|
||||
</>
|
||||
)
|
||||
}
|
Loading…
Reference in New Issue