Skip to content

fix: add missing file remove calls from inventory popup#1002

Open
tomrndom wants to merge 4 commits into
masterfrom
fix/form-image-delete
Open

fix: add missing file remove calls from inventory popup#1002
tomrndom wants to merge 4 commits into
masterfrom
fix/form-image-delete

Conversation

@tomrndom

@tomrndom tomrndom commented Jul 1, 2026

Copy link
Copy Markdown

ref: https://app.clickup.com/t/9014802374/86bakf3mp

Signed-off-by: Tomás Castillo tcastilloboireau@gmail.com

Summary by CodeRabbit

  • New Features
    • Added image-deletion support throughout sponsor-related item dialogs, including sponsor form items, managed sponsor form items, inventory items, and form template items.
    • Updated upload dialogs to accept an image-deleted callback so deletions propagate from the UI consistently.
  • Bug Fixes
    • Improved customized form item image loading by ensuring images are included in returned results.
    • Ensured images for managed form items are saved immediately after the item is created/updated to prevent missing attachments.

Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>
@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds sponsor form and inventory image deletion actions, expands customized form item image fetching, saves images after managed item creation, and wires image-deletion callbacks through shared dialogs and page containers.

Changes

Image deletion feature

Layer / File(s) Summary
Delete image actions and save flow
src/actions/sponsor-forms-actions.js
Adds delete-image constants and thunks, expands customized form item image fetching, and saves item images after managed item creation.
Upload dialog deletion callbacks
src/pages/sponsors-global/form-templates/sponsor-inventory-popup.js, src/pages/sponsors/sponsor-form-item-list-page/components/sponsor-form-item-form.js
Adds onImageDeleted support in the shared dialog and form components, and routes upload delete events through those callbacks.
Page-level delete wiring
src/pages/sponsors/sponsor-form-item-list-page/components/sponsor-form-item-popup.js, src/pages/sponsors-global/form-templates/form-template-item-list-page.js, src/pages/sponsors-global/inventory/inventory-list-page.js, src/pages/sponsors/sponsor-page/tabs/sponsor-forms-tab/components/manage-items/sponsor-forms-manage-items.js
Adds page callbacks that delete the current item image and wires them into dialogs and Redux connect props.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Page
  participant Dialog
  participant ReduxAction

  Page->>Dialog: onImageDeleted(imageId)
  Dialog->>ReduxAction: call delete thunk with item id + image id
  ReduxAction-->>Page: loading and deleted state updates
Loading

Possibly related PRs

  • fntechgit/summit-admin#786: Both PRs touch src/pages/sponsors-global/form-templates/sponsor-inventory-popup.js within SponsorItemDialog—one refactors the image value/filename formatting for UploadInputV2, while the other adds onImageDeleted plumbing to trigger image deletion.

Suggested reviewers: smarcet

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main change: wiring missing file/image removal calls into the inventory popup and related flows.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/form-image-delete

Comment @coderabbitai help to get the list of available commands.

Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>
@tomrndom tomrndom marked this pull request as ready for review July 9, 2026 12:38

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/actions/sponsor-forms-actions.js (1)

1448-1465: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Call saveItemImages heresaveImages is undefined in this module, so this branch throws a ReferenceError after the POST succeeds and skips the success snackbar/return flow. Pass formId, response.id, and the images array to saveItemImages instead.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/actions/sponsor-forms-actions.js` around lines 1448 - 1465, The success
branch in the sponsor form item save flow is calling an undefined saveImages
helper, which causes a ReferenceError after the POST succeeds. Update the
promise chain in the action that handles the POST response to use saveItemImages
instead, and pass the formId, response.id, and the images array so the success
snackbar and return flow complete normally.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/actions/sponsor-forms-actions.js`:
- Around line 1627-1649: The removeSponsorCustomizedFormItemImages action is
using the whole-item deletion action for an image-only endpoint, which can cause
the item row to be removed instead of just the image. Update the deleteRequest
callback in removeSponsorCustomizedFormItemImages to dispatch a dedicated
image-delete action (or add one if missing) and ensure
sponsor-customized-form-items-list-reducer.js handles that image-specific action
separately from SPONSOR_CUSTOMIZED_FORM_ITEM_DELETED.

