Skip to content

Commit

Permalink
Refactor campaign content type references
Browse files Browse the repository at this point in the history
  • Loading branch information
knadh committed Feb 9, 2020
1 parent ec22170 commit af14fff
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
16 changes: 8 additions & 8 deletions frontend/src/Campaign.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ class Editor extends React.PureComponent {
editor: null,
quill: null,
rawInput: null,
selContentType: "richtext",
contentType: "richtext",
selContentType: cs.CampaignContentTypeRichtext,
contentType: cs.CampaignContentTypeRichtext,
body: ""
}

Expand Down Expand Up @@ -108,11 +108,11 @@ class Editor extends React.PureComponent {

// Switching from richtext to html.
let body = ""
if (this.state.selContentType === "html") {
if (this.state.selContentType === cs.CampaignContentTypeHTML) {
body = this.state.quill.editor.container.firstChild.innerHTML
// eslint-disable-next-line
this.state.rawInput.value = body
} else if (this.state.selContentType === "richtext") {
} else if (this.state.selContentType === cs.CampaignContentTypeRichtext) {
body = this.state.rawInput.value
this.state.quill.editor.clipboard.dangerouslyPasteHTML(body, "raw")
}
Expand All @@ -135,8 +135,8 @@ class Editor extends React.PureComponent {
style={{ minWidth: 200 }}
value={this.state.selContentType}
>
<Select.Option value="richtext">Rich Text</Select.Option>
<Select.Option value="html">Raw HTML</Select.Option>
<Select.Option value={ cs.CampaignContentTypeRichtext }>Rich Text</Select.Option>
<Select.Option value={ cs.CampaignContentTypeHTML }>Raw HTML</Select.Option>
</Select>
{this.state.contentType !== this.state.selContentType && (
<div className="actions">
Expand All @@ -159,7 +159,7 @@ class Editor extends React.PureComponent {
<ReactQuill
readOnly={this.props.formDisabled}
style={{
display: this.state.contentType === "richtext" ? "block" : "none"
display: this.state.contentType === cs.CampaignContentTypeRichtext ? "block" : "none"
}}
modules={this.quillModules}
defaultValue={this.props.record.body}
Expand Down Expand Up @@ -594,7 +594,7 @@ class Campaign extends React.PureComponent {
: 0,
record: {},
formRef: null,
contentType: "richtext",
contentType: cs.CampaignContentTypeRichtext,
previewRecord: null,
body: "",
currentTab: "form",
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ export const CampaignStatusRunning = "running"
export const CampaignStatusPaused = "paused"
export const CampaignStatusFinished = "finished"
export const CampaignStatusCancelled = "cancelled"
export const CampaignContentTypeRichtext = "richtext"
export const CampaignContentTypeHTML = "html"
export const CampaignContentTypePlain = "plain"

export const SubscriptionStatusConfirmed = "confirmed"
export const SubscriptionStatusUnConfirmed = "unconfirmed"
Expand Down

0 comments on commit af14fff

Please sign in to comment.