diff --git a/sass/css/_shop.scss b/sass/css/_shop.scss index b48a548..9b70692 100644 --- a/sass/css/_shop.scss +++ b/sass/css/_shop.scss @@ -12,6 +12,36 @@ button { .layout { + .rfqFeedback { + display: flex; + align-items: center; + padding: 2rem 3rem; + text-align: center; + position: absolute; + width: 350px; + background: white; + left: calc(100%/2 - 350px/2); + -webkit-box-shadow: 0px 0px 33px -7px rgba(0,0,0,0.75); + -moz-box-shadow: 0px 0px 33px -7px rgba(0,0,0,0.75); + box-shadow: 0px 0px 33px -7px rgba(0,0,0,0.75); + top: calc(50% - 50px); + border: 1px solid $brand-color; + font-size: .9rem; + + button { + background-color: inherit; + align-self: center; + border: 0; + position: absolute; + right: 10px; + top: 10px; + + img { + width: 15px; + } + } + } + display: flex; > aside.aside { @@ -253,8 +283,9 @@ button { textarea { border: 1px solid $color-secondary; border-radius: 3px; - margin: 0 0 1rem; + margin: 0 0 .5rem; padding: .4rem; + outline: none; } input[type="submit"] { @@ -264,6 +295,16 @@ button { padding: .7rem; border: 0; border-radius: 3px; + outline: none; + } + + .error { + color: #e53e3e; + padding-bottom: 1em; + } + + .errorField { + border: 1px solid #e53e3e !important; } } } diff --git a/static/images/shop/icon-close.svg b/static/images/shop/icon-close.svg new file mode 100644 index 0000000..c24613f --- /dev/null +++ b/static/images/shop/icon-close.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/static/images/shop/icon-done.svg b/static/images/shop/icon-done.svg new file mode 100644 index 0000000..88722f9 --- /dev/null +++ b/static/images/shop/icon-done.svg @@ -0,0 +1,4 @@ + + + + diff --git a/static/js/axios.min.js b/static/js/axios.min.js new file mode 100644 index 0000000..b87c0e3 --- /dev/null +++ b/static/js/axios.min.js @@ -0,0 +1,3 @@ +/* axios v0.19.2 | (c) 2020 by Matt Zabriskie */ +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.axios=t():e.axios=t()}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){e.exports=n(1)},function(e,t,n){"use strict";function r(e){var t=new s(e),n=i(s.prototype.request,t);return o.extend(n,s.prototype,t),o.extend(n,t),n}var o=n(2),i=n(3),s=n(4),a=n(22),u=n(10),c=r(u);c.Axios=s,c.create=function(e){return r(a(c.defaults,e))},c.Cancel=n(23),c.CancelToken=n(24),c.isCancel=n(9),c.all=function(e){return Promise.all(e)},c.spread=n(25),e.exports=c,e.exports.default=c},function(e,t,n){"use strict";function r(e){return"[object Array]"===j.call(e)}function o(e){return"undefined"==typeof e}function i(e){return null!==e&&!o(e)&&null!==e.constructor&&!o(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function s(e){return"[object ArrayBuffer]"===j.call(e)}function a(e){return"undefined"!=typeof FormData&&e instanceof FormData}function u(e){var t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer}function c(e){return"string"==typeof e}function f(e){return"number"==typeof e}function p(e){return null!==e&&"object"==typeof e}function d(e){return"[object Date]"===j.call(e)}function l(e){return"[object File]"===j.call(e)}function h(e){return"[object Blob]"===j.call(e)}function m(e){return"[object Function]"===j.call(e)}function y(e){return p(e)&&m(e.pipe)}function g(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams}function v(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")}function x(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)}function w(e,t){if(null!==e&&"undefined"!=typeof e)if("object"!=typeof e&&(e=[e]),r(e))for(var n=0,o=e.length;n=200&&e<300}};u.headers={common:{Accept:"application/json, text/plain, */*"}},i.forEach(["delete","get","head"],function(e){u.headers[e]={}}),i.forEach(["post","put","patch"],function(e){u.headers[e]=i.merge(a)}),e.exports=u},function(e,t,n){"use strict";var r=n(2);e.exports=function(e,t){r.forEach(e,function(n,r){r!==t&&r.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[r])})}},function(e,t,n){"use strict";var r=n(2),o=n(13),i=n(5),s=n(16),a=n(19),u=n(20),c=n(14);e.exports=function(e){return new Promise(function(t,f){var p=e.data,d=e.headers;r.isFormData(p)&&delete d["Content-Type"];var l=new XMLHttpRequest;if(e.auth){var h=e.auth.username||"",m=e.auth.password||"";d.Authorization="Basic "+btoa(h+":"+m)}var y=s(e.baseURL,e.url);if(l.open(e.method.toUpperCase(),i(y,e.params,e.paramsSerializer),!0),l.timeout=e.timeout,l.onreadystatechange=function(){if(l&&4===l.readyState&&(0!==l.status||l.responseURL&&0===l.responseURL.indexOf("file:"))){var n="getAllResponseHeaders"in l?a(l.getAllResponseHeaders()):null,r=e.responseType&&"text"!==e.responseType?l.response:l.responseText,i={data:r,status:l.status,statusText:l.statusText,headers:n,config:e,request:l};o(t,f,i),l=null}},l.onabort=function(){l&&(f(c("Request aborted",e,"ECONNABORTED",l)),l=null)},l.onerror=function(){f(c("Network Error",e,null,l)),l=null},l.ontimeout=function(){var t="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),f(c(t,e,"ECONNABORTED",l)),l=null},r.isStandardBrowserEnv()){var g=n(21),v=(e.withCredentials||u(y))&&e.xsrfCookieName?g.read(e.xsrfCookieName):void 0;v&&(d[e.xsrfHeaderName]=v)}if("setRequestHeader"in l&&r.forEach(d,function(e,t){"undefined"==typeof p&&"content-type"===t.toLowerCase()?delete d[t]:l.setRequestHeader(t,e)}),r.isUndefined(e.withCredentials)||(l.withCredentials=!!e.withCredentials),e.responseType)try{l.responseType=e.responseType}catch(t){if("json"!==e.responseType)throw t}"function"==typeof e.onDownloadProgress&&l.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&l.upload&&l.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then(function(e){l&&(l.abort(),f(e),l=null)}),void 0===p&&(p=null),l.send(p)})}},function(e,t,n){"use strict";var r=n(14);e.exports=function(e,t,n){var o=n.config.validateStatus;!o||o(n.status)?e(n):t(r("Request failed with status code "+n.status,n.config,null,n.request,n))}},function(e,t,n){"use strict";var r=n(15);e.exports=function(e,t,n,o,i){var s=new Error(e);return r(s,t,n,o,i)}},function(e,t){"use strict";e.exports=function(e,t,n,r,o){return e.config=t,n&&(e.code=n),e.request=r,e.response=o,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e}},function(e,t,n){"use strict";var r=n(17),o=n(18);e.exports=function(e,t){return e&&!r(t)?o(e,t):t}},function(e,t){"use strict";e.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},function(e,t){"use strict";e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},function(e,t,n){"use strict";var r=n(2),o=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(e){var t,n,i,s={};return e?(r.forEach(e.split("\n"),function(e){if(i=e.indexOf(":"),t=r.trim(e.substr(0,i)).toLowerCase(),n=r.trim(e.substr(i+1)),t){if(s[t]&&o.indexOf(t)>=0)return;"set-cookie"===t?s[t]=(s[t]?s[t]:[]).concat([n]):s[t]=s[t]?s[t]+", "+n:n}}),s):s}},function(e,t,n){"use strict";var r=n(2);e.exports=r.isStandardBrowserEnv()?function(){function e(e){var t=e;return n&&(o.setAttribute("href",t),t=o.href),o.setAttribute("href",t),{href:o.href,protocol:o.protocol?o.protocol.replace(/:$/,""):"",host:o.host,search:o.search?o.search.replace(/^\?/,""):"",hash:o.hash?o.hash.replace(/^#/,""):"",hostname:o.hostname,port:o.port,pathname:"/"===o.pathname.charAt(0)?o.pathname:"/"+o.pathname}}var t,n=/(msie|trident)/i.test(navigator.userAgent),o=document.createElement("a");return t=e(window.location.href),function(n){var o=r.isString(n)?e(n):n;return o.protocol===t.protocol&&o.host===t.host}}():function(){return function(){return!0}}()},function(e,t,n){"use strict";var r=n(2);e.exports=r.isStandardBrowserEnv()?function(){return{write:function(e,t,n,o,i,s){var a=[];a.push(e+"="+encodeURIComponent(t)),r.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),r.isString(o)&&a.push("path="+o),r.isString(i)&&a.push("domain="+i),s===!0&&a.push("secure"),document.cookie=a.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}()},function(e,t,n){"use strict";var r=n(2);e.exports=function(e,t){t=t||{};var n={},o=["url","method","params","data"],i=["headers","auth","proxy"],s=["baseURL","url","transformRequest","transformResponse","paramsSerializer","timeout","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","maxContentLength","validateStatus","maxRedirects","httpAgent","httpsAgent","cancelToken","socketPath"];r.forEach(o,function(e){"undefined"!=typeof t[e]&&(n[e]=t[e])}),r.forEach(i,function(o){r.isObject(t[o])?n[o]=r.deepMerge(e[o],t[o]):"undefined"!=typeof t[o]?n[o]=t[o]:r.isObject(e[o])?n[o]=r.deepMerge(e[o]):"undefined"!=typeof e[o]&&(n[o]=e[o])}),r.forEach(s,function(r){"undefined"!=typeof t[r]?n[r]=t[r]:"undefined"!=typeof e[r]&&(n[r]=e[r])});var a=o.concat(i).concat(s),u=Object.keys(t).filter(function(e){return a.indexOf(e)===-1});return r.forEach(u,function(r){"undefined"!=typeof t[r]?n[r]=t[r]:"undefined"!=typeof e[r]&&(n[r]=e[r])}),n}},function(e,t){"use strict";function n(e){this.message=e}n.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},n.prototype.__CANCEL__=!0,e.exports=n},function(e,t,n){"use strict";function r(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise(function(e){t=e});var n=this;e(function(e){n.reason||(n.reason=new o(e),t(n.reason))})}var o=n(23);r.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},r.source=function(){var e,t=new r(function(t){e=t});return{token:t,cancel:e}},e.exports=r},function(e,t){"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}}])}); +//# sourceMappingURL=axios.min.map \ No newline at end of file diff --git a/static/js/shop.jsx b/static/js/shop.jsx index 493740e..df7f4de 100644 --- a/static/js/shop.jsx +++ b/static/js/shop.jsx @@ -8,6 +8,7 @@ const { const data = window.shop_data; +const axios = window.axios; const productStyle = (style, snapshot, removeAnim, hovered, selected) => { const custom = { @@ -140,6 +141,7 @@ class Layout extends React.PureComponent { isMobile: PropTypes.bool, newCardJustAdded: PropTypes.bool, onClickToggleMobileSideMenu: PropTypes.func, + onClickCloseRFQFeedback: PropTypes.func, }; } @@ -156,7 +158,9 @@ class Layout extends React.PureComponent { mobileSideMenuShouldOpen, isMobile, newCardJustAdded, - onClickToggleMobileSideMenu + onClickToggleMobileSideMenu, + onClickCloseRFQFeedback, + showRFQFeedback, } = this.props; return ( @@ -176,6 +180,23 @@ class Layout extends React.PureComponent { ) : null} + +
+
+ close +
+ +
+ We've received your request and will be in contact soon. +
+ +
+ +
+
+ ); } @@ -812,43 +833,197 @@ class OrderForm extends React.PureComponent { static get propTypes() { return { + isProcessing: PropTypes.bool, + isProcessingComplete: PropTypes.bool, onClickSubmit: PropTypes.func, }; } constructor(props) { super(props); - this.state = {note: ''}; + this.state = { + note: '', + email: '', + error: { + note: null, + email: null, + }, + empty: { + note: null, + email: null, + }, + }; - this.handleNoteChange = this.handleNoteChange.bind(this); + this.handleEmail = this.handleEmail.bind(this); + this.handleNote = this.handleNote.bind(this); this.handleSubmit = this.handleSubmit.bind(this); + this.resetEmptyError = this.resetEmptyError.bind(this); + this.checkValidation = this.checkValidation.bind(this); } - handleNoteChange(event) { + checkValidation() { + let isValid = true; + let validationFields = {...this.state}; + + const { + isEmpty: isEmailEmpty, + isError: isEmailError + } = this.validateEmail(this.state.email); + + validationFields = { + ...validationFields, + error: { + ...this.state.error, + email: isEmailError, + }, + empty: { + ...this.state.empty, + email: isEmailEmpty, + } + } + + this.setState(validationFields); + + isValid = + !isEmailEmpty && + !isEmailError + + return isValid; + } + + validateEmail(value) { + let isEmpty = null; + let isError = null; + + const { t } = this.props; + + if (!value || value.trim() === '') { + isEmpty = true; + } else if (value && !value.match(/^\w+([\+\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/)) { + isError = { + message: 'Your email is incomplete', + }; + } + + return { isEmpty, isError }; + } + + validateNote(value) { + let isEmpty = null; + + if (!value || value.trim() === '') { + isEmpty = true; + } + + return { isEmpty }; + } + + resetEmptyError(key) { this.setState({ - note: event.target.value, + ...this.state, + error: { + ...this.state.error, + [key]: null, + }, + empty: { + ...this.state.empty, + [key]: null, + }, + }); + } + + handleEmail(e) { + const value = e.target.value; + const { isEmpty, isError } = this.validateEmail(value); + + this.setState({ + ...this.state, + email: value, + error: { + ...this.state.error, + email: isError, + }, + empty: { + ...this.state.empty, + email: isEmpty, + } + }); + } + + handleNote(e) { + const value = e.target.value; + + this.setState({ + ...this.state, + note: value, }); } handleSubmit(event) { - if (this.props.onClickSubmit) { - this.props.onClickSubmit(this.state.note); - } event.preventDefault(); + + if (this.props.onClickSubmit) { + // check validation input fields + const isValidated = this.checkValidation(); + if (!isValidated) { + return false; + } + + this.props.onClickSubmit(this.state.note, this.state.email); + } } render() { + const { + handleEmail, + handleNote, + resetEmptyError, + handleSubmit, + } = this; + + const { + email, + note, + error, + empty + } = this.state; + + const { isProcessing, isProcessingComplete } = this.props; + return (
-
+ + + resetEmptyError('email')} + onChange={handleEmail} + onBlur={handleEmail} + value={email} /> + + { empty && empty.email ? ( +
+ Required +
+ ) : null} + + { error && error.email ? ( +
+ Your email is incomplete +
+ ) : null} +