fix: add missing file remove calls from inventory popup#1002
Conversation
Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>
📝 WalkthroughWalkthroughThis 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. ChangesImage deletion feature
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
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>
There was a problem hiding this comment.
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 winCall
saveItemImageshere —saveImagesis undefined in this module, so this branch throws aReferenceErrorafter the POST succeeds and skips the success snackbar/return flow. PassformId,response.id, and the images array tosaveItemImagesinstead.🤖 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
📒 Files selected for processing (7)
src/actions/sponsor-forms-actions.jssrc/pages/sponsors-global/form-templates/form-template-item-list-page.jssrc/pages/sponsors-global/form-templates/sponsor-inventory-popup.jssrc/pages/sponsors-global/inventory/inventory-list-page.jssrc/pages/sponsors/sponsor-form-item-list-page/components/sponsor-form-item-form.jssrc/pages/sponsors/sponsor-form-item-list-page/components/sponsor-form-item-popup.jssrc/pages/sponsors/sponsor-page/tabs/sponsor-forms-tab/components/manage-items/sponsor-forms-manage-items.js
Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>
Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>
There was a problem hiding this comment.
🧹 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
removeItemFilemissing 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
📒 Files selected for processing (1)
src/pages/sponsors/sponsor-form-item-list-page/components/sponsor-form-item-popup.js
ref: https://app.clickup.com/t/9014802374/86bakf3mp
Signed-off-by: Tomás Castillo tcastilloboireau@gmail.com
Summary by CodeRabbit