-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from sarthakpant772/master
Added Community Partners and Events
- Loading branch information
Showing
5 changed files
with
202 additions
and
159 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,137 +1,164 @@ | ||
import React, {useState, useEffect} from 'react'; | ||
import EventCard from './EventCard'; | ||
import React, { useState, useEffect } from "react"; | ||
import EventCard from "./EventCard"; | ||
import "./EventCard.scss"; | ||
import './Events.scss'; | ||
const axios = require('axios'); | ||
const cheerio = require('cheerio'); | ||
import "./Events.scss"; | ||
const axios = require("axios"); | ||
const cheerio = require("cheerio"); | ||
var pastEvents = [ | ||
{ | ||
id: "8", | ||
imgsrc: "SpeakerPromo.png", | ||
url: "https://www.youtube.com/watch?v=fu75vu6Nnnk", | ||
}, | ||
{ | ||
id: "1", | ||
imgsrc: "30days.jpeg", | ||
url: "", | ||
}, | ||
{ | ||
id: "2", | ||
imgsrc: "cloudComputing.jpeg", | ||
url: "https://www.youtube.com/watch?v=BTA_5GK3C_I", | ||
}, | ||
{ | ||
id: "3", | ||
imgsrc: "CodethonPoster.jpeg", | ||
url: "https://www.youtube.com/channel/UCsq-cbi1tZStoem3KVQVjCg/videos", | ||
}, | ||
{ | ||
id: "4", | ||
imgsrc: "codethon2.0.jpeg", | ||
url: "https://www.youtube.com/channel/UCsq-cbi1tZStoem3KVQVjCg/videos", | ||
}, | ||
{ | ||
id: "5", | ||
imgsrc: "cybersecurity.jpeg", | ||
url: "https://www.youtube.com/watch?v=3DzD_LBJCe4", | ||
}, | ||
{ | ||
id: "6", | ||
imgsrc: "gitGithub.jpeg", | ||
url: "https://www.youtube.com/watch?v=8jBivxwdizw&t=1502s", | ||
}, | ||
{ | ||
id: "7", | ||
imgsrc: "orientationPoster.jpeg", | ||
url: "", | ||
}, | ||
]; | ||
var upcommingEvents = []; | ||
var webdata = ""; | ||
|
||
async function getData() { | ||
await axios.get(url).then(res => { | ||
webdata = res.data; | ||
console.log("I am loaded") | ||
const $ = cheerio.load(webdata); | ||
if ($('#past-events .vertical-boxes a').attr('href') != undefined) { | ||
pastEvents = []; | ||
$('#past-events .vertical-boxes a:nth-child(n)').each((i, elem) => { | ||
// console.log($(elem).find('p.vertical-box--event-date').text()) | ||
pastEvents.push({ | ||
id: i + 1, | ||
link: 'https://dsc.community.dev/' + $(elem).attr('href'), | ||
date: $(elem).find('p.vertical-box--event-date').text().replace(/ |\n/g, ''), | ||
type: $(elem).find('p.vertical-box--event-type').text().replace(/ |\n/g, ''), | ||
title: $(elem).find('p.vertical-box--event-title').text().replace(/ |\n/g, ''), | ||
image: $(elem).find('img').attr('src') | ||
}) | ||
}); | ||
} | ||
else { | ||
pastEvents = []; | ||
pastEvents = $('#past-events .general-body--color').text(); | ||
} | ||
if ($('#upcoming-events .event-list a').attr('href') != undefined) { | ||
upcommingEvents = []; | ||
console.log("found"); | ||
$('#upcoming-events .event-list .row:nth-child(n)').each((i, elem) => { | ||
// console.log($(elem).find('p.vertical-box--event-date').text()) | ||
upcommingEvents.push({ | ||
id: i + 1, | ||
link: 'https://dsc.community.dev/' + $(elem).find('a.picture').attr('href'), | ||
date: $(elem).find('div.date strong').text().replace(/ |\n/g, ''), | ||
type: $(elem).find('div.date span').text().replace(/ |\n/g, ''), | ||
title: $(elem).find('h4.general-body--color').text().replace(/ |\n/g, ''), | ||
image: $(elem).find('img').attr('src') | ||
}) | ||
}); | ||
} | ||
else { | ||
upcommingEvents = []; | ||
upcommingEvents = $('#upcoming-events .general-body--color').text(); | ||
} | ||
await axios | ||
.get(url) | ||
.then((res) => { | ||
webdata = res.data; | ||
console.log("I am loaded"); | ||
const $ = cheerio.load(webdata); | ||
if ($("#past-events .vertical-boxes a").attr("href") != undefined) { | ||
pastEvents = []; | ||
$("#past-events .vertical-boxes a:nth-child(n)").each((i, elem) => { | ||
// console.log($(elem).find('p.vertical-box--event-date').text()) | ||
pastEvents.push({ | ||
id: i + 1, | ||
link: "https://dsc.community.dev/" + $(elem).attr("href"), | ||
date: $(elem) | ||
.find("p.vertical-box--event-date") | ||
.text() | ||
.replace(/ |\n/g, ""), | ||
type: $(elem) | ||
.find("p.vertical-box--event-type") | ||
.text() | ||
.replace(/ |\n/g, ""), | ||
title: $(elem) | ||
.find("p.vertical-box--event-title") | ||
.text() | ||
.replace(/ |\n/g, ""), | ||
image: $(elem).find("img").attr("src"), | ||
}); | ||
}); | ||
} else { | ||
pastEvents = []; | ||
pastEvents = $("#past-events .general-body--color").text(); | ||
} | ||
if ($("#upcoming-events .event-list a").attr("href") != undefined) { | ||
upcommingEvents = []; | ||
console.log("found"); | ||
$("#upcoming-events .event-list .row:nth-child(n)").each((i, elem) => { | ||
// console.log($(elem).find('p.vertical-box--event-date').text()) | ||
upcommingEvents.push({ | ||
id: i + 1, | ||
link: | ||
"https://dsc.community.dev/" + | ||
$(elem).find("a.picture").attr("href"), | ||
date: $(elem).find("div.date strong").text().replace(/ |\n/g, ""), | ||
type: $(elem).find("div.date span").text().replace(/ |\n/g, ""), | ||
title: $(elem) | ||
.find("h4.general-body--color") | ||
.text() | ||
.replace(/ |\n/g, ""), | ||
image: $(elem).find("img").attr("src"), | ||
}); | ||
}); | ||
} else { | ||
upcommingEvents = []; | ||
upcommingEvents = $("#upcoming-events .general-body--color").text(); | ||
} | ||
}) | ||
.catch(error => { | ||
console.log(error); | ||
}) | ||
.catch((error) => { | ||
console.log(error); | ||
}); | ||
} | ||
|
||
const url = "https://dsc.community.dev/jaypee-institute-of-information-technology-sec-128/"; | ||
const url = | ||
"https://dsc.community.dev/jaypee-institute-of-information-technology-sec-128/"; | ||
|
||
const EventsPage = ({isDark})=>{ | ||
const [pastData, setpastData] = useState(); | ||
const [upcomingData, setupcomingData] = useState(); | ||
useEffect(()=>{ | ||
getData().then(()=>{ | ||
setpastData(pastEvents); | ||
if(upcommingEvents[0].id) { | ||
setupcomingData(upcommingEvents); | ||
} | ||
}).catch((err)=>{ | ||
console.log(err); | ||
}) | ||
}, []); | ||
return ( | ||
<div id="events" class={isDark ? "eventsectionDark" : "pageEvent"}> | ||
<div className="eventsection"> | ||
<h1>Upcoming Events</h1> | ||
<div className="cards"> | ||
{ | ||
upcomingData ? upcomingData.map((event)=>{ | ||
return <EventCard | ||
imgsrc={event.image} | ||
/> | ||
}) : "There are no upcomming Events right now!!!" | ||
} | ||
</div> | ||
</div> | ||
<div className="eventsection"> | ||
<h1>Past Events</h1> | ||
<div className="cards"> | ||
{ | ||
pastData ? pastData.map((event)=>{ | ||
return ( | ||
<div className="eventCard" target="_blank"> | ||
<img | ||
src={require(`../../images/previousEvents/${event.imgsrc}`)} | ||
/> | ||
</div> | ||
); | ||
}) : null | ||
} | ||
</div> | ||
</div> | ||
const EventsPage = ({ isDark }) => { | ||
const [pastData, setpastData] = useState(); | ||
const [upcomingData, setupcomingData] = useState(); | ||
useEffect(() => { | ||
getData() | ||
.then(() => { | ||
setpastData(pastEvents); | ||
if (upcommingEvents[0].id) { | ||
setupcomingData(upcommingEvents); | ||
} | ||
}) | ||
.catch((err) => { | ||
console.log(err); | ||
}); | ||
}, []); | ||
return ( | ||
<div id="events" class={isDark ? "eventsectionDark" : "pageEvent"}> | ||
<div className="eventsection"> | ||
<h1>Upcoming Events</h1> | ||
<div className="cards"> | ||
{upcomingData | ||
? upcomingData.map((event) => { | ||
return <EventCard imgsrc={event.image} />; | ||
}) | ||
: "There are no upcomming Events right now!!!"} | ||
</div> | ||
); | ||
} | ||
</div> | ||
<div className="eventsection"> | ||
<h1>Past Events</h1> | ||
<div className="cards"> | ||
{pastData | ||
? pastData.map((event) => { | ||
return ( | ||
<a className="eventCard" href={event.url} target="_blank"> | ||
<img | ||
src={require(`../../images/previousEvents/${event.imgsrc}`)} | ||
/> | ||
</a> | ||
); | ||
}) | ||
: null} | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default EventsPage; | ||
export default EventsPage; |
Oops, something went wrong.