-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change input type for volunteer log popup; Work on rendering coluntee… #72
Merged
Merged
Changes from 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
63c48b2
Change input type for volunteer log popup; Work on rendering coluntee…
buildwithmanish 4ef7365
Implement the submit button to add volunteer log record in database
manishacharya60 84356c6
Merge branch 'main' into volunteer-logs
JiashuHarryHuang 16213cb
Created a new component for SelectableLongEventCard
JiashuHarryHuang 77b4d2c
API user endpoint
manishacharya60 3568cba
Add events/user endpoint
JiashuHarryHuang 1ac51db
Make success and error handling more elegant
JiashuHarryHuang aed51ba
Optimize API endpoint and add a script for deleting all logs
JiashuHarryHuang f55d82c
Rename endpoint
JiashuHarryHuang f99cc1c
Move helper function to utils.ts
JiashuHarryHuang cb6f257
Update scripts
JiashuHarryHuang 2406014
Add comments to log-hour endpoint
JiashuHarryHuang 41cb862
Prettier
JiashuHarryHuang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ import { Media } from '@/lib/media'; | |
import { BOOKEM_THEME } from '@/utils/constants'; | ||
import { QueriedUserData } from 'bookem-shared/src/types/database'; | ||
import { formatDate } from '@/utils/utils'; | ||
import { message } from 'antd'; | ||
|
||
const VolunteerDashboard = ({ | ||
userData, | ||
|
@@ -29,12 +30,38 @@ const VolunteerDashboard = ({ | |
}) => { | ||
// set pop up window to false | ||
const [showPopup, setShowPopup] = useState(false); | ||
const [messageApi, contextHolder] = message.useMessage(); | ||
|
||
// Display success message | ||
const successMessage = (message: string) => { | ||
messageApi.open({ | ||
type: 'success', | ||
content: message, | ||
}); | ||
}; | ||
|
||
// Display error message | ||
const errorMessage = (message: string) => { | ||
messageApi.open({ | ||
type: 'error', | ||
content: message, | ||
}); | ||
}; | ||
Comment on lines
+35
to
+49
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use antd message here to display success/error message in frontend. |
||
|
||
return ( | ||
<> | ||
<DashboardContainer> | ||
{/* Context for antd messages */} | ||
{contextHolder} | ||
|
||
{/* based on whether or not hideppopup is true, displays popup */} | ||
{showPopup && <LogHoursPopupWindowForm setShowPopup={setShowPopup} />} | ||
{showPopup && ( | ||
<LogHoursPopupWindowForm | ||
successMessage={successMessage} | ||
errorMessage={errorMessage} | ||
setShowPopup={setShowPopup} | ||
/> | ||
)} | ||
|
||
<Greeting>Volunteer</Greeting> | ||
|
||
|
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
When we get the response from backend, we need to decide whether it's a success or a failure.