In `@src/pages/sponsors-global/form-templates/sponsor-inventory-popup.js`:
- Around line 87-90: The optional onImageDeleted callback is being invoked
unconditionally in handleIDeleteImage, which can throw when the prop is omitted.
Update handleIDeleteImage in sponsor-inventory-popup.js to guard the callback
before calling it, keeping the image id check but only invoking onImageDeleted
when it is defined.

In
`@src/pages/sponsors/sponsor-form-item-list-page/components/sponsor-form-item-form.js`:
- Around line 60-63: `handleDeleteImage` in `SponsorFormItemForm` should
defensively guard the `onImageDeleted` callback before calling it, since it may
be undefined like in the sibling `SponsorItemDialog`. Update the delete handler
to check that `onImageDeleted` exists alongside the `id` check, keeping the same
behavior when the callback is provided.

In
`@src/pages/sponsors/sponsor-form-item-list-page/components/sponsor-form-item-popup.js`:
- Around line 55-60: The dialog title in SponsorFormItemPopup includes leftover
debug text after the translated label, so remove the literal string from the
Typography block and keep only the T.translate result in the popup title. Use
the existing SponsorFormItemPopup component and its title rendering logic to
locate and clean up this stray text.

---

Outside diff comments:
In `@src/actions/sponsor-forms-actions.js`:
- Around line 1448-1465: The success branch in the sponsor form item save flow
is calling an undefined saveImages helper, which causes a ReferenceError after
the POST succeeds. Update the promise chain in the action that handles the POST
response to use saveItemImages instead, and pass the formId, response.id, and
the images array so the success snackbar and return flow complete normally.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 57ad779e-180d-41ad-9758-c88bd93dd6d4

📥 Commits

Reviewing files that changed from the base of the PR and between 05f5ba9 and ae76f55.

📒 Files selected for processing (7)
  • src/actions/sponsor-forms-actions.js
  • src/pages/sponsors-global/form-templates/form-template-item-list-page.js
  • src/pages/sponsors-global/form-templates/sponsor-inventory-popup.js
  • src/pages/sponsors-global/inventory/inventory-list-page.js
  • src/pages/sponsors/sponsor-form-item-list-page/components/sponsor-form-item-form.js
  • src/pages/sponsors/sponsor-form-item-list-page/components/sponsor-form-item-popup.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-forms-tab/components/manage-items/sponsor-forms-manage-items.js

Comment thread src/actions/sponsor-forms-actions.js
Comment thread src/pages/sponsors-global/form-templates/sponsor-inventory-popup.js
tomrndom added 2 commits July 9, 2026 09:53
Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>
Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/pages/sponsors/sponsor-form-item-list-page/components/sponsor-form-item-popup.js (1)

74-81: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

removeItemFile missing from propTypes.

The prop is destructured and used at Line 29/46 but not declared in propTypes, unlike the other injected action props.

🐛 Proposed fix
 SponsorFormItemPopup.propTypes = {
   open: PropTypes.bool.isRequired,
   onClose: PropTypes.func.isRequired,
   formId: PropTypes.string.isRequired,
   resetSponsorFormItem: PropTypes.func.isRequired,
   saveSponsorFormItem: PropTypes.func.isRequired,
-  updateSponsorFormItem: PropTypes.func.isRequired
+  updateSponsorFormItem: PropTypes.func.isRequired,
+  removeItemFile: PropTypes.func.isRequired
 };
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/pages/sponsors/sponsor-form-item-list-page/components/sponsor-form-item-popup.js`
around lines 74 - 81, The SponsorFormItemPopup component is using the
removeItemFile prop but it is missing from its propTypes declaration. Update
SponsorFormItemPopup.propTypes to include removeItemFile alongside the other
injected action props so the component’s expected props match the destructuring
and usage in SponsorFormItemPopup.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In
`@src/pages/sponsors/sponsor-form-item-list-page/components/sponsor-form-item-popup.js`:
- Around line 74-81: The SponsorFormItemPopup component is using the
removeItemFile prop but it is missing from its propTypes declaration. Update
SponsorFormItemPopup.propTypes to include removeItemFile alongside the other
injected action props so the component’s expected props match the destructuring
and usage in SponsorFormItemPopup.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9041e12b-b634-4ccf-855c-df050b4cb506

📥 Commits

Reviewing files that changed from the base of the PR and between 39221f4 and d27136e.

📒 Files selected for processing (1)
  • src/pages/sponsors/sponsor-form-item-list-page/components/sponsor-form-item-popup.js

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.

1 participant