fix: presentation material form reset#1019
Conversation
📝 WalkthroughWalkthrough
ChangesEvent material form
Estimated code review effort: 4 (Complex) | ~45 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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/components/forms/event-material-form.js`:
- Around line 56-59: Update the mediaUploadsOpts mapping in the event material
form to safely handle an undefined event.type during initial render and
handleChangeMUType. Use the existing event data when available and fall back to
an empty list before calling map.
🪄 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: e7020f9e-94a8-4f9a-a171-d874adb218dc
📒 Files selected for processing (1)
src/components/forms/event-material-form.js
| const mediaUploadsOpts = event.type.allowed_media_upload_types.map((mu) => ({ | ||
| label: mu.name, | ||
| value: mu.id | ||
| })); |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Find EventMaterialForm mount sites and how `event` is passed
rg -nP --type=js -C4 '<EventMaterialForm\b'
# Locate the removed defaults referenced by the commit
rg -nP --type=js -C3 '\b(defaultProps|allowed_media_upload_types)\b' srcRepository: fntechgit/summit-admin
Length of output: 160
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Map the target file and nearby uses
git ls-files | rg '^src/components/forms/event-material-form\.js$|^src/components/forms/|^src/'
printf '\n--- outline ---\n'
ast-grep outline src/components/forms/event-material-form.js --view expanded || true
printf '\n--- file excerpt ---\n'
wc -l src/components/forms/event-material-form.js
cat -n src/components/forms/event-material-form.js | sed -n '1,220p'
printf '\n--- search for mount sites / props passing ---\n'
rg -n --glob '!**/node_modules/**' -C 3 'EventMaterialForm|event-material-form' srcRepository: fntechgit/summit-admin
Length of output: 50378
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Find the component definition and any immediate guards around event usage
rg -n --glob '!**/node_modules/**' -C 4 'allowed_media_upload_types|handleChangeMUType|event\.type|event\?' src/components/forms/event-material-form.js srcRepository: fntechgit/summit-admin
Length of output: 50378
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Locate the component file and inspect the relevant lines plus surrounding props/defaults
fd -a 'event-material-form.js' src || true
printf '\n--- nearby references ---\n'
rg -n --glob '!**/node_modules/**' -C 4 'event\.type\.allowed_media_upload_types|handleChangeMUType|defaultProps|propTypes|EventMaterialForm' src/components srcRepository: fntechgit/summit-admin
Length of output: 50379
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Read the component and related surrounding context directly
file=src/components/forms/event-material-form.js
wc -l "$file"
printf '\n--- top ---\n'
cat -n "$file" | sed -n '1,180p'
printf '\n--- references to event in this file ---\n'
rg -n --no-heading 'event|allowed_media_upload_types|defaultProps|propTypes' "$file"Repository: fntechgit/summit-admin
Length of output: 8506
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Find exact imports/usages of EventMaterialForm and inspect the immediate parent page
rg -n --glob '!**/node_modules/**' 'EventMaterialForm' src/components src/pages
printf '\n--- parent page excerpt ---\n'
file=src/pages/events/edit-event-material-page.js
wc -l "$file"
cat -n "$file" | sed -n '1,240p'
printf '\n--- component metadata excerpt ---\n'
file=src/components/forms/event-material-form.js
rg -n --no-heading 'propTypes|defaultProps|event:' "$file"Repository: fntechgit/summit-admin
Length of output: 5178
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Inspect the event material form's prop handling and any guards in the call chain
file=src/components/forms/event-material-form.js
ast-grep outline "$file" --view expanded || true
printf '\n--- exact prop usage ---\n'
rg -n --no-heading -C 3 'const EventMaterialForm|useEffect|event\.type\.allowed_media_upload_types|onSubmit|event\b' "$file"Repository: fntechgit/summit-admin
Length of output: 1875
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Check the event state shape and how event material loads the event
printf '%s\n' '--- currentSummitEventState reducer ---'
file=src/reducers/events/summit-event-reducer.js
wc -l "$file"
cat -n "$file" | sed -n '1,220p'
printf '\n%s\n' '--- event material action path ---'
file=src/actions/event-material-actions.js
wc -l "$file"
cat -n "$file" | sed -n '1,240p'
printf '\n%s\n' '--- search for currentSummitEventState entity initialization/usages ---'
rg -n --glob '!**/node_modules/**' -C 3 'currentSummitEventState|summit-event-reducer|entity:' src/reducers src/actions src/pages/eventsRepository: fntechgit/summit-admin
Length of output: 50379
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Find whether event.type is normalized before this page mounts
rg -n --glob '!**/node_modules/**' -C 3 'normalizeEvent\(|getEventMaterial\(|saveEventMaterial\(|saveEventMaterialWithFile\(' src/actions src/reducers src/pages/eventsRepository: fntechgit/summit-admin
Length of output: 4832
🏁 Script executed:
#!/bin/bash
set -euo pipefail
file=src/reducers/events/summit-event-reducer.js
wc -l "$file"
printf '\n--- defaults and entity updates ---\n'
rg -n --no-heading -C 4 'DEFAULT_ENTITY|DEFAULT_STATE|RECEIVE_|RESET_|UPDATE_|type_id|allowed_media_upload_types|type:' "$file"
printf '\n--- first 140 lines ---\n'
cat -n "$file" | sed -n '1,140p'Repository: fntechgit/summit-admin
Length of output: 9644
🏁 Script executed:
#!/bin/bash
set -euo pipefail
file=src/actions/event-actions.js
printf '%s\n' '--- normalizeEvent definition ---'
rg -n --no-heading -C 6 'function normalizeEvent|const normalizeEvent|export const normalizeEvent' "$file"
printf '\n%s\n' '--- around normalizeEvent use in save/load paths ---\n'
rg -n --no-heading -C 4 'normalizeEvent\(' "$file"Repository: fntechgit/summit-admin
Length of output: 2143
Guard event.type before mapping media upload types. event starts as the reducer’s default entity, so event.type is undefined on the first render and in handleChangeMUType. Use a fallback like event?.type?.allowed_media_upload_types ?? [].
🤖 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/components/forms/event-material-form.js` around lines 56 - 59, Update the
mediaUploadsOpts mapping in the event material form to safely handle an
undefined event.type during initial render and handleChangeMUType. Use the
existing event data when available and fall back to an empty list before calling
map.
https://app.clickup.com/t/9014802374/86bb18pbh
Summary by CodeRabbit