Skip to content

Commit

Permalink
fix: remove unused isNew prop in admin edit
Browse files Browse the repository at this point in the history
  • Loading branch information
boba1007 committed Nov 13, 2024
1 parent 9a56c63 commit 3902e31
Showing 1 changed file with 4 additions and 20 deletions.
24 changes: 4 additions & 20 deletions src/containers/AdminCampaignEdit/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { CampaignBuilderMode } from "@spoke/spoke-codegen";
import isEqual from "lodash/isEqual";
import pick from "lodash/pick";
import PropTypes from "prop-types";
import queryString from "query-string";
import React from "react";
import { Helmet } from "react-helmet";
import { compose } from "recompose";
Expand Down Expand Up @@ -61,9 +60,7 @@ import CampaignVariablesForm from "./sections/CampaignVariablesForm";
class AdminCampaignEdit extends React.Component {
constructor(props) {
super(props);
const isNew = queryString.parse(props.location.search).new;
this.state = {
expandedSection: isNew ? 0 : null,
campaignFormValues: { ...props.campaignData.campaign },
startingCampaign: false,
isWorking: false,
Expand Down Expand Up @@ -144,10 +141,6 @@ class AdminCampaignEdit extends React.Component {
return sectionState;
}

isNew = () => {
return Boolean(queryString.parse(this.props.location.search).new);
};

handleDeleteJob = async (jobId) => {
if (
// eslint-disable-next-line no-alert,no-restricted-globals
Expand Down Expand Up @@ -175,8 +168,7 @@ class AdminCampaignEdit extends React.Component {
await this.handleSave();
this.setState({
expandedSection:
this.state.expandedSection >= this.sections().length - 1 ||
!this.isNew()
this.state.expandedSection >= this.sections().length - 1
? null
: this.state.expandedSection + 1
}); // currently throws an unmounted component error in the console
Expand Down Expand Up @@ -654,14 +646,8 @@ class AdminCampaignEdit extends React.Component {
renderCampaignFormSection = (section, forceDisable) => {
const { isWorking } = this.state;
const shouldDisable =
isWorking ||
forceDisable ||
(!this.isNew() && this.checkSectionSaved(section));
const saveLabel = isWorking
? "Working..."
: this.isNew()
? "Save and goto next section"
: "Save";
isWorking || forceDisable || this.checkSectionSaved(section);
const saveLabel = isWorking ? "Working..." : "Save";
const ContentComponent = section.content;
const formValues = this.getSectionState(section);
return (
Expand Down Expand Up @@ -859,8 +845,7 @@ class AdminCampaignEdit extends React.Component {
const { expandedSection, requestError } = this.state;
const { isAdmin, match } = this.props;
const { campaignId } = match.params;
const isNew = this.isNew();
const saveLabel = isNew ? "Save and goto next section" : "Save";
const saveLabel = "Save";

const errorActions = [
<Button key="ok" color="primary" onClick={this.handleCloseError}>
Expand All @@ -885,7 +870,6 @@ class AdminCampaignEdit extends React.Component {
organizationId={match.params.organizationId}
campaignId={campaignId}
active={expandedSection === sectionIndex}
isNew={isNew}
saveLabel={saveLabel}
onError={this.handleSectionError}
onExpandChange={this.handleExpandChange(sectionIndex)}
Expand Down

0 comments on commit 3902e31

Please sign in to comment.