Changeset 2361465
- Timestamp:
- 08/14/2020 08:28:10 PM (6 years ago)
- Location:
- foreup-forms/trunk
- Files:
-
- 7 edited
-
README.txt (modified) (2 diffs)
-
assets/js/frontend.js (modified) (2 diffs)
-
assets/js/frontend.min.js (modified) (1 diff)
-
assets/src/frontend/App.vue (modified) (2 diffs)
-
package-lock.json (modified) (1 diff)
-
package.json (modified) (1 diff)
-
plugin.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
foreup-forms/trunk/README.txt
r2279763 r2361465 5 5 Requires at least: 5.1 6 6 Tested up to: 5.2 7 Stable tag: 1. 1.97 Stable tag: 1.2 8 8 Requires PHP: 5.2.4 9 9 License: GPLv2 or later … … 57 57 = 1.1.8 = 58 58 *Updated endpoints 59 60 = 1.2 = 61 *updated error handling and required defaults for creating customers -
foreup-forms/trunk/assets/js/frontend.js
r2279763 r2361465 843 843 birthdate: "", 844 844 customerId: "", 845 token: "" 845 token: "", 846 handicapScore: 0 846 847 }; 847 848 } … … 885 886 this.isSending = false; 886 887 this.spinnerMsg = ""; 887 this.handleMessage("green", "success"); 888 let response = JSON.parse(res.data); 889 if (response.success) { 890 this.handleMessage("green", "success"); 891 } else { 892 this.handleMessage("orange", "wrong"); 893 } 888 894 } 889 895 }).catch(err => { -
foreup-forms/trunk/assets/js/frontend.min.js
r2279791 r2361465 1 pluginWebpack([0],{14:function(e,t,s){"use strict";var o=i(s(1)),a=i(s(17));function i(e){return e&&e.__esModule?e:{default:e}}o.default.config.productionTip=!1,new o.default({el:"#vue-frontend-app",render:function(e){return e(a.default)}})},17:function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=s(5),a=s(41),i=!1;var r=function(e){i||s(18)},n=s(20)(o.a,a.a,!1,r,"data-v-c687af6c",null);n.options.__file="assets\\src\\frontend\\App.vue",t.default=n.exports},18:function(e,t){},41:function(e,t,s){"use strict";var o=function(){var e=this,t=e.$createElement,s=e._self._c||t;return s("div",{attrs:{id:"form-up-frontend-app"}},[s("h2",[e._v(e._s(e.settings.header))]),e._v(" "),s("input",{directives:[{name:"model",rawName:"v-model",value:e.form.first,expression:"form.first"}],staticClass:"first",attrs:{placeholder:"First Name*",type:"text",pattern:"[a-zA-Z0-9 ]+",size:"40"},domProps:{value:e.form.first},on:{input:function(t){t.target.composing||e.$set(e.form,"first",t.target.value)}}}),e._v(" "),s("input",{directives:[{name:"model",rawName:"v-model",value:e.form.last,expression:"form.last"}],staticClass:"last",attrs:{placeholder:"Last Name*",type:"text",pattern:"[a-zA-Z0-9 ]+",size:"40"},domProps:{value:e.form.last},on:{input:function(t){t.target.composing||e.$set(e.form,"last",t.target.value)}}}),e._v(" "),s("input",{directives:[{name:"model",rawName:"v-model",value:e.form.email,expression:"form.email"}],staticClass:"email",attrs:{placeholder:"Email*",type:"email",size:"40"},domProps:{value:e.form.email},on:{input:function(t){t.target.composing||e.$set(e.form,"email",t.target.value)}}}),e._v(" "),e.settings.homePhone?s("input",{directives:[{name:"model",rawName:"v-model",value:e.form.homePhone,expression:"form.homePhone"}],staticClass:"home",attrs:{placeholder:e.homePhoneHold,type:"text",size:"40"},domProps:{value:e.form.homePhone},on:{input:function(t){t.target.composing||e.$set(e.form,"homePhone",t.target.value)}}}):e._e(),e._v(" "),e.settings.cellPhone?s("input",{directives:[{name:"model",rawName:"v-model",value:e.form.cellPhone,expression:"form.cellPhone"}],staticClass:"cell",attrs:{placeholder:e.cellPhoneHold,type:"text",size:"40"},domProps:{value:e.form.cellPhone},on:{input:function(t){t.target.composing||e.$set(e.form,"cellPhone",t.target.value)}}}):e._e(),e._v(" "),e.settings.address1?s("input",{directives:[{name:"model",rawName:"v-model",value:e.form.address1,expression:"form.address1"}],attrs:{placeholder:e.address1Hold,type:"text",size:"40"},domProps:{value:e.form.address1},on:{input:function(t){t.target.composing||e.$set(e.form,"address1",t.target.value)}}}):e._e(),e._v(" "),e.settings.address2?s("input",{directives:[{name:"model",rawName:"v-model",value:e.form.address2,expression:"form.address2"}],attrs:{placeholder:e.address2Hold,type:"text",size:"40"},domProps:{value:e.form.address2},on:{input:function(t){t.target.composing||e.$set(e.form,"address2",t.target.value)}}}):e._e(),e._v(" "),e.settings.city?s("input",{directives:[{name:"model",rawName:"v-model",value:e.form.city,expression:"form.city"}],staticClass:"city",attrs:{placeholder:e.cityHold,type:"text",size:"40"},domProps:{value:e.form.city},on:{input:function(t){t.target.composing||e.$set(e.form,"city",t.target.value)}}}):e._e(),e._v(" "),e.settings.state?s("select",{directives:[{name:"model",rawName:"v-model",value:e.form.state,expression:"form.state"}],staticClass:"state",attrs:{name:"state"},on:{change:function(t){var s=Array.prototype.filter.call(t.target.options,function(e){return e.selected}).map(function(e){return"_value"in e?e._value:e.value});e.$set(e.form,"state",t.target.multiple?s:s[0])}}},[s("optgroup",[s("option",{attrs:{value:"",selected:"",disabled:"",hidden:""}},[e._v(e._s(e.stateHold))]),e._v(" "),s("option",{attrs:{value:"AL"}},[e._v("AL")]),e._v(" "),s("option",{attrs:{value:"AK"}},[e._v("AK")]),e._v(" "),s("option",{attrs:{value:"AR"}},[e._v("AR")]),e._v(" "),s("option",{attrs:{value:"AZ"}},[e._v("AZ")]),e._v(" "),s("option",{attrs:{value:"CA"}},[e._v("CA")]),e._v(" "),s("option",{attrs:{value:"CO"}},[e._v("CO")]),e._v(" "),s("option",{attrs:{value:"CT"}},[e._v("CT")]),e._v(" "),s("option",{attrs:{value:"DC"}},[e._v("DC")]),e._v(" "),s("option",{attrs:{value:"DE"}},[e._v("DE")]),e._v(" "),s("option",{attrs:{value:"FL"}},[e._v("FL")]),e._v(" "),s("option",{attrs:{value:"GA"}},[e._v("GA")]),e._v(" "),s("option",{attrs:{value:"HI"}},[e._v("HI")]),e._v(" "),s("option",{attrs:{value:"IA"}},[e._v("IA")]),e._v(" "),s("option",{attrs:{value:"ID"}},[e._v("ID")]),e._v(" "),s("option",{attrs:{value:"IL"}},[e._v("IL")]),e._v(" "),s("option",{attrs:{value:"IN"}},[e._v("IN")]),e._v(" "),s("option",{attrs:{value:"KS"}},[e._v("KS")]),e._v(" "),s("option",{attrs:{value:"KY"}},[e._v("KY")]),e._v(" "),s("option",{attrs:{value:"LA"}},[e._v("LA")]),e._v(" "),s("option",{attrs:{value:"MA"}},[e._v("MA")]),e._v(" "),s("option",{attrs:{value:"MD"}},[e._v("MD")]),e._v(" "),s("option",{attrs:{value:"ME"}},[e._v("ME")]),e._v(" "),s("option",{attrs:{value:"MI"}},[e._v("MI")]),e._v(" "),s("option",{attrs:{value:"MN"}},[e._v("MN")]),e._v(" "),s("option",{attrs:{value:"MO"}},[e._v("MO")]),e._v(" "),s("option",{attrs:{value:"MS"}},[e._v("MS")]),e._v(" "),s("option",{attrs:{value:"MT"}},[e._v("MT")]),e._v(" "),s("option",{attrs:{value:"NC"}},[e._v("NC")]),e._v(" "),s("option",{attrs:{value:"NE"}},[e._v("NE")]),e._v(" "),s("option",{attrs:{value:"NH"}},[e._v("NH")]),e._v(" "),s("option",{attrs:{value:"NJ"}},[e._v("NJ")]),e._v(" "),s("option",{attrs:{value:"NM"}},[e._v("NM")]),e._v(" "),s("option",{attrs:{value:"NV"}},[e._v("NV")]),e._v(" "),s("option",{attrs:{value:"NY"}},[e._v("NY")]),e._v(" "),s("option",{attrs:{value:"ND"}},[e._v("ND")]),e._v(" "),s("option",{attrs:{value:"OH"}},[e._v("OH")]),e._v(" "),s("option",{attrs:{value:"OK"}},[e._v("OK")]),e._v(" "),s("option",{attrs:{value:"OR"}},[e._v("OR")]),e._v(" "),s("option",{attrs:{value:"PA"}},[e._v("PA")]),e._v(" "),s("option",{attrs:{value:"RI"}},[e._v("RI")]),e._v(" "),s("option",{attrs:{value:"SC"}},[e._v("SC")]),e._v(" "),s("option",{attrs:{value:"SD"}},[e._v("SD")]),e._v(" "),s("option",{attrs:{value:"TN"}},[e._v("TN")]),e._v(" "),s("option",{attrs:{value:"TX"}},[e._v("TX")]),e._v(" "),s("option",{attrs:{value:"UT"}},[e._v("UT")]),e._v(" "),s("option",{attrs:{value:"VT"}},[e._v("VT")]),e._v(" "),s("option",{attrs:{value:"VA"}},[e._v("VA")]),e._v(" "),s("option",{attrs:{value:"WA"}},[e._v("WA")]),e._v(" "),s("option",{attrs:{value:"WI"}},[e._v("WI")]),e._v(" "),s("option",{attrs:{value:"WV"}},[e._v("WV")]),e._v(" "),s("option",{attrs:{value:"WY"}},[e._v("WY")])])]):e._e(),e._v(" "),e.settings.zip?s("input",{directives:[{name:"model",rawName:"v-model",value:e.form.zip,expression:"form.zip"}],staticClass:"zip",attrs:{placeholder:e.zipHold,type:"text",pattern:"[0-9]{5}",size:"40"},domProps:{value:e.form.zip},on:{input:function(t){t.target.composing||e.$set(e.form,"zip",t.target.value)}}}):e._e(),e._v(" "),e.settings.birthdate?s("label",{attrs:{for:"birthdate"}},[e._v(e._s(e.birthdateHold)+":")]):e._e(),e._v(" "),e.settings.birthdate?s("input",{directives:[{name:"model",rawName:"v-model",value:e.form.birthdate,expression:"form.birthdate"}],staticClass:"birthdate",attrs:{type:"date"},domProps:{value:e.form.birthdate},on:{input:function(t){t.target.composing||e.$set(e.form,"birthdate",t.target.value)}}}):e._e(),e._v(" "),s("button",{staticClass:"submit-button",on:{click:function(t){e.checkForm(e.form)}}},[e._v("Sign Up!")]),e._v(" "),s("div",{attrs:{id:"error-snack"}},e._l(e.errors,function(t,o){return s("ul",{key:o},[s("li",[e._v(e._s(t))])])})),e._v(" "),s("div",{attrs:{id:"success-snack"}},[e._v("Success! An email has been sent to: "+e._s(e.email))]),e._v(" "),s("div",{attrs:{id:"wrong-snack"}},[e._v("Oops! :( something went wrong, try again later.")]),e._v(" "),e.isSending?s("div",{staticClass:"spinner-modal"},[s("div",{staticClass:"spinner-container"},[e._m(0),e._v(" "),s("strong",[e._v("Sending, Please Wait: "+e._s(e.spinnerMsg))])])]):e._e()])};o._withStripped=!0;var a={render:o,staticRenderFns:[function(){var e=this.$createElement,t=this._self._c||e;return t("div",{staticClass:"flower-spinner"},[t("div",{staticClass:"dots-container"},[t("div",{staticClass:"bigger-dot"},[t("div",{staticClass:"smaller-dot"})])])])}]};t.a=a},5:function(e,t,s){"use strict";var o=s(6),a=s.n(o),i=s(1),r=s(12);s.n(r);i.default.use(r.VueReCaptcha,{siteKey:options.recaptchaKey}),t.a={name:"App",data:function(){return{form:{first:"",last:"",email:"",homePhone:"",cellPhone:"",address1:"",address2:"",city:"",state:"",zip:"",birthdate:"",customerId:"",recaptchaToken:""},settings:{homePhone:options.homePhone,cellPhone:options.cellPhone,address1:options.address1,address2:options.address2,city:options.city,state:options.state,zip:options.zip,birthdate:options.birthdate,homePhoneReq:options.homePhoneReq,cellPhoneReq:options.cellPhoneReq,address1Req:options.address1Req,address2Req:options.address2Req,cityReq:options.cityReq,stateReq:options.stateReq,zipReq:options.zipReq,birthdateReq:options.birthdateReq,header:options.header,recaptchaKey:options.recaptchaKey},errors:[],email:"",isSending:!1,spinnerMsg:""}},computed:{homePhoneHold:function(){return this.settings.homePhoneReq?"Home Phone*":"Home Phone"},cellPhoneHold:function(){return this.settings.cellPhoneReq?"Cell Phone*":"Cell Phone"},address1Hold:function(){return this.settings.address1Req?"Address*":"Address"},address2Hold:function(){return this.settings.address2Req?"Address 2*":"Address 2"},cityHold:function(){return this.settings.cityReq?"City*":"City"},stateHold:function(){return this.settings.stateReq?"State*":"State"},zipHold:function(){return this.settings.zipReq?"Zip*":"Zip"},birthdateHold:function(){return this.settings.birthdateReq?"Birthdate*":"Birthdate"}},methods:{recaptcha(e){this.isSending=!0,this.spinnerMsg="Checking if you are a robot...",this.$recaptcha("login").then(t=>{this.form.token=t,this.checkEmail(e)})},handleMessage(e,t){var s=document.getElementById(`${t}-snack`);s.className=`show ${e}`,setTimeout(function(){s.className=s.className.replace("show","")},3e3)},postCustomer(e){this.spinnerMsg="Adding to Mailing List...",this.email&&(this.form={first:"",last:"",email:"",homePhone:"",cellPhone:"",address1:"",address2:"",city:"",state:"",zip:"",birthdate:"",customerId:"",token:"" }),a.a.post(`${window.location.origin}/wp-json/foreup-forms/v1/post-customer/`,e).then(e=>{e.data&&(this.isSending=!1,this.spinnerMsg="",this.handleMessage("green","success"))}).catch(e=>{this.isSending=!1,this.spinnerMsg="",console.log(e.response.data.message),this.handleMessage("orange","wrong")})},updateCustomer(e,t){this.spinnerMsg="Updating Contact Info...",this.email&&(this.form={first:"",last:"",email:"",homePhone:"",cellPhone:"",address1:"",address2:"",city:"",state:"",zip:"",birthdate:"",customerId:""}),a.a.post(`${window.location.origin}/wp-json/foreup-forms/v1/update-customer/`,e).then(e=>{e.data&&(this.isSending=!1,this.spinnerMsg="",this.handleMessage("green","success"))}).catch(e=>{this.isSending=!1,this.spinnerMsg="",console.log(e.response.data.message),this.handleMessage("orange","wrong")})},checkEmail(e){this.spinnerMsg="Checking Info...",a.a.post(`${window.location.origin}/wp-json/foreup-forms/v1/check-email/`,e).then(t=>{if(t.data[0]){let s=t.data[1].body,o=JSON.parse(s);if(o.data&&0!==o.data.length){let t=o.data[0].attributes.account_number;this.form.customerId=o.data[0].id,e.account_number=t,this.updateCustomer(e)}else this.postCustomer(e)}else this.isSending=!1,this.spinnerMsg="",this.handleMessage("orange","wrong")}).catch(e=>{console.log(e),this.isSending=!1,this.spinnerMsg="",this.handleMessage("orange","wrong")})},async checkForm(e){this.spinnerMsg="Verifying Form...",this.errors=[],this.email=this.form.email;let{homePhoneReq:t,cellPhoneReq:s,address1Req:o,address2Req:a,cityReq:i,stateReq:r,zipReq:n,birthdateReq:l,homePhone:d,cellPhone:v,address1:p,address2:u,city:h,state:m,zip:c,birthdate:_}=this.settings;this.form.first||this.errors.push("First Name Required"),this.form.last||this.errors.push("Last Name Required"),e.email.match(/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/)&&this.form.email||this.errors.push("Valid Email Required"),t&&d&&!this.form.homePhone&&this.errors.push("Home Phone Required"),s&&v&&!this.form.cellPhone&&this.errors.push("Cell Phone Required"),o&&p&&!this.form.address1&&this.errors.push("Address Required"),a&&u&&!this.form.address2&&this.errors.push("Address 2 Required"),i&&h&&!this.form.city&&this.errors.push("City Required"),r&&m&&!this.form.state&&this.errors.push("State Required"),n&&c&&!this.form.zip&&this.errors.push("Zip Code Required"),l&&_&&!this.form.birthdate&&this.errors.push("Birthdate Required"),this.errors.length?this.handleMessage("red","error"):await this.recaptcha(e)}}}}},[14]);1 pluginWebpack([0],{14:function(e,t,s){"use strict";var o=i(s(1)),a=i(s(17));function i(e){return e&&e.__esModule?e:{default:e}}o.default.config.productionTip=!1,new o.default({el:"#vue-frontend-app",render:function(e){return e(a.default)}})},17:function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=s(5),a=s(41),i=!1;var r=function(e){i||s(18)},n=s(20)(o.a,a.a,!1,r,"data-v-c687af6c",null);n.options.__file="assets\\src\\frontend\\App.vue",t.default=n.exports},18:function(e,t){},41:function(e,t,s){"use strict";var o=function(){var e=this,t=e.$createElement,s=e._self._c||t;return s("div",{attrs:{id:"form-up-frontend-app"}},[s("h2",[e._v(e._s(e.settings.header))]),e._v(" "),s("input",{directives:[{name:"model",rawName:"v-model",value:e.form.first,expression:"form.first"}],staticClass:"first",attrs:{placeholder:"First Name*",type:"text",pattern:"[a-zA-Z0-9 ]+",size:"40"},domProps:{value:e.form.first},on:{input:function(t){t.target.composing||e.$set(e.form,"first",t.target.value)}}}),e._v(" "),s("input",{directives:[{name:"model",rawName:"v-model",value:e.form.last,expression:"form.last"}],staticClass:"last",attrs:{placeholder:"Last Name*",type:"text",pattern:"[a-zA-Z0-9 ]+",size:"40"},domProps:{value:e.form.last},on:{input:function(t){t.target.composing||e.$set(e.form,"last",t.target.value)}}}),e._v(" "),s("input",{directives:[{name:"model",rawName:"v-model",value:e.form.email,expression:"form.email"}],staticClass:"email",attrs:{placeholder:"Email*",type:"email",size:"40"},domProps:{value:e.form.email},on:{input:function(t){t.target.composing||e.$set(e.form,"email",t.target.value)}}}),e._v(" "),e.settings.homePhone?s("input",{directives:[{name:"model",rawName:"v-model",value:e.form.homePhone,expression:"form.homePhone"}],staticClass:"home",attrs:{placeholder:e.homePhoneHold,type:"text",size:"40"},domProps:{value:e.form.homePhone},on:{input:function(t){t.target.composing||e.$set(e.form,"homePhone",t.target.value)}}}):e._e(),e._v(" "),e.settings.cellPhone?s("input",{directives:[{name:"model",rawName:"v-model",value:e.form.cellPhone,expression:"form.cellPhone"}],staticClass:"cell",attrs:{placeholder:e.cellPhoneHold,type:"text",size:"40"},domProps:{value:e.form.cellPhone},on:{input:function(t){t.target.composing||e.$set(e.form,"cellPhone",t.target.value)}}}):e._e(),e._v(" "),e.settings.address1?s("input",{directives:[{name:"model",rawName:"v-model",value:e.form.address1,expression:"form.address1"}],attrs:{placeholder:e.address1Hold,type:"text",size:"40"},domProps:{value:e.form.address1},on:{input:function(t){t.target.composing||e.$set(e.form,"address1",t.target.value)}}}):e._e(),e._v(" "),e.settings.address2?s("input",{directives:[{name:"model",rawName:"v-model",value:e.form.address2,expression:"form.address2"}],attrs:{placeholder:e.address2Hold,type:"text",size:"40"},domProps:{value:e.form.address2},on:{input:function(t){t.target.composing||e.$set(e.form,"address2",t.target.value)}}}):e._e(),e._v(" "),e.settings.city?s("input",{directives:[{name:"model",rawName:"v-model",value:e.form.city,expression:"form.city"}],staticClass:"city",attrs:{placeholder:e.cityHold,type:"text",size:"40"},domProps:{value:e.form.city},on:{input:function(t){t.target.composing||e.$set(e.form,"city",t.target.value)}}}):e._e(),e._v(" "),e.settings.state?s("select",{directives:[{name:"model",rawName:"v-model",value:e.form.state,expression:"form.state"}],staticClass:"state",attrs:{name:"state"},on:{change:function(t){var s=Array.prototype.filter.call(t.target.options,function(e){return e.selected}).map(function(e){return"_value"in e?e._value:e.value});e.$set(e.form,"state",t.target.multiple?s:s[0])}}},[s("optgroup",[s("option",{attrs:{value:"",selected:"",disabled:"",hidden:""}},[e._v(e._s(e.stateHold))]),e._v(" "),s("option",{attrs:{value:"AL"}},[e._v("AL")]),e._v(" "),s("option",{attrs:{value:"AK"}},[e._v("AK")]),e._v(" "),s("option",{attrs:{value:"AR"}},[e._v("AR")]),e._v(" "),s("option",{attrs:{value:"AZ"}},[e._v("AZ")]),e._v(" "),s("option",{attrs:{value:"CA"}},[e._v("CA")]),e._v(" "),s("option",{attrs:{value:"CO"}},[e._v("CO")]),e._v(" "),s("option",{attrs:{value:"CT"}},[e._v("CT")]),e._v(" "),s("option",{attrs:{value:"DC"}},[e._v("DC")]),e._v(" "),s("option",{attrs:{value:"DE"}},[e._v("DE")]),e._v(" "),s("option",{attrs:{value:"FL"}},[e._v("FL")]),e._v(" "),s("option",{attrs:{value:"GA"}},[e._v("GA")]),e._v(" "),s("option",{attrs:{value:"HI"}},[e._v("HI")]),e._v(" "),s("option",{attrs:{value:"IA"}},[e._v("IA")]),e._v(" "),s("option",{attrs:{value:"ID"}},[e._v("ID")]),e._v(" "),s("option",{attrs:{value:"IL"}},[e._v("IL")]),e._v(" "),s("option",{attrs:{value:"IN"}},[e._v("IN")]),e._v(" "),s("option",{attrs:{value:"KS"}},[e._v("KS")]),e._v(" "),s("option",{attrs:{value:"KY"}},[e._v("KY")]),e._v(" "),s("option",{attrs:{value:"LA"}},[e._v("LA")]),e._v(" "),s("option",{attrs:{value:"MA"}},[e._v("MA")]),e._v(" "),s("option",{attrs:{value:"MD"}},[e._v("MD")]),e._v(" "),s("option",{attrs:{value:"ME"}},[e._v("ME")]),e._v(" "),s("option",{attrs:{value:"MI"}},[e._v("MI")]),e._v(" "),s("option",{attrs:{value:"MN"}},[e._v("MN")]),e._v(" "),s("option",{attrs:{value:"MO"}},[e._v("MO")]),e._v(" "),s("option",{attrs:{value:"MS"}},[e._v("MS")]),e._v(" "),s("option",{attrs:{value:"MT"}},[e._v("MT")]),e._v(" "),s("option",{attrs:{value:"NC"}},[e._v("NC")]),e._v(" "),s("option",{attrs:{value:"NE"}},[e._v("NE")]),e._v(" "),s("option",{attrs:{value:"NH"}},[e._v("NH")]),e._v(" "),s("option",{attrs:{value:"NJ"}},[e._v("NJ")]),e._v(" "),s("option",{attrs:{value:"NM"}},[e._v("NM")]),e._v(" "),s("option",{attrs:{value:"NV"}},[e._v("NV")]),e._v(" "),s("option",{attrs:{value:"NY"}},[e._v("NY")]),e._v(" "),s("option",{attrs:{value:"ND"}},[e._v("ND")]),e._v(" "),s("option",{attrs:{value:"OH"}},[e._v("OH")]),e._v(" "),s("option",{attrs:{value:"OK"}},[e._v("OK")]),e._v(" "),s("option",{attrs:{value:"OR"}},[e._v("OR")]),e._v(" "),s("option",{attrs:{value:"PA"}},[e._v("PA")]),e._v(" "),s("option",{attrs:{value:"RI"}},[e._v("RI")]),e._v(" "),s("option",{attrs:{value:"SC"}},[e._v("SC")]),e._v(" "),s("option",{attrs:{value:"SD"}},[e._v("SD")]),e._v(" "),s("option",{attrs:{value:"TN"}},[e._v("TN")]),e._v(" "),s("option",{attrs:{value:"TX"}},[e._v("TX")]),e._v(" "),s("option",{attrs:{value:"UT"}},[e._v("UT")]),e._v(" "),s("option",{attrs:{value:"VT"}},[e._v("VT")]),e._v(" "),s("option",{attrs:{value:"VA"}},[e._v("VA")]),e._v(" "),s("option",{attrs:{value:"WA"}},[e._v("WA")]),e._v(" "),s("option",{attrs:{value:"WI"}},[e._v("WI")]),e._v(" "),s("option",{attrs:{value:"WV"}},[e._v("WV")]),e._v(" "),s("option",{attrs:{value:"WY"}},[e._v("WY")])])]):e._e(),e._v(" "),e.settings.zip?s("input",{directives:[{name:"model",rawName:"v-model",value:e.form.zip,expression:"form.zip"}],staticClass:"zip",attrs:{placeholder:e.zipHold,type:"text",pattern:"[0-9]{5}",size:"40"},domProps:{value:e.form.zip},on:{input:function(t){t.target.composing||e.$set(e.form,"zip",t.target.value)}}}):e._e(),e._v(" "),e.settings.birthdate?s("label",{attrs:{for:"birthdate"}},[e._v(e._s(e.birthdateHold)+":")]):e._e(),e._v(" "),e.settings.birthdate?s("input",{directives:[{name:"model",rawName:"v-model",value:e.form.birthdate,expression:"form.birthdate"}],staticClass:"birthdate",attrs:{type:"date"},domProps:{value:e.form.birthdate},on:{input:function(t){t.target.composing||e.$set(e.form,"birthdate",t.target.value)}}}):e._e(),e._v(" "),s("button",{staticClass:"submit-button",on:{click:function(t){e.checkForm(e.form)}}},[e._v("Sign Up!")]),e._v(" "),s("div",{attrs:{id:"error-snack"}},e._l(e.errors,function(t,o){return s("ul",{key:o},[s("li",[e._v(e._s(t))])])})),e._v(" "),s("div",{attrs:{id:"success-snack"}},[e._v("Success! An email has been sent to: "+e._s(e.email))]),e._v(" "),s("div",{attrs:{id:"wrong-snack"}},[e._v("Oops! :( something went wrong, try again later.")]),e._v(" "),e.isSending?s("div",{staticClass:"spinner-modal"},[s("div",{staticClass:"spinner-container"},[e._m(0),e._v(" "),s("strong",[e._v("Sending, Please Wait: "+e._s(e.spinnerMsg))])])]):e._e()])};o._withStripped=!0;var a={render:o,staticRenderFns:[function(){var e=this.$createElement,t=this._self._c||e;return t("div",{staticClass:"flower-spinner"},[t("div",{staticClass:"dots-container"},[t("div",{staticClass:"bigger-dot"},[t("div",{staticClass:"smaller-dot"})])])])}]};t.a=a},5:function(e,t,s){"use strict";var o=s(6),a=s.n(o),i=s(1),r=s(12);s.n(r);i.default.use(r.VueReCaptcha,{siteKey:options.recaptchaKey}),t.a={name:"App",data:function(){return{form:{first:"",last:"",email:"",homePhone:"",cellPhone:"",address1:"",address2:"",city:"",state:"",zip:"",birthdate:"",customerId:"",recaptchaToken:""},settings:{homePhone:options.homePhone,cellPhone:options.cellPhone,address1:options.address1,address2:options.address2,city:options.city,state:options.state,zip:options.zip,birthdate:options.birthdate,homePhoneReq:options.homePhoneReq,cellPhoneReq:options.cellPhoneReq,address1Req:options.address1Req,address2Req:options.address2Req,cityReq:options.cityReq,stateReq:options.stateReq,zipReq:options.zipReq,birthdateReq:options.birthdateReq,header:options.header,recaptchaKey:options.recaptchaKey},errors:[],email:"",isSending:!1,spinnerMsg:""}},computed:{homePhoneHold:function(){return this.settings.homePhoneReq?"Home Phone*":"Home Phone"},cellPhoneHold:function(){return this.settings.cellPhoneReq?"Cell Phone*":"Cell Phone"},address1Hold:function(){return this.settings.address1Req?"Address*":"Address"},address2Hold:function(){return this.settings.address2Req?"Address 2*":"Address 2"},cityHold:function(){return this.settings.cityReq?"City*":"City"},stateHold:function(){return this.settings.stateReq?"State*":"State"},zipHold:function(){return this.settings.zipReq?"Zip*":"Zip"},birthdateHold:function(){return this.settings.birthdateReq?"Birthdate*":"Birthdate"}},methods:{recaptcha(e){this.isSending=!0,this.spinnerMsg="Checking if you are a robot...",this.$recaptcha("login").then(t=>{this.form.token=t,this.checkEmail(e)})},handleMessage(e,t){var s=document.getElementById(`${t}-snack`);s.className=`show ${e}`,setTimeout(function(){s.className=s.className.replace("show","")},3e3)},postCustomer(e){this.spinnerMsg="Adding to Mailing List...",this.email&&(this.form={first:"",last:"",email:"",homePhone:"",cellPhone:"",address1:"",address2:"",city:"",state:"",zip:"",birthdate:"",customerId:"",token:"",handicapScore:0}),a.a.post(`${window.location.origin}/wp-json/foreup-forms/v1/post-customer/`,e).then(e=>{e.data&&(this.isSending=!1,this.spinnerMsg="",this.handleMessage("green","success"))}).catch(e=>{this.isSending=!1,this.spinnerMsg="",console.log(e.response.data.message),this.handleMessage("orange","wrong")})},updateCustomer(e,t){this.spinnerMsg="Updating Contact Info...",this.email&&(this.form={first:"",last:"",email:"",homePhone:"",cellPhone:"",address1:"",address2:"",city:"",state:"",zip:"",birthdate:"",customerId:""}),a.a.post(`${window.location.origin}/wp-json/foreup-forms/v1/update-customer/`,e).then(e=>{if(e.data){this.isSending=!1,this.spinnerMsg="",JSON.parse(e.data).success?this.handleMessage("green","success"):this.handleMessage("orange","wrong")}}).catch(e=>{this.isSending=!1,this.spinnerMsg="",console.log(e.response.data.message),this.handleMessage("orange","wrong")})},checkEmail(e){this.spinnerMsg="Checking Info...",a.a.post(`${window.location.origin}/wp-json/foreup-forms/v1/check-email/`,e).then(t=>{if(t.data[0]){let s=t.data[1].body,o=JSON.parse(s);if(o.data&&0!==o.data.length){let t=o.data[0].attributes.account_number;this.form.customerId=o.data[0].id,e.account_number=t,this.updateCustomer(e)}else this.postCustomer(e)}else this.isSending=!1,this.spinnerMsg="",this.handleMessage("orange","wrong")}).catch(e=>{console.log(e),this.isSending=!1,this.spinnerMsg="",this.handleMessage("orange","wrong")})},async checkForm(e){this.spinnerMsg="Verifying Form...",this.errors=[],this.email=this.form.email;let{homePhoneReq:t,cellPhoneReq:s,address1Req:o,address2Req:a,cityReq:i,stateReq:r,zipReq:n,birthdateReq:l,homePhone:d,cellPhone:v,address1:p,address2:u,city:h,state:c,zip:m,birthdate:_}=this.settings;this.form.first||this.errors.push("First Name Required"),this.form.last||this.errors.push("Last Name Required"),e.email.match(/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/)&&this.form.email||this.errors.push("Valid Email Required"),t&&d&&!this.form.homePhone&&this.errors.push("Home Phone Required"),s&&v&&!this.form.cellPhone&&this.errors.push("Cell Phone Required"),o&&p&&!this.form.address1&&this.errors.push("Address Required"),a&&u&&!this.form.address2&&this.errors.push("Address 2 Required"),i&&h&&!this.form.city&&this.errors.push("City Required"),r&&c&&!this.form.state&&this.errors.push("State Required"),n&&m&&!this.form.zip&&this.errors.push("Zip Code Required"),l&&_&&!this.form.birthdate&&this.errors.push("Birthdate Required"),this.errors.length?this.handleMessage("red","error"):await this.recaptcha(e)}}}}},[14]); -
foreup-forms/trunk/assets/src/frontend/App.vue
r2279763 r2361465 259 259 birthdate: "", 260 260 customerId: "", 261 token: "" 261 token: "", 262 handicapScore: 0 262 263 }; 263 264 } … … 306 307 this.isSending = false; 307 308 this.spinnerMsg = ""; 308 this.handleMessage("green", "success"); 309 let response = JSON.parse(res.data) 310 if(response.success){ 311 this.handleMessage("green", "success"); 312 } else { 313 this.handleMessage("orange", "wrong"); 314 } 309 315 } 310 316 }) -
foreup-forms/trunk/package-lock.json
r2279791 r2361465 1 1 { 2 2 "name": "foreup-forms", 3 "version": "1. 1.9",3 "version": "1.2", 4 4 "lockfileVersion": 1, 5 5 "requires": true, -
foreup-forms/trunk/package.json
r2279791 r2361465 1 1 { 2 2 "name": "foreup-forms", 3 "version": "1. 1.9",3 "version": "1.2", 4 4 "description": "Forms that integrate with foreUP Golf Software", 5 5 "author": "Nathan Johnson <nathan@foreup.com>", -
foreup-forms/trunk/plugin.php
r2279763 r2361465 4 4 Plugin URI: https://foreup.com/ 5 5 Description: Forms that integrate with foreUP Golf Software 6 Version: 1. 1.96 Version: 1.2 7 7 Author: foreUP Software 8 8 Author URI: https://freakingjohnson.github.io/portfolio/ … … 57 57 * @var string 58 58 */ 59 public $version = '1. 1.9';59 public $version = '1.2'; 60 60 61 61 /** … … 323 323 'birthdate', 324 324 'courseId', 325 'handicapScore', 325 326 ), 326 327 ]);
Note: See TracChangeset
for help on using the changeset viewer.