From e60e37dc44060c6c13153caea2aa09fcf5ed97fd Mon Sep 17 00:00:00 2001 From: Suraj Rane Date: Wed, 12 Aug 2020 13:06:50 +0530 Subject: [PATCH 1/2] Added Opensource Index page with Carousel card, Section descriptions & Community events section --- src/components/layout/Navbar.js | 5 + src/components/opensource/communityEvents.jsx | 80 +++++++++++ src/components/opensource/imageCarousel.jsx | 77 ++++++++++ src/components/opensource/index.jsx | 60 ++++++++ src/components/opensource/sectionFragment.jsx | 135 ++++++++++++++++++ src/components/opensource/videoCarousel.jsx | 28 ++++ src/layout.js | 2 + src/routeConstants.js | 1 + 8 files changed, 388 insertions(+) create mode 100644 src/components/opensource/communityEvents.jsx create mode 100644 src/components/opensource/imageCarousel.jsx create mode 100644 src/components/opensource/index.jsx create mode 100644 src/components/opensource/sectionFragment.jsx create mode 100644 src/components/opensource/videoCarousel.jsx diff --git a/src/components/layout/Navbar.js b/src/components/layout/Navbar.js index 91ca2151..b977aeb8 100644 --- a/src/components/layout/Navbar.js +++ b/src/components/layout/Navbar.js @@ -75,6 +75,11 @@ Component.defaultProps = { title: "Success Stories", url: routes.SUCCESS_STORIES_URL }, + { + id: 10, + title: "Open Source", + url: routes.OPEN_SOURCE_URL + }, { id: 5, title: "Blogs", diff --git a/src/components/opensource/communityEvents.jsx b/src/components/opensource/communityEvents.jsx new file mode 100644 index 00000000..0601319b --- /dev/null +++ b/src/components/opensource/communityEvents.jsx @@ -0,0 +1,80 @@ +import React, { useState, useEffect } from "react"; +import { Spinner } from "reactstrap"; +import { API_BASE_URL } from "../../globalConstants"; + +const CommunityEvents = (props) => { + const [loading, setLoading] = useState(false); + const [events, setEvents] = useState([]); + + // helper function to fetch community events + const fetchEvents = () => { + setLoading(true); + return fetch(`${API_BASE_URL}community_events`, { + method: "GET", + headers: { + Accept: "application/json", + "Content-Type": "application/json", + }, + }).then((response) => response.json()); + }; + + // useEffect to fetch and store the events data + useEffect(() => { + const promise = fetchEvents(); + promise + .then((responseData) => { + setEvents(responseData.community_events); + setLoading(false); + }) + .catch((error) => console.log(error)); + }, []); + + return ( +
+
+

+ Organising Community Events +

+ {loading && ( +
+ +
+ )} + {loading === false && ( +
+ {events.map((event, index) => { + return ( +
+
+