Skip to content
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

Implement admin "select shift times" calendar #150

Merged
merged 18 commits into from
Mar 6, 2022

Conversation

7tint
Copy link
Member

@7tint 7tint commented Feb 18, 2022

Ticket link

Closes #102

Implementation description

  • Leveraged FullCalendar to create the admin shifts calendar.
  • To use the calendar:
    • Click to create a new event
    • Drag the bottom of the event card to change the length of the event
    • Click on the card to prompt deletion modal

Steps to test

  1. Navigate to http://localhost:3000/admin/posting/create/shifts and play around with the calendar!
  2. Feel free to add a console.log(events) in the code to check the output data

What should reviewers focus on?

  • Correct usage of FullCalendar
  • Intuitive feel to the calendar

Checklist

  • My PR name is descriptive and in imperative tense
  • My commit messages are descriptive and in imperative tense. My commits are atomic and trivial commits are squashed or fixup'd into non-trivial commits
  • I have run the appropriate linter(s)
  • I have requested a review from the PL, as well as other devs who have background knowledge on this PR or who will be building on top of this PR

@github-actions
Copy link

github-actions bot commented Feb 18, 2022

Visit the preview URL for this PR (updated for commit 959dce8):

https://sistering-dev--pr150-lambert-implement-ca-bcy6p2av.web.app

(expires Sun, 13 Mar 2022 06:23:07 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

newEvents.splice(i, 1);
break;
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optionally you could use newEvents.indexOf()

Copy link
Member

@sherryhli sherryhli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, thanks for fiddling around with CSS to get the correct styling! One main thing is to change events to a prop, the rest are just small nits.

Copy link
Member

@LenaNguyen LenaNguyen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just tested it out and the calendar looks sooo good! 🤩

@7tint
Copy link
Member Author

7tint commented Feb 27, 2022

Fixed up the details! Please let me know if there's anything else I can clean up 🛁

Copy link
Member

@sherryhli sherryhli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UI looks great but we do need to rework the state management a bit. Again, sorry for not catching this earlier and let me know if you have any questions!

};

const ShiftCalendar = ({ shifts }: ShiftCalendarProps): React.ReactElement => {
const [events, setEvents] = useState<Event[]>(shifts);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to lift the state up to the parent component (in this case it's CreatePostingShiftsPage and eventually it'll be CreatePostingShifts from #164 when merged). This is so that the create shifts component can update the posting context (global state) with shifts data along with other posting fields.

Sorry, I didn't completely think this through when I made my previous comment, but the change is a bit more involved than just adding a shifts prop. We need the parent component to maintain the events state and all functions for manipulating state (e.g. addEvent, changeEvent, deleteEvent) should be passed in as props (and defined in the parent). The event count state should similarly be maintained in the parent and a function for getting the next event ID should also be provided as a prop.

Let me know if any further clarification is needed!

@7tint 7tint requested a review from sherryhli March 4, 2022 02:17
@7tint 7tint force-pushed the lambert/implement-calendar-ui branch from 76ebc9f to 1b7f90f Compare March 4, 2022 02:21
sherryhli
sherryhli previously approved these changes Mar 6, 2022
Copy link
Member

@sherryhli sherryhli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome stuff! 🚀 Go ahead and merge if you need to unblock yourself, though there is a one-liner change needed

Co-authored-by: Sherry Li <sherryhli@users.noreply.github.com>
Copy link
Member

@sherryhli sherryhli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢🚢🚢

@7tint 7tint merged commit 6b1ad2a into main Mar 6, 2022
@7tint 7tint deleted the lambert/implement-calendar-ui branch March 6, 2022 06:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Admin "Select Shift Times" Calendar - Implementation
3 participants