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

Issue 1542/refactor EVENTS into hooks #1585

Conversation

rebecarubio
Copy link
Contributor

@rebecarubio rebecarubio commented Oct 12, 2023

Description

This PR refactors all Event Models into hooks

Changes

  • Removes EventDataModel, EventTypesModel, EventsModel and LocationsModel
  • Removes ZUISpeedDial and /TaskList
  • Adds useAllEvents (will be removed when mergin Campaigns hook)
  • Adds useDuplicateEvent
  • Adds useEventContact
  • Adds useEvent and useEventMutations
  • Adds useEventLocations and useEventLocationsMutations
  • Adds useEventParticipants and useEventParticipantsMutations
  • Adds useEventState
  • Adds useEventTypes
  • Adds useEventsMutations
  • Adds useParallelEvents
  • Adds useParticipantsStatus
  • Adds useRelatedEvents
  • Adds useCreateType
  • Adds useCreateEvent
  • Changes all references from old event models to the new hooks and implements relevant changes

Notes to reviewer

Repo file will be removed in another PR.
useAllEvents hook is used only by AllCampaignsSummaryPage and it will be removed after merge Campaigns refactor PR #1586

Related issues

Part of issue 1542

…r on hooks and implement changes in components
…ypes definitions ZetkinEventPatchBody and ZetkinEventPostBody
@rebecarubio rebecarubio changed the title WIP Issue 1542/refactor events into hooks Issue 1542/refactor EVENTS into hooks Oct 13, 2023
@rebecarubio rebecarubio marked this pull request as ready for review October 13, 2023 09:23
Copy link
Member

@richardolsson richardolsson left a comment

Choose a reason for hiding this comment

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

Amazing work on this major refactor! I think the code looks mostly great. I did find some opportunities for optimization (loading only necessary events instead of loading all of them) and also some design decisions that I don't fully agree with.

I especially think we need as a team to talk about:

  • Should mutation hooks take the ID of the object they're meant to mutate in the hook, or in the mutation functions? (I prefer the former)
  • Should hooks that load data generally return a future or an object containing a future (and if so, should it be called e.g. eventFuture or just event)?
  • Where do we put "create" actions, i.e. mutations that create a new object on the server? They don't quite fit in the normal mutation hooks (which are for a single, already existing object) nor in the plural hooks, because we don't want to retrieve data before creating. Maybe a separate hook, e.g. useCreateEventType() etc?

src/zui/ZUISpeedDial/actions/createEvent.tsx Show resolved Hide resolved
src/features/events/layout/EventLayout.tsx Outdated Show resolved Hide resolved
src/features/events/hooks/useRelatedEvents.ts Outdated Show resolved Hide resolved
src/features/events/hooks/useDuplicateEvent.ts Outdated Show resolved Hide resolved
src/features/events/components/EventPopper/SingleEvent.tsx Outdated Show resolved Hide resolved
src/features/events/components/EventTypeAutocomplete.tsx Outdated Show resolved Hide resolved
src/features/events/components/EventActionButtons.tsx Outdated Show resolved Hide resolved
src/features/events/components/EventOverviewCard/index.tsx Outdated Show resolved Hide resolved
…atus to set participant status and inplement changes
Copy link
Member

@richardolsson richardolsson left a comment

Choose a reason for hiding this comment

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

Awesome work on this massive PR! It's very big, so I might have missed something, but the code looks good to me. I haven't tested it, but if it's working as expected, I think it can be merged.

@rebecarubio rebecarubio merged commit a2cb85e into issue-1542/refactor-to-use-hooks Oct 24, 2023
4 checks passed
@rebecarubio rebecarubio deleted the issue-1542/refactor-events-into-hooks branch October 24, 2023 06:10
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.

2 participants