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

Events v2: implement delete action for action menu, make sure delete works in the form three dot menu #8297

Merged
merged 5 commits into from
Jan 7, 2025

Conversation

rikukissa
Copy link
Member

No description provided.

Copy link

github-actions bot commented Jan 7, 2025

Oops! Looks like you forgot to update the changelog. When updating CHANGELOG.md, please consider the following:

  • Changelog is read by country implementors who might not always be familiar with all technical details of OpenCRVS. Keep language high-level, user friendly and avoid technical references to internals.
  • Answer "What's new?", "Why was the change made?" and "Why should I care?" for each change.
  • If it's a breaking change, include a migration guide answering "What do I need to do to upgrade?".

@@ -27,7 +35,12 @@ function waitUntilEventIsCreated<R>(
}

utils.event.delete.setMutationDefaults(({ canonicalMutationFn }) => ({
retry: true,
retry: (_, error) => {
if (error.data?.httpStatus === 404 || error.data?.httpStatus === 400) {
Copy link
Member Author

Choose a reason for hiding this comment

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

This stops the event deletion from retrying if the endpoint returned with 404 (event most likely already removed) or 400 (it can't be deleted)

<DropdownMenu.Item
key={action.type}
onClick={() => {
if (action.type === 'CREATE' || action.type === 'CUSTOM') {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We could use enum here as agreed

packages/client/src/v2-events/trpc.tsx Outdated Show resolved Hide resolved
import { ROUTES } from '@client/v2-events/routes'
import { useEvents } from '@client/v2-events/features/events/useEvents/useEvents'

export function DeleteEvent() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could this be a method instead of component? deleteEvent.mutate({ eventId }) takes options as second parameter, and it navigation could be provided as onSuccess callback.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, I see. If the abstraction works. We might want to add a comment here the reason for opting for component-pattern.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Since this is now url accessible by anyone, does backend prevent from deleting non-draft items?

Copy link
Member Author

Choose a reason for hiding this comment

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

It does yea 👍

@rikukissa rikukissa merged commit 4ed93eb into develop Jan 7, 2025
38 of 39 checks passed
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