From ad8787cab33df95449474b9e0f28baae54b163e7 Mon Sep 17 00:00:00 2001 From: Kailash Nadh Date: Fri, 2 Nov 2018 23:33:00 +0530 Subject: [PATCH] Load global configuration into the frontend as a JS dict using a - React App diff --git a/frontend/my/src/App.js b/frontend/my/src/App.js index 59c2a64..702839d 100644 --- a/frontend/my/src/App.js +++ b/frontend/my/src/App.js @@ -118,6 +118,7 @@ class App extends React.PureComponent { ) diff --git a/frontend/my/src/Campaign.js b/frontend/my/src/Campaign.js index e21aa0b..3d4a1c9 100644 --- a/frontend/my/src/Campaign.js +++ b/frontend/my/src/Campaign.js @@ -298,7 +298,7 @@ class TheFormDef extends React.PureComponent { {getFieldDecorator("from_email", { - initialValue: record.from_email, + initialValue: record.from_email ? record.from_email : this.props.config.fromEmail, rules: [{ required: true }, { validator: this.validateEmail }] })()} @@ -325,10 +325,10 @@ class TheFormDef extends React.PureComponent { )} - + {getFieldDecorator("messenger", { initialValue: record.messenger ? record.messenger : "email" })( - {[...this.props.messengers].map((v, i) => + {[...this.props.config.messengers].map((v, i) => { v } )} @@ -395,7 +395,6 @@ class Campaign extends React.PureComponent { campaignID: this.props.route.match.params ? parseInt(this.props.route.match.params.campaignID, 10) : 0, record: {}, contentType: "richtext", - messengers: [], previewRecord: null, body: "", currentTab: "form", @@ -412,14 +411,11 @@ class Campaign extends React.PureComponent { // Fetch templates. this.props.modelRequest(cs.ModelTemplates, cs.Routes.GetTemplates, cs.MethodGet) - // Fetch messengers. - this.props.request(cs.Routes.GetCampaignMessengers, cs.MethodGet).then((r) => { - this.setState({ messengers: r.data.data, loading: false }) - }) - // Fetch campaign. if(this.state.campaignID) { this.fetchRecord(this.state.campaignID) + } else { + this.setState({ loading: false }) } } @@ -482,7 +478,6 @@ class Campaign extends React.PureComponent {