{"version":3,"file":"contactus.js","sources":["../../../../IREP.Web.Content/v7/scripts/modules/contactus/contactus.ts"],"sourcesContent":["import Component from \"irep/modules/component\";\nimport { Loading7 } from 'irep/modules/loading/index';\nimport { EmailValidation } from \"irep/utilities/validation\";\nexport class ContactUs extends Component {\n constructor(id) {\n super(id);\n this.$main = $(\"#cu7\");\n this.$submit = $(\"#cu7submit\");\n this.$message = $('#cu7inputmessage');\n this.init();\n }\n init() {\n this.isAnonymous = this.$main.data(\"anon\");\n this.countrySelect = this.$main.data(\"countryselect\");\n this.isRek = this.$main.data(\"isrek\");\n this.loader = Loading7.fromOptions('cu7loading', {\n appendToSelector: '#cu7inner',\n containerSelector: '#cu7inner'\n });\n this.$submit.click(() => {\n this.submit();\n });\n if (this.isAnonymous) {\n this.$main.find(\".cu7input\").show();\n }\n else {\n this.$main.find('.cu7static').show();\n this.$message.show();\n }\n }\n buildRequestObject() {\n this.request = {\n cu: {\n geoCode: this.$main.data(\"geocode\"),\n site: this.$main.data(\"site\"),\n countryCode: this.$main.data(\"countrycode\"),\n cultureCode: this.$main.data(\"culturecode\"),\n userTypeId: this.$main.data(\"usertypeid\"),\n storeChainId: this.$main.data(\"storechainid\"),\n email: this.$main.data(\"email\"),\n firstName: this.$main.data(\"firstname\"),\n lastName: this.$main.data(\"lastname\"),\n message: $.trim(this.$message.val().toString()),\n }\n };\n if (this.isAnonymous) {\n this.request.cu.email = $.trim($(\"#cu7inputemail\").val().toString());\n this.request.cu.firstName = $.trim($(\"#cu7inputfirst\").val().toString());\n this.request.cu.lastName = $.trim($(\"#cu7inputlast\").val().toString());\n if (this.countrySelect) {\n this.request.cu.countryCode = $.trim($(\"#cu7inputcountry\").val().toString());\n }\n }\n }\n valid() {\n let valid = true;\n if (this.request.cu.firstName === '') {\n valid = false;\n this.invalidate($(\"#cu7errorfirst\"));\n }\n if (this.request.cu.lastName === '') {\n valid = false;\n this.invalidate($(\"#cu7errorlast\"));\n }\n if (this.request.cu.email === '' || (!EmailValidation.emailFormatIsValid(this.request.cu.email))) {\n valid = false;\n this.invalidate($(\"#cu7erroremail\"));\n }\n if (this.request.cu.message === '') {\n valid = false;\n this.invalidate($(\"#cu7errormessage\"));\n }\n if (this.countrySelect && this.request.cu.countryCode === '') {\n valid = false;\n this.invalidate($(\"#cu7errorcountry\"));\n }\n return valid;\n }\n invalidate($error) {\n $error.prev(\".cu7input\").addClass(\"has-error\");\n $error.show();\n }\n clearErrors() {\n this.$main.find(\".cu7input\").removeClass(\"has-error\");\n this.$main.find(\".cu7error\").hide();\n }\n submit() {\n this.clearErrors();\n this.buildRequestObject();\n if (!this.valid())\n return;\n this.loader.showLoader();\n let url = '';\n switch (true) {\n case this.isRek:\n url = 'api/communications/rek/contact-us';\n break;\n default:\n url = 'api/communications/contactus';\n break;\n }\n window.irep.getHtml({\n url: url,\n data: this.request,\n anonymous: this.isAnonymous,\n type: 'POST'\n })\n .done(() => {\n this.$submit.hide();\n $(\"#cu7success\").show();\n })\n .always(() => {\n this.loader.hideLoader();\n });\n }\n}\n"],"names":["ContactUs","Component","constructor","id","super","this","$main","$","$submit","$message","init","isAnonymous","data","countrySelect","isRek","loader","Loading7","fromOptions","appendToSelector","containerSelector","click","submit","find","show","buildRequestObject","request","cu","geoCode","site","countryCode","cultureCode","userTypeId","storeChainId","email","firstName","lastName","message","trim","val","toString","valid","invalidate","EmailValidation","emailFormatIsValid","$error","prev","addClass","clearErrors","removeClass","hide","showLoader","url","window","irep","getHtml","anonymous","type","done","always","hideLoader"],"mappings":"8HAGO,MAAMA,UAAkBC,EAC3B,WAAAC,CAAYC,GACRC,MAAMD,GACNE,KAAKC,MAAQC,EAAE,QACfF,KAAKG,QAAUD,EAAE,cACjBF,KAAKI,SAAWF,EAAE,oBAClBF,KAAKK,MACb,CACI,IAAAA,GACIL,KAAKM,YAAcN,KAAKC,MAAMM,KAAK,QACnCP,KAAKQ,cAAgBR,KAAKC,MAAMM,KAAK,iBACrCP,KAAKS,MAAQT,KAAKC,MAAMM,K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