Skip to content

Feature: add frontend requirements for trashing donations #8011

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

Open
wants to merge 12 commits into
base: epic/donation-details-admin-page
Choose a base branch
from

Conversation

JoshuaHungDinh
Copy link
Contributor

@JoshuaHungDinh JoshuaHungDinh commented Jul 9, 2025

Resolves GIVE-2686

Description

This PR adds support for trashihng donations from the Overview page. It introduces a custom hook to handle the API call for deletion using the v3 api. The confirmation dialog opened by the row action "delete" on the DonationListTable has also been updated for parity & to enable trashing rather then permanent deletion.

Note: Can be tested with

Affects

Donation Overview page
Deleting Donations

Visuals

Testing Instructions

  • Create several donations.
  • From the DonationListTable hover over a donation row and select delete.
  • Verify the new wording and confirm delete.
  • Select edit on another donation.
  • From the top right settings select delete donation.
  • View the database and confirm that the donations have been moved to trash status.

Pre-review Checklist

  • Acceptance criteria satisfied and marked in related issue
  • Relevant @unreleased tags included in DocBlocks
  • Includes unit tests
  • Reviewed by the designer (if follows a design)
  • Self Review of code and UX completed

@JoshuaHungDinh JoshuaHungDinh changed the base branch from develop to epic/donation-details-admin-page July 9, 2025 04:19

try {
await apiFetch({
path: `give-api/v2/admin/donations/delete?ids=${donationId}`,
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a good way to get this working since it already exists - however, we should really be updating our v3 endpoint for delete functionality. Perhaps we can follow up on this UI focused PR with the updated endpoint functionality and swap this out.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jonwaldstein Yea there's also an issue with using wp_delete_post(id, false) it still deletes the post not trash it. I was eventually able to get it to work with wp_trash_post but could not pin down why the former would not trash it properly.

@JoshuaHungDinh JoshuaHungDinh changed the title Feature: Trash donations from Donation Overview page Feature: add frontend requirements for trashing donations Jul 10, 2025
@JoshuaHungDinh JoshuaHungDinh marked this pull request as ready for review July 15, 2025 13:26
try {
await deleteDonation(donation?.id);
setShowConfirmationDialog(null);
window.location.href = `${adminUrl}edit.php?post_type=give_forms&page=give-payment-history`;
Copy link
Contributor

Choose a reason for hiding this comment

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

this full url would be convenient to send through the window something like: donationsAdminUrl

Comment on lines +20 to +23
await apiFetch({
path: `/givewp/v3/donations/${donationId}?force=${force}`,
method: 'DELETE',
});
Copy link
Contributor

Choose a reason for hiding this comment

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

I discovered we can use deleteEntityRecord here instead of fetch.

It will make a the DELETE request and we would include the force param.

There's a nifty little tutorial here on how to use it but it's pretty similiar to our other entity record usages

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