Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions src/components/forms/promocode-form/forms/speakers-base-pc-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const SpeakersBasePCForm = (props) => {
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: T.translate("general.yes_delete")
}).then(function (result) {
}).then((result) => {
if (result.value) {
unAssignSpeaker(class_name, id, speakerId);
}
Expand All @@ -86,17 +86,15 @@ const SpeakersBasePCForm = (props) => {
const handlePageChange = (page) => {
const { entity } = props;
const {
speakers: { term, order, orderDir, perPage },
class_name
speakers: { term, order, orderDir, perPage }
} = entity;
props.getAssignedSpeakers(entity, term, page, perPage, order, orderDir);
};

const handleSort = (index, key, dir, func) => {
const handleSort = (index, key, dir) => {
const { entity } = props;
const {
speakers: { term, currentPage, perPage },
class_name
speakers: { term, currentPage, perPage }
} = entity;
props.getAssignedSpeakers(entity, term, currentPage, perPage, key, dir);
};
Expand Down Expand Up @@ -134,16 +132,18 @@ const SpeakersBasePCForm = (props) => {
<hr />
<label> {T.translate("edit_promo_code.speakers")} </label>
<div className="row">
<div className="col-md-6" style={{ zIndex: 0 }}>
<FreeTextSearch
value={term ?? ""}
placeholder={T.translate(
"edit_promo_code.placeholders.search_speakers"
)}
onSearch={handleSearch}
preventEvents={true}
/>
</div>
{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>
)}
Comment on lines +135 to +146
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.

<div className="col-md-4">
<SpeakerInput
id="speaker"
Expand Down