Skip to content
This repository was archived by the owner on Sep 25, 2025. It is now read-only.

feat: chapters dropdown event create - #1430

Merged
ojeytonwilliams merged 5 commits into
freeCodeCamp:mainfrom
gikf:feat/chapters-dropdown-event-create
Aug 22, 2022
Merged

ojeytonwilliams merged 5 commits into
freeCodeCamp:mainfrom
gikf:feat/chapters-dropdown-event-create

Conversation

@gikf

@gikf gikf commented Aug 21, 2022

Copy link
Copy Markdown
Member
  • I have read Chapter's contributing guidelines.
  • My pull request has a descriptive title (not a vague title like Update README.md).
  • My pull request targets the main branch of Chapter.

Closes #1215


  • Adds general Add new button on the events dashboard, leading to /dashboard/events/new route, with add event form including chapters dropdown.
  • Dropdown uses user admined_chapters array. This can be a bit weird, as permission required for admining chapter - ChapterEdit is not the permission required for adding new events - EventCreate.
  • Add new Button is visible only to those with permission to admin chapter.
  • The bulk of the changed lines in components/EventForm.tsx is due to removal of blank dummy parent element and dedenting the whole form.

@gikf
gikf requested a review from a team August 21, 2022 18:19
@gitpod-io

gitpod-io Bot commented Aug 21, 2022

Copy link
Copy Markdown

@ghost

ghost commented Aug 21, 2022 •

Copy link
Copy Markdown
👇 Click on the image for a new way to code review
  • Make big changes easier — review code in small groups of related files

  • Know where to start — see the whole change at a glance

  • Take a code tour — explore the change with an interactive tour

  • Make comments and review — all fully sync’ed with github

    Try it now!

Review these changes using an interactive CodeSee Map

Legend

CodeSee Map Legend

@ojeytonwilliams ojeytonwilliams left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I agree that admined_chapters is a bit odd, since it's the wrong permission, but I think it's fine for the MVP. I've tracked it in #1435

Comment on lines +129 to +144
const {
loading: loadingVenues,
error: errorVenues,
data: dataVenues,
} = useChapterVenuesQuery({ variables: { chapterId: chapter } });

useEffect(() => {
resetField('chapter_id', { defaultValue: adminedChapters[0]?.id ?? -1 });
}, [adminedChapters]);

useEffect(() => {
resetField('venue_id', {
defaultValue:
defaultValues.venue_id ?? dataVenues?.chapterVenues[0]?.id ?? -1,
});
}, [dataVenues]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's a bit out of scope of this PR, but this got me thinking: could we avoid resetting if we pulled the data fetching up into the parent compoenent? i.e. don't create the form until we have all the data and so avoid setting the wrong defaultValue.

@gikf gikf Aug 22, 2022 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

For venues problem would be fact venues belong to chapter. Unless all venues, for corresponding possible admined chapters, are loaded before rendering form, there's bound to be setting default when dataVenues changes, after selected chapter changed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That's a shame, but it sounds like some amount of resetting is inevitable. Oh well.

Co-authored-by: Oliver Eyton-Williams <[email protected]>

@ojeytonwilliams ojeytonwilliams left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Alrighty, this LGTM 👍 Thanks @gikf!

@ojeytonwilliams
ojeytonwilliams merged commit 284ed6b into freeCodeCamp:main Aug 22, 2022
@gikf
gikf deleted the feat/chapters-dropdown-event-create branch August 23, 2022 07:35
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Event and Venue creation pages

3 participants