Skip to content
Open
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
75 changes: 44 additions & 31 deletions src/pages/Events/Events.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,10 @@ const HeadEvent = ({ subtitle, firstCta, secondCta, description, event }) => {
);
};

const Event = ({ name, description, img }) => {
const Event = ({ name, description, img ,event,link}) => {
const { data, isLoading } = useEventData();
// console.log(data);
// const registrationLink = event.registrationLink


return (
Expand All @@ -108,6 +109,7 @@ const Event = ({ name, description, img }) => {
size="small"
background="linear-gradient(135deg, #f7f7f7, #cfcfcf)"
img={img}
// registrationLink = {registrationLink}
action={true}
>
<Box>
Expand All @@ -126,7 +128,7 @@ const Event = ({ name, description, img }) => {
{/*<Description color="black">{description}</Description>*/}

<Box position="absolute" right={'25px'} bottom="15px">
<IconButton>
<IconButton href={link}>
<FiArrowRight />
</IconButton>
</Box>
Expand All @@ -136,36 +138,36 @@ const Event = ({ name, description, img }) => {
};

const Events = () => {
const { data, isLoading } = useEventData();
const { data,isLoading } = useEventData();
const rootRef = useRef();
// const [data, setData] = useState([]);
// const binId = '650b2bb0205af66dd4a23cb4';
// const apiKey = '$2a$10$ALWgRdFMPxMOF8WhLWbVmuC1Q.mfj6P/O1CvmwCXLT9LRC4HM6Woq';
// useEffect(() => {
// const fetchData = async () => {
// try {
// const response = await fetch(`https://api.jsonbin.io/v3/b/${binId}/latest`, {
// headers: {
// 'X-Master-Key': apiKey,
// },
// });


// if (response.ok) {
// const jsonData = await response.json();
// setData(jsonData.record.events);
// console.log(data)
// // console.log(data.record.events)
// } else {
// console.error(`Failed to fetch data. Status code: ${response.status}`);
// }
// } catch (error) {
// console.error('Error:', error);
// }
// };

// fetchData();
// },[]);
const [games, setData] = useState([]);
const binId = '650b2bb0205af66dd4a23cb4';
const apiKey = '$2a$10$ALWgRdFMPxMOF8WhLWbVmuC1Q.mfj6P/O1CvmwCXLT9LRC4HM6Woq';
useEffect(() => {
const fetchData = async () => {
try {
const response = await fetch(`https://api.jsonbin.io/v3/b/${binId}/latest`, {
headers: {
'X-Master-Key': apiKey,
},
});


if (response.ok) {
const jsonData = await response.json();
setData(jsonData.record.events);
console.log(data)
// console.log(data.record.events)
} else {
console.error(`Failed to fetch data. Status code: ${response.status}`);
}
} catch (error) {
console.error('Error:', error);
}
};

fetchData();
},[]);

return (
<Box ref={rootRef} sx={{ backgroundColor: 'black' }}>
Expand All @@ -180,6 +182,17 @@ const Events = () => {
{
isLoading ? <Skeleton width='100%' height='200px'/> : <EmblaCarousel gap="20px">
{data.map((_, index) => (
<Event link={_.registrationLink} name={`${_.title}`} description={`${_.description}`} img={`${_.image}`} />
))}
</EmblaCarousel>

}
<br />
<Heading>Gaming events</Heading>
<br />
{
isLoading ? <Skeleton width='100%' height='200px'/> : <EmblaCarousel gap="20px">
{games.map((_, index) => (
<Event name={`${_.title}`} description={`${_.description}`} img={`${_.image}`} />
))}
</EmblaCarousel>
Expand Down