diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d6fb49dfd97..7cd3367b729 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,10 +25,8 @@ jobs: with: node-version: "${{ matrix.node-version }}" - - name: Build - run: | - npm install - npm run build + - name: Install + run: npm ci - name: Setup environment run: gpg --quiet --batch --yes --decrypt --passphrase="$PASSPHRASE" --output calendar-service-account.json calendar-service-account.json.gpg @@ -38,9 +36,12 @@ jobs: - name: Get events from Google API run: npm run getEvents + - name: Build + run: npm run build + - name: Add CNAME in dist folder run: cp CNAME dist - + - name: Deploy to GitHub Pages uses: peaceiris/actions-gh-pages@v3 with: diff --git a/README.md b/README.md index ff669061285..80a6056c28c 100644 --- a/README.md +++ b/README.md @@ -43,8 +43,6 @@ Create a new directory named `dist` in the root directory and run : npm run getEvents ``` -Copy `events.json` from `dist` to root directory. - ### Run development server ```bash diff --git a/package-lock.json b/package-lock.json index 3e3a70731f9..753770cbee3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,6 +20,7 @@ "@mdi/react": "^1.6.1", "googleapis": "^133.0.0", "html-react-parser": "^5.0.7", + "prop-types": "^15.8.1", "react": "^18.2.0", "react-dom": "^18.2.0" }, diff --git a/package.json b/package.json index ba22724886e..b4aec5e606c 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "@mdi/react": "^1.6.1", "googleapis": "^133.0.0", "html-react-parser": "^5.0.7", + "prop-types": "^15.8.1", "react": "^18.2.0", "react-dom": "^18.2.0" }, diff --git a/src/App.jsx b/src/App.jsx index 5ca40a21225..bdfd6821790 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -9,7 +9,9 @@ import { mdiCalendarRange, mdiClose, mdiMapMarkerOutline } from '@mdi/js'; import Icon from '@mdi/react'; import parse from 'html-react-parser'; import { createRef, useCallback, useEffect, useMemo, useState } from 'react'; +import SearchHeader from './components/SearchHeader'; import useEscKey from './hooks/useEscKey'; +import eventData from '../dist/events.json'; import './App.css'; const htmlRegex = /<\/*html-blob>/; @@ -18,6 +20,9 @@ function App() { const calendarRef = createRef(); const eventDetailRef = createRef(); + const eventsArray = Array.from(eventData); + const [events, setEvents] = useState(eventsArray); + const [loading, setLoading] = useState(true); const [clickedEvent, setClickedEvent] = useState([]); const [showEventDetails, setShowEventDetails] = useState(false); @@ -65,6 +70,16 @@ function App() { setPopupPosition({ left: position.left + 'px', top: position.top + 'px' }); }; + const filterEvents = (searchTerm)=>{ + if(!searchTerm) return setEvents(eventsArray); //handles searchbox clear + let matchingEvents = eventsArray.filter((event) => { + const titleIncludes = event.title?.toLowerCase().includes(searchTerm.toLowerCase()); + const descriptionIncludes = event.description?.toLowerCase().includes(searchTerm.toLowerCase()); + return titleIncludes || descriptionIncludes; + }); + setEvents(matchingEvents); + }; + const handleEventClick = useCallback((clickInfo) => { window.outerWidth > 600 && createPopupPosition(clickInfo.jsEvent); setEventDetails(clickInfo.event); @@ -234,7 +249,7 @@ function App() { aspectRatio={aspectRatio} handleWindowResize={true} windowResize={windowResize} - events="events.json" + events={events} headerToolbar={{ left: 'prev,next today', center: 'title', @@ -249,11 +264,12 @@ function App() { loading={(isLoading) => setLoading(isLoading)} /> ), - [aspectRatio, initialView, calendarRef, handleEventClick] + [aspectRatio, initialView, calendarRef, handleEventClick, events] ); return (