From f4f34eb5bd5a00e69b773d4d9e78156e821a7991 Mon Sep 17 00:00:00 2001 From: RujitRaval Date: Tue, 5 Nov 2019 10:12:16 -0500 Subject: [PATCH 01/12] Add mailchimp code for dev --- public/index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/public/index.html b/public/index.html index eafe85d31..da8015aee 100644 --- a/public/index.html +++ b/public/index.html @@ -40,6 +40,7 @@ })(window,document,'script','dataLayer','GTM-TJ6FTN5'); BlocPower Questionnaire + -- GitLab From 6fb78045cd4b5d3ba599f2382573306ddbde58a7 Mon Sep 17 00:00:00 2001 From: RujitRaval Date: Wed, 6 Nov 2019 10:28:29 -0500 Subject: [PATCH 02/12] Mailchimp test --- src/actions.js | 61 +++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 48 insertions(+), 13 deletions(-) diff --git a/src/actions.js b/src/actions.js index 506aea73b..319022cc4 100644 --- a/src/actions.js +++ b/src/actions.js @@ -1,23 +1,58 @@ import axios from 'axios'; +import { async } from 'q'; // asynchronous action creator export const verifyUser = (user) => { - const blocLinkUrl = process.env.REACT_APP_BLOCLINK_URL; - console.log(blocLinkUrl) - return (dispatch) => { - dispatch({ type: "UserRequested" }); - return axios.put( - `${blocLinkUrl}/buildings/bis/verify-user/`, - user, - { headers : { 'Content-Type' : 'application/x-www-form-urlencoded; charset=UTF-8' } }, - ) - .then(res => dispatch( - { type: "UserSucceeded", data: res })) + return (dispatch) => { + axios.post( + 'https://us9.api.mailchimp.com/3.0/lists/1b2463411b/members/', + { + "email_address": "tedddst@test.com", + "status": "subscribed", + "merge_fields": { + "FNAME": "TEST", + "LNAME": "TEST", + "PHONE": "9898" + } + }, + { + headers: { + 'Content-Type' : 'application/x-www-form-urlencoded; charset=UTF-8;', + 'Authorization': 'anystring:2673f5fbd16f91cc6c0c2e33991f83ec', + }, + // auth: { + // username: 'anystring', + // password: '2673f5fbd16f91cc6c0c2e33991f83ec' + // } + }, + ) + .then( + res => dispatch( + { type: "MailchimpSucceeded"})) .catch(err => dispatch( - { type: "UserFailed", msg: err.response.data })); - } + { type: "MailchimpFailed"})); + } +// const blocLinkUrl = process.env.REACT_APP_BLOCLINK_URL; +// return (dispatch) => { +// axios.put( +// `${blocLinkUrl}/buildings/bis/verify-user/`, +// user, +// { +// headers : +// { +// 'Content-Type' : 'application/x-www-form-urlencoded; charset=UTF-8' +// } +// }, +// ) +// .then( +// res => dispatch( +// { type: "UserSucceeded", data: res })) +// .catch(err => dispatch( +// { type: "UserFailed", msg: err.response.data })); +// } } + // asynchronous action creator export const verifyToken = (user) => { const blocLinkUrl = process.env.REACT_APP_BLOCLINK_URL; -- GitLab From 1124e810395f18eba495c582a33ed5d996ff18e1 Mon Sep 17 00:00:00 2001 From: RujitRaval Date: Wed, 6 Nov 2019 12:11:12 -0500 Subject: [PATCH 03/12] Testing mailchimp connection --- src/actions.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/actions.js b/src/actions.js index 319022cc4..6ce1df1a5 100644 --- a/src/actions.js +++ b/src/actions.js @@ -18,12 +18,11 @@ export const verifyUser = (user) => { { headers: { 'Content-Type' : 'application/x-www-form-urlencoded; charset=UTF-8;', - 'Authorization': 'anystring:2673f5fbd16f91cc6c0c2e33991f83ec', }, - // auth: { - // username: 'anystring', - // password: '2673f5fbd16f91cc6c0c2e33991f83ec' - // } + auth: { + username: 'anystring', + password: '2673f5fbd16f91cc6c0c2e33991f83ec' + } }, ) .then( -- GitLab From 742ffcd6b01fa6428a71963a61eee6289a2c0ed2 Mon Sep 17 00:00:00 2001 From: RujitRaval Date: Thu, 7 Nov 2019 12:51:08 -0500 Subject: [PATCH 04/12] Add react-mailchimp-form --- package-lock.json | 31 +++++++++++++++++++++++++++++++ package.json | 1 + 2 files changed, 32 insertions(+) diff --git a/package-lock.json b/package-lock.json index 17a322ffd..b92686734 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7892,6 +7892,29 @@ "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=" }, + "jsonp": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/jsonp/-/jsonp-0.2.1.tgz", + "integrity": "sha1-pltPoPEL2nGaBUQep7lMVfPhW64=", + "requires": { + "debug": "^2.1.3" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + } + } + }, "jsprim": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", @@ -10538,6 +10561,14 @@ "resolved": "https://registry.npmjs.org/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz", "integrity": "sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA==" }, + "react-mailchimp-form": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/react-mailchimp-form/-/react-mailchimp-form-1.0.2.tgz", + "integrity": "sha512-G4eONuXCIiAbWw9xN5Klj38SekUV5R+crbF5+9kClDdONaz0XLbo+Nbg9kLH5zfMthyKVPKEgdosEjn/Wux8qA==", + "requires": { + "jsonp": "^0.2.1" + } + }, "react-mapbox-gl-geocoder": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/react-mapbox-gl-geocoder/-/react-mapbox-gl-geocoder-1.0.3.tgz", diff --git a/package.json b/package.json index dfa0bdcff..e0c4de4f8 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "qs": "^6.8.0", "react": "^16.9.0", "react-dom": "^16.9.0", + "react-mailchimp-form": "^1.0.2", "react-mapbox-gl-geocoder": "^1.0.3", "react-redux": "^7.1.1", "react-router-dom": "^5.0.1", -- GitLab From c874e7f3847fe4e9905f328e1679899cf2842fb9 Mon Sep 17 00:00:00 2001 From: RujitRaval Date: Thu, 7 Nov 2019 12:53:24 -0500 Subject: [PATCH 05/12] Testing react-mailchimp-form --- src/App.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/App.js b/src/App.js index fec412aae..d6846ee1c 100644 --- a/src/App.js +++ b/src/App.js @@ -20,6 +20,7 @@ import { questionTree, initialQuestions } from './constants'; import { connect } from 'react-redux'; import { verifyUser, verifyToken, submitAnswer, submitBuilding, completeQuestionnaire } from './actions'; import './App.css'; +import Mailchimp from 'react-mailchimp-form'; class App extends React.Component { @@ -794,6 +795,38 @@ class App extends React.Component { onChange={e => this.handleInputChange(e)} className="input" /> + + +