Skip to content

fix: hide speaker input search on speakers promocodes not saved#806

Open
tomrndom wants to merge 1 commit intomasterfrom
fix/speaker-promocode-search-assigned
Open

fix: hide speaker input search on speakers promocodes not saved#806
tomrndom wants to merge 1 commit intomasterfrom
fix/speaker-promocode-search-assigned

Conversation

@tomrndom
Copy link

@tomrndom tomrndom commented Feb 27, 2026

ref: https://app.clickup.com/t/86b8mpbev

image

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

Summary by CodeRabbit

Release Notes

  • Refactor

    • Removed unused parameters and streamlined internal code logic for improved maintainability.
  • Bug Fixes

    • Fixed conditional display of search functionality to appear only when appropriate conditions are met.

Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>
@tomrndom tomrndom requested a review from smarcet February 27, 2026 15:18
@coderabbitai
Copy link

coderabbitai bot commented Feb 27, 2026

📝 Walkthrough

Walkthrough

A single component file underwent refactoring that includes converting a callback to an arrow function, removing unused method parameters, eliminating unnecessary property destructuring, and adding conditional rendering logic for the FreeTextSearch component based on entity ID values.

Changes

Cohort / File(s) Summary
Component Refactoring
src/components/forms/promocode-form/forms/speakers-base-pc-form.js
Updated handleSort method signature to remove unused func parameter; converted Swal callback to arrow function; removed class_name destructuring from entity in handlePageChange; added conditional rendering for FreeTextSearch when entity.id > 0; simplified preventEvents prop usage.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • smarcet

Poem

🐰 A rabbit's refactoring song:

Parameters pruned like garden weeds,
Arrow functions plant cleaner seeds,
Conditional renders just when we need,
Simpler props make code agreed! 🌿

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: hiding the speaker search input when speakers promocodes have not been saved yet (conditional rendering when entity.id > 0).
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/speaker-promocode-search-assigned

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

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/components/forms/promocode-form/forms/speakers-base-pc-form.js`:
- Around line 135-146: Replace the numeric comparison entity.id > 0 with a
presence check so string IDs won't hide the search; change the conditional
around the FreeTextSearch (the block rendering FreeTextSearch that uses
value={term ?? ""}, onSearch={handleSearch}) to use a boolean presence check
like !!entity.id (or simply if (entity.id)) to match the check used earlier in
the file.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f0fbe8c and f2781df.

📒 Files selected for processing (1)
  • src/components/forms/promocode-form/forms/speakers-base-pc-form.js

Comment on lines +135 to +146
{entity.id > 0 && (
<div className="col-md-6" style={{ zIndex: 0 }}>
<FreeTextSearch
value={term ?? ""}
placeholder={T.translate(
"edit_promo_code.placeholders.search_speakers"
)}
onSearch={handleSearch}
preventEvents
/>
</div>
)}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# Find the speakers-base-pc-form.js file to understand context
fd -n "speakers-base-pc-form" --type f

Repository: fntechgit/summit-admin

Length of output: 296


🏁 Script executed:

# Search for id prop-type or type declarations in the codebase
rg -n -C3 --type=js --type=jsx --type=ts --type=tsx '\bid\s*:\s*(PropTypes\.)?(number|string|Number|String)|\bid\s*[:=]\s*(Number|String|PropTypes\.number|PropTypes\.string)\b' | head -80

Repository: fntechgit/summit-admin

Length of output: 93


🏁 Script executed:

# Find numeric id guards similar to the one in question
rg -n -C2 --type=js --type=jsx --type=ts --type=tsx '\.id\s*>\s*0' | head -60

Repository: fntechgit/summit-admin

Length of output: 93


🏁 Script executed:

# Also check for entity/model definitions to understand id type
rg -n -C3 --type=js --type=jsx --type=ts --type=tsx 'entity\s*[:=].*id|id\s*:\s*.*(?:number|string|Number|String|uuid|UUID)' | head -80

Repository: fntechgit/summit-admin

Length of output: 93


🏁 Script executed:

# Find the speakers-base-pc-form.js file
fd "speakers-base-pc-form" --type f

Repository: fntechgit/summit-admin

Length of output: 132


🏁 Script executed:

# Search for id prop-type or type declarations in the codebase
rg -n -C3 '\bid\s*:\s*(PropTypes\.)?(number|string|Number|String)|\bid\s*[:=]\s*(Number|String|PropTypes\.number|PropTypes\.string)' --type=js --type=ts 2>/dev/null | head -100

Repository: fntechgit/summit-admin

Length of output: 5728


🏁 Script executed:

# Find numeric id guards similar to the one in question
rg -n -C2 '\.id\s*>\s*0' --type=js --type=ts 2>/dev/null | head -60

Repository: fntechgit/summit-admin

Length of output: 4358


🏁 Script executed:

# Read the speakers-base-pc-form.js file to understand context around line 135-146
fd "speakers-base-pc-form.js" --type f -x cat -n {}

Repository: fntechgit/summit-admin

Length of output: 6749


🏁 Script executed:

# Search for entity model/interface definitions
rg -n -C3 'entity.*id|interface.*entity|type.*entity' --type=js --type=ts 2>/dev/null | head -100

Repository: fntechgit/summit-admin

Length of output: 7071


Use a presence check for entity.id instead of numeric comparison.

Line 135 uses entity.id > 0, but IDs in this codebase can be strings (e.g., PropTypes.string appears in multiple components). If a persisted entity has a string ID, this check would fail and hide the search component. Line 26 in the same file already uses the safer if (entity.id) pattern. Use !!entity.id for consistency and to handle both numeric and string IDs.

Suggested change
-        {entity.id > 0 && (
+        {!!entity.id && (
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{entity.id > 0 && (
<div className="col-md-6" style={{ zIndex: 0 }}>
<FreeTextSearch
value={term ?? ""}
placeholder={T.translate(
"edit_promo_code.placeholders.search_speakers"
)}
onSearch={handleSearch}
preventEvents
/>
</div>
)}
{!!entity.id && (
<div className="col-md-6" style={{ zIndex: 0 }}>
<FreeTextSearch
value={term ?? ""}
placeholder={T.translate(
"edit_promo_code.placeholders.search_speakers"
)}
onSearch={handleSearch}
preventEvents
/>
</div>
)}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/forms/promocode-form/forms/speakers-base-pc-form.js` around
lines 135 - 146, Replace the numeric comparison entity.id > 0 with a presence
check so string IDs won't hide the search; change the conditional around the
FreeTextSearch (the block rendering FreeTextSearch that uses value={term ?? ""},
onSearch={handleSearch}) to use a boolean presence check like !!entity.id (or
simply if (entity.id)) to match the check used earlier in the file.

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