-
Notifications
You must be signed in to change notification settings - Fork 0
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 #72 from ChangePlusPlusVandy/volunteer-logs
Change input type for volunteer log popup; Work on rendering coluntee…
- Loading branch information
Showing
10 changed files
with
371 additions
and
97 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
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
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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import { QueriedVolunteerEventData } from 'bookem-shared/src/types/database'; | ||
import { fetchData } from '@/utils/utils'; | ||
import { MainContainer } from '@/styles/volunteerHistory.styles'; | ||
import SelectableLongEventCard from '../shared/SelectableLongEventCard'; | ||
|
||
/** | ||
* format horizontal upcoming event scroll bar on home page | ||
*/ | ||
const VolunteerSignedEvents = ({ | ||
selectedEvent, | ||
setSelectedEvent, | ||
}: { | ||
selectedEvent: QueriedVolunteerEventData | undefined; | ||
setSelectedEvent: React.Dispatch< | ||
React.SetStateAction<QueriedVolunteerEventData | undefined> | ||
>; | ||
}) => { | ||
const [events, setEvents] = useState<QueriedVolunteerEventData[]>(); | ||
const [error, setError] = useState<Error>(); | ||
|
||
const handleEventClick = (event: QueriedVolunteerEventData) => { | ||
// Update the selected event when an event is clicked | ||
setSelectedEvent(event); | ||
}; | ||
|
||
// Fetch upcoming events when rendered | ||
useEffect(() => { | ||
fetchData('/api/events/log-hour') | ||
.then(data => setEvents(data)) | ||
.catch(err => setError(err)); | ||
}, []); | ||
return ( | ||
<> | ||
{/* TODO: render 404 page */} | ||
{error && <>404 Event not found!</>} | ||
{!events && !error && <div>Loading...</div>} | ||
{events && ( | ||
<MainContainer> | ||
{/* Loop through each VolunteerEvent specific to that user */} | ||
{events.map(event => ( | ||
<SelectableLongEventCard | ||
eventData={event} | ||
key={event._id.toString()} | ||
isSelected={selectedEvent === event} | ||
onClick={() => handleEventClick(event)} | ||
/> | ||
))} | ||
</MainContainer> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
export default VolunteerSignedEvents; |
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
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 |
---|---|---|
@@ -0,0 +1,103 @@ | ||
import React from 'react'; | ||
import Image from 'next/image'; | ||
import { | ||
EventImage, | ||
Name, | ||
AddressContainer, | ||
AddressIcon, | ||
InfoContainer, | ||
Description, | ||
ClockIcon, | ||
Address, | ||
CalendarIcon, | ||
CheckmarkIcon, | ||
Container, | ||
} from '@/styles/components/longEventCard.styles'; | ||
import { QueriedVolunteerEventData } from 'bookem-shared/src/types/database'; | ||
import { convertLocationToString } from 'bookem-shared/src/utils/utils'; | ||
import { formatAMPM } from '@/utils/utils'; | ||
|
||
// this component takes in and displays all of an event's data | ||
const SelectableLongEventCard = ({ | ||
eventData, | ||
isSelected, | ||
onClick, | ||
}: { | ||
eventData: QueriedVolunteerEventData; | ||
isSelected: boolean; | ||
onClick: () => void; | ||
}) => { | ||
// create a date object with JavaScript's Date constructor | ||
const date = new Date(eventData.startDate); | ||
|
||
return ( | ||
<Container | ||
style={{ | ||
// Add styles for selected event | ||
border: isSelected ? '2px solid blue' : '1px solid #ddd', | ||
padding: '10px', | ||
cursor: 'pointer', | ||
}} | ||
onClick={onClick}> | ||
<EventImage> | ||
<Image | ||
src="/eventCard/event-image.png" | ||
alt="Event image icon" | ||
width={`${Math.round((300 / 328) * 53)}`} | ||
height={`${Math.round((300 / 328) * 53)}`} | ||
/> | ||
</EventImage> | ||
<Name>{eventData.name}</Name> | ||
|
||
<AddressContainer> | ||
<AddressIcon> | ||
<Image | ||
src="/eventCard/map.png" | ||
alt="Map icon" | ||
width={`${Math.round((300 / 328) * 21)}`} | ||
height={`${Math.round((300 / 328) * 23.99)}`} | ||
/> | ||
</AddressIcon> | ||
<Address>{convertLocationToString(eventData.location)}</Address> | ||
</AddressContainer> | ||
|
||
<InfoContainer> | ||
<CalendarIcon> | ||
<Image | ||
src="/event/calendar.png" | ||
alt="Calendar icon" | ||
width={`${Math.round((300 / 328) * 21)}`} | ||
height={`${Math.round((300 / 328) * 23.99)}`} | ||
/> | ||
{/* calls a JavaScript method to format the date into a readable format */} | ||
<Description>{date.toDateString()}</Description> | ||
</CalendarIcon> | ||
|
||
<ClockIcon> | ||
<Image | ||
src="/event/clock.png" | ||
alt="Clock icon" | ||
width={`${Math.round((300 / 328) * 21.27)}`} | ||
height={`${Math.round((300 / 328) * 22.14)}`} | ||
/> | ||
<Description>{formatAMPM(date)}</Description> | ||
</ClockIcon> | ||
|
||
<CheckmarkIcon> | ||
<Image | ||
src="/eventCard/checkmark.png" | ||
alt="Checkmark icon" | ||
width={`${Math.round((300 / 328) * 21)}`} | ||
height={`${Math.round((300 / 328) * 23.99)}`} | ||
/> | ||
<Description> | ||
{/* TODO: add data for number of books distributed*/}X books | ||
distributed | ||
</Description> | ||
</CheckmarkIcon> | ||
</InfoContainer> | ||
</Container> | ||
); | ||
}; | ||
|
||
export default SelectableLongEventCard; |
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
Oops, something went wrong.
084e0ce
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
bookem-user – ./
bookem-user-bookem-user.vercel.app
bookem-user.vercel.app
bookem-user-git-main-bookem-user.vercel.app