-
Notifications
You must be signed in to change notification settings - Fork 9
feat: Add Activity & Tasks section to Tracker Dawer #215
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
Merged
victoriatran17
merged 2 commits into
BobaTalks:main
from
JennaXiao3:jenna/activity-task-section
Sep 18, 2025
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 hidden or 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
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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,110 @@ | ||
| import AddRoundedIcon from '@mui/icons-material/AddRounded'; | ||
| import { | ||
| Timeline, | ||
| TimelineConnector, | ||
| TimelineContent, | ||
| TimelineDot, | ||
| TimelineItem, | ||
| TimelineOppositeContent, | ||
| TimelineSeparator, | ||
| } from '@mui/lab'; | ||
| import { Button } from '@mui/material'; | ||
| import React, { useEffect, useState } from 'react'; | ||
|
|
||
| import { getActivitiesByTrackedInternshipId } from '../utils/api'; | ||
| import { addActivity } from '../utils/api'; | ||
| import TrackedActivityRow from './TrackedActivityRow'; | ||
|
|
||
| const TrackedActivity = ({ trackedInternshipId }) => { | ||
| const [activity, setActivity] = useState([]); | ||
| const [isActivityUpdated, setIsActivityUpdated] = useState(true); | ||
|
|
||
| const addEvent = async () => { | ||
| try { | ||
| // By setting the title to an empty string, the added event will default to edit mode | ||
| await addActivity(trackedInternshipId, '', null); | ||
| setIsActivityUpdated(true); | ||
| } catch (err) { | ||
| console.error('Error adding activity:', err); | ||
| } | ||
| }; | ||
|
|
||
| useEffect(() => { | ||
| const fetchActivities = async () => { | ||
| if (trackedInternshipId) { | ||
| try { | ||
| const allActivity = await getActivitiesByTrackedInternshipId( | ||
| trackedInternshipId | ||
| ); | ||
| setActivity(allActivity); | ||
| } catch (error) { | ||
| console.error('Error getting internship activity.', error); | ||
| } | ||
| } | ||
| }; | ||
|
|
||
| if (isActivityUpdated) { | ||
| fetchActivities(); | ||
| setIsActivityUpdated(false); | ||
| } | ||
| }, [trackedInternshipId, isActivityUpdated]); | ||
JennaXiao3 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| return ( | ||
| <> | ||
| {activity.length > 0 && ( | ||
| <Timeline sx={{ p: 0, m: 0 }}> | ||
| {activity.map((event, index) => ( | ||
| <TimelineItem sx={{ minHeight: '3.2rem' }} key={event.id}> | ||
| <TimelineOppositeContent | ||
| sx={{ flex: 0 }} | ||
| ></TimelineOppositeContent> | ||
| <TimelineSeparator> | ||
| <TimelineDot | ||
| variant="outlined" | ||
| sx={{ | ||
| borderColor: 'tertiary.main', | ||
| backgroundColor: | ||
| event.date == null || new Date(event.date) > new Date() | ||
| ? 'white' | ||
| : 'background.dark', | ||
| width: '1.1rem', | ||
| height: '1.1rem', | ||
| marginY: '.5rem', | ||
| }} | ||
| /> | ||
| {index < activity.length - 1 && ( | ||
| <TimelineConnector | ||
| sx={{ | ||
| borderColor: 'background.dark', | ||
| borderStyle: 'dashed', | ||
| backgroundColor: 'white', | ||
| borderWidth: 1, | ||
| }} | ||
| /> | ||
| )} | ||
| </TimelineSeparator> | ||
| <TimelineContent sx={{ m: 0, p: 0 }}> | ||
| <TrackedActivityRow | ||
| event={event} | ||
| onEventUpdated={() => setIsActivityUpdated(true)} | ||
| defaultEditMode={!event.title} | ||
| /> | ||
| </TimelineContent> | ||
| </TimelineItem> | ||
| ))} | ||
| </Timeline> | ||
| )} | ||
| <Button | ||
| variant="rounded" | ||
| color="primary" | ||
| onClick={addEvent} | ||
| startIcon={<AddRoundedIcon />} | ||
| sx={{ mb: '1rem', mt: '.5rem' }} | ||
| > | ||
| Add task | ||
| </Button> | ||
| </> | ||
| ); | ||
| }; | ||
|
|
||
| export default TrackedActivity; | ||
This file contains hidden or 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,121 @@ | ||
| import CheckCircleRoundedIcon from '@mui/icons-material/CheckCircleRounded'; | ||
| import DeleteRoundedIcon from '@mui/icons-material/DeleteRounded'; | ||
| import EditRoundedIcon from '@mui/icons-material/EditRounded'; | ||
| import { IconButton, Stack, TextField, Typography } from '@mui/material'; | ||
| import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns'; | ||
| import { DatePicker } from '@mui/x-date-pickers/DatePicker'; | ||
| import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider'; | ||
| import React, { useState } from 'react'; | ||
|
|
||
| import { deleteActivity, editActivity } from '../utils/api'; | ||
|
|
||
| const TEXT_FIELD_STYLE = { | ||
| '& .MuiInputBase-input': { | ||
| fontSize: '0.9rem', | ||
| fontWeight: 200, | ||
| }, | ||
| '& .MuiInputLabel-root': { | ||
| fontSize: '0.9rem !important', | ||
| fontWeight: 200, | ||
| }, | ||
| '& .MuiInputLabel-shrink': { | ||
| fontWeight: 200, | ||
| }, | ||
| }; | ||
|
|
||
| const TrackedActivityRow = ({ | ||
| event, | ||
| onEventUpdated, | ||
| defaultEditMode = false, | ||
| }) => { | ||
| const [isEditMode, setIsEditMode] = useState(defaultEditMode); | ||
| const [title, setTitle] = useState(event.title); | ||
| const [date, setDate] = useState(event.date); | ||
|
|
||
| const updateEvent = async () => { | ||
| try { | ||
| await editActivity(event.id, title, date); | ||
| setIsEditMode(false); | ||
| } catch (err) { | ||
| console.error('Error updating activity:', err); | ||
| } | ||
| onEventUpdated(); | ||
| }; | ||
|
|
||
| const deleteEvent = async () => { | ||
| try { | ||
| await deleteActivity(event.id); | ||
| } catch (err) { | ||
| console.error('Error deleting activity:', err); | ||
| } | ||
| onEventUpdated(); | ||
| }; | ||
|
|
||
| return ( | ||
| <LocalizationProvider dateAdapter={AdapterDateFns}> | ||
| <Stack | ||
| direction="row" | ||
| justifyContent="space-between" | ||
| alignItems="center" | ||
| paddingBottom="1rem" | ||
| paddingLeft="1rem" | ||
| borderRadius="1rem" | ||
| spacing={4} | ||
| > | ||
| {isEditMode ? ( | ||
| <TextField | ||
| label="Activity" | ||
| size="small" | ||
| fullWidth | ||
| value={title} | ||
| onChange={(event) => setTitle(event.target.value)} | ||
| sx={TEXT_FIELD_STYLE} | ||
| /> | ||
| ) : ( | ||
| <Typography variant="body3" fontWeight={200}> | ||
| {event.title} | ||
| </Typography> | ||
| )} | ||
| <Stack direction="row" alignItems="center" spacing={2} py={0}> | ||
| {isEditMode ? ( | ||
| <DatePicker | ||
| label="Date" | ||
| value={date} | ||
| onChange={(newDate) => setDate(newDate)} | ||
| renderInput={(params) => ( | ||
| <TextField | ||
| {...params} | ||
| size="small" | ||
| sx={{ | ||
| ...TEXT_FIELD_STYLE, | ||
| minWidth: '9.5rem', | ||
| }} | ||
| /> | ||
| )} | ||
| /> | ||
| ) : ( | ||
| <Typography variant="body3" color="text.light" fontWeight={200}> | ||
| {event.date ? new Date(event.date).toLocaleDateString() : ''} | ||
| </Typography> | ||
| )} | ||
| <Stack direction="row" py={0}> | ||
| {isEditMode ? ( | ||
| <IconButton onClick={updateEvent}> | ||
| <CheckCircleRoundedIcon fontSize="small" /> | ||
| </IconButton> | ||
| ) : ( | ||
| <IconButton onClick={() => setIsEditMode(true)}> | ||
| <EditRoundedIcon fontSize="small" /> | ||
| </IconButton> | ||
| )} | ||
| <IconButton onClick={deleteEvent}> | ||
| <DeleteRoundedIcon fontSize="small" /> | ||
| </IconButton> | ||
| </Stack> | ||
| </Stack> | ||
| </Stack> | ||
| </LocalizationProvider> | ||
| ); | ||
| }; | ||
|
|
||
| export default TrackedActivityRow; |
This file contains hidden or 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 hidden or 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.
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.
Updated the node version of frontendtests Github Action since I'm using "@mui/lab" and "@mui/x-date-pickers", which require at least node v16. Although they use the same MUI version (v5), they have stricter deps than "@mui/materal", so the node version used to run the tests needs to be updated