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
50 changes: 25 additions & 25 deletions src/components/forms/event-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -747,23 +747,19 @@ class EventForm extends React.Component {
);
}

isDraftComplete() {
const { entity } = this.state;
return entity?.status === "NonReceived" && entity?.progress === "COMPLETE";
}
Comment on lines +750 to +753

Copy link
Copy Markdown

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:

#!/bin/bash
# Description: Verify event progress constant usage

# Search for event progress constant definitions
rg -n --type=js -C3 'progress.*=.*["\']COMPLETE["\']' 

# Search for progress field usage in event context
rg -n --type=js -A3 -B3 'entity\.progress|event\.progress' src/pages/events/

# Check if there's an event-specific progress constant
ast-grep --pattern 'export const $EVENT_PROGRESS = {
  $$$
}'

Repository: fntechgit/summit-admin

Length of output: 135


🏁 Script executed:

#!/bin/bash
# Search for COMPLETE constant definitions
rg -n "COMPLETE" src/utils/constants.js src/utils/

# Search for NonReceived constant or usage
rg -n "NonReceived" --type=js -B2 -A2

# Check where progress field is set in event form
rg -n "progress" src/components/forms/event-form.js -B1 -A1 | head -50

# Look for event progress related constants
rg -n "progress|COMPLETE" src/utils/constants.js

Repository: fntechgit/summit-admin

Length of output: 1149


🏁 Script executed:

#!/bin/bash
# Check imports at top of event-form.js
head -50 src/components/forms/event-form.js | grep -n "import"

# Get full context of COMPLETE constant definition
rg -n -B5 -A5 "COMPLETE: \"COMPLETE\"" src/utils/constants.js

# Search for NonReceived constant definition
rg -n "NonReceived" src/utils/constants.js

# Check what COMPLETE constant belongs to (which export)
rg -n -B20 "COMPLETE: \"COMPLETE\"" src/utils/constants.js | head -40

Repository: fntechgit/summit-admin

Length of output: 2947


🏁 Script executed:

#!/bin/bash
# Search for all COMPLETE definitions across the codebase
rg -n "COMPLETE.*:" src/utils/constants.js

# Check for any event progress related constants
rg -n "PROGRESS|EVENT" src/utils/constants.js | head -20

# Search for where entity.progress is assigned or used
rg -n "\.progress\s*=" src/components/forms/event-form.js

# Check if COMPLETE is imported anywhere in event-form.js
rg -n "COMPLETE" src/components/forms/event-form.js

Repository: fntechgit/summit-admin

Length of output: 519


Define constants for event progress and status values rather than using string literals.

The isDraftComplete() method uses string literals "NonReceived" and "COMPLETE" directly. While the COMPLETE constant exists in src/utils/constants.js, it's defined for SPONSOR_MEDIA_UPLOAD_STATUS (line 304), not event progress. Similarly, NonReceived has no corresponding constant definition.

The code appears to use "COMPLETE" as a generic progress value, but this lacks proper constant definitions. Consider creating dedicated constants for event progress (e.g., EVENT_PROGRESS) and event status values (e.g., EVENT_STATUS) in src/utils/constants.js to improve maintainability and prevent typos.

🤖 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-form.js` around lines 750 - 753, The
isDraftComplete() method uses hardcoded string literals "NonReceived" and
"COMPLETE" instead of constants, which can lead to typos and maintenance issues.
Create two new constant definitions in src/utils/constants.js: one for
EVENT_STATUS (with a NON_RECEIVED property) and one for EVENT_PROGRESS (with a
COMPLETE property). Then import these constants at the top of the event-form.js
file and replace the hardcoded strings in the isDraftComplete() method with
references to EVENT_STATUS.NON_RECEIVED and EVENT_PROGRESS.COMPLETE
respectively.


getMissingDraftFields() {
const { entity } = this.state;
const missing = [];

if (!entity.title) missing.push("Title");
if (!entity.type_id) missing.push("Activity Type");
if (!entity.track_id) missing.push("Activity Category");

if (!entity.type_id || this.shouldShowField("allows_publishing_dates")) {
if (!entity.start_date) missing.push("Start Date");
if (!entity.end_date) missing.push("End Date");
if (!entity.duration) missing.push("Duration");
}

if (!entity.type_id || this.isEventType(EVENT_TYPE_PRESENTATION)) {
if (!entity.disclaimer_accepted) missing.push("Disclaimer Accepted");
}
if (!entity.speakers?.length) missing.push("Speakers");

return missing;
}
Expand Down Expand Up @@ -1085,15 +1081,17 @@ class EventForm extends React.Component {
{ label: "Submission", value: "Submission" }
];

const showDraftUI =
this.isPresentation() && !this.isNew() && !this.isComplete();
const missingDraftFields =
!this.isPresentation() || this.isNew() || this.isComplete()
? []
: this.getMissingDraftFields();
showDraftUI && !this.isDraftComplete()
? this.getMissingDraftFields()
: [];

return (
<div>
<input type="hidden" id="id" value={entity.id} />
{this.isPresentation() && !this.isNew() && !this.isComplete() && (
{showDraftUI && (
<div className="alert alert-warning" role="alert">
<div
style={{
Expand Down Expand Up @@ -2146,24 +2144,26 @@ class EventForm extends React.Component {
type="button"
onClick={(ev) => this.triggerFormSubmit(ev, false)}
className="btn btn-primary pull-right"
value={T.translate("edit_event.save_and_mark_complete")}
value={T.translate(
showDraftUI && !this.isDraftComplete()
? "edit_event.save_and_mark_complete"
: "general.save"
)}
/>
<input
type="button"
onClick={(ev) => this.triggerFormSubmit(ev, true)}
className="btn btn-success pull-right"
value={T.translate("general.save_and_publish")}
/>
{this.isPresentation() &&
!this.isNew() &&
!this.isComplete() && (
<input
type="button"
onClick={this.handleSaveIncomplete}
className="btn btn-warning pull-right"
value={T.translate("edit_event.save_as_incomplete")}
/>
)}
{showDraftUI && !this.isDraftComplete() && (
<input
type="button"
onClick={this.handleSaveIncomplete}
className="btn btn-warning pull-right"
value={T.translate("edit_event.save_as_incomplete")}
/>
)}
</div>
)}

Expand Down
Loading