16a007240a5fc459ae1741d6054fa686.json 13.4 KB
Newer Older
1
{"ast":null,"code":"var _jsxFileName = \"C:\\\\Users\\\\Bruger\\\\Desktop\\\\Web-projects\\\\pipit\\\\client\\\\src\\\\pages\\\\login\\\\passwordReset\\\\PasswordForgotModal.jsx\",\n    _s = $RefreshSig$();\n\nimport React, { useState, useRef, useEffect } from 'react';\nimport config from '../../../config';\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\nimport \"./PasswordForgotModal.css\";\nimport MessageModal from '../../../components/messageModal/MessageModal';\nimport { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\n\nconst PasswordForgotModal = () => {\n  _s();\n\n  const [forgotPasswordFormVisibilityState, setForgotPasswordFormVisibilityState] = useState(false);\n  const forgotPasswordFormRef = useRef(null);\n\n  const toggleForgotPasswordFormVisible = () => setForgotPasswordFormVisibilityState(!forgotPasswordFormVisibilityState);\n\n  const [submitOkMessageModalState, setSubmitOkMessageModalState] = useState(false);\n  const [username, setUsername] = useState('');\n\n  const handleUsernameChange = e => {\n    setUsername(e.target.value);\n  };\n\n  useEffect(() => {\n    const pageClickEvent = e => {\n      if (forgotPasswordFormRef.current !== null && !forgotPasswordFormRef.current.contains(e.target)) {\n        toggleForgotPasswordFormVisible();\n      }\n    }; // If the item is active (ie open) then listen for clicks\n\n\n    if (forgotPasswordFormVisibilityState) {\n      window.addEventListener('click', pageClickEvent);\n    }\n\n    return () => {\n      window.removeEventListener('click', pageClickEvent);\n    };\n  }, [forgotPasswordFormVisibilityState]);\n  const userInputData = JSON.stringify({\n    email: `${username}`\n  });\n  const ForgotPasswordRequestOptions = {\n    method: 'PUT',\n    body: userInputData\n  };\n\n  const handlePasswordForgot = e => {\n    e.preventDefault();\n    toggleForgotPasswordFormVisible();\n    setSubmitOkMessageModalState(true); // fetch(config.serviceAPI.ForgotPasswordURL, ForgotPasswordRequestOptions)\n    //   .then((res) => {\n    //     if (!res.ok) {\n    //       window.alert(\"Error: something went wrong\")\n    //       Promise.reject(\"\")\n    //       return\n    //     }\n    //     if (res.ok) {\n    //       toggleSubmitOkModalVisible()\n    //     }\n    //   })\n  };\n\n  return /*#__PURE__*/_jsxDEV(\"div\", {\n    children: [/*#__PURE__*/_jsxDEV(\"div\", {\n      className: \"password-forgot-prompt\",\n      children: /*#__PURE__*/_jsxDEV(\"span\", {\n        children: /*#__PURE__*/_jsxDEV(\"a\", {\n          onClick: toggleForgotPasswordFormVisible,\n          children: \"Forgot password\"\n        }, void 0, false, {\n          fileName: _jsxFileName,\n          lineNumber: 68,\n          columnNumber: 11\n        }, this)\n      }, void 0, false, {\n        fileName: _jsxFileName,\n        lineNumber: 67,\n        columnNumber: 9\n      }, this)\n    }, void 0, false, {\n      fileName: _jsxFileName,\n      lineNumber: 66,\n      columnNumber: 7\n    }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n      className: `modal ${forgotPasswordFormVisibilityState ? \"active\" : \"inactive\"}`,\n      children: /*#__PURE__*/_jsxDEV(\"div\", {\n        ref: forgotPasswordFormRef,\n        className: \"modal-content\",\n        children: /*#__PURE__*/_jsxDEV(\"div\", {\n          className: \"recoverPasswordForm\",\n          children: [/*#__PURE__*/_jsxDEV(\"h2\", {\n            children: \"Recover password\"\n          }, void 0, false, {\n            fileName: _jsxFileName,\n            lineNumber: 76,\n            columnNumber: 13\n          }, this), /*#__PURE__*/_jsxDEV(\"form\", {\n            onSubmit: handlePasswordForgot,\n            children: [/*#__PURE__*/_jsxDEV(\"label\", {\n              children: [\"Email:\", /*#__PURE__*/_jsxDEV(\"input\", {\n                id: \"email\",\n                type: \"text\",\n                value: username,\n                onChange: handleUsernameChange\n              }, void 0, false, {\n                fileName: _jsxFileName,\n                lineNumber: 80,\n                columnNumber: 17\n              }, this)]\n            }, void 0, true, {\n              fileName: _jsxFileName,\n              lineNumber: 78,\n              columnNumber: 15\n            }, this), /*#__PURE__*/_jsxDEV(\"label\", {\n              children: \"An email with a password recovery link will be sent if it is registered in our system\"\n            }, void 0, false, {\n              fileName: _jsxFileName,\n              lineNumber: 85,\n              columnNumber: 15\n            }, this), /*#__PURE__*/_jsxDEV(\"button\", {\n              className: \"formSubmitButton\",\n              type: \"submit\",\n              children: [\"Submit\\xA0\\xA0\", /*#__PURE__*/_jsxDEV(FontAwesomeIcon, {\n                icon: \"arrow-right\"\n              }, void 0, false, {\n                fileName: _jsxFileName,\n                lineNumber: 90,\n                columnNumber: 17\n              }, this)]\n            }, void 0, true, {\n              fileName: _jsxFileName,\n              lineNumber: 88,\n              columnNumber: 15\n            }, this)]\n          }, void 0, true, {\n            fileName: _jsxFileName,\n            lineNumber: 77,\n            columnNumber: 13\n          }, this)]\n        }, void 0, true, {\n          fileName: _jsxFileName,\n          lineNumber: 75,\n          columnNumber: 11\n        }, this)\n      }, void 0, false, {\n        fileName: _jsxFileName,\n        lineNumber: 74,\n        columnNumber: 9\n      }, this)\n    }, void 0, false, {\n      fileName: _jsxFileName,\n      lineNumber: 73,\n      columnNumber: 7\n    }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n      children: /*#__PURE__*/_jsxDEV(MessageModal, {\n        removeModal: () => setSubmitOkMessageModalState(false),\n        headerMessage: \"Email submitted!\",\n        bodyMessage: \"An email with a password recovery link will be sent if it is registered in our system\"\n      }, void 0, false, {\n        fileName: _jsxFileName,\n        lineNumber: 97,\n        columnNumber: 9\n      }, this)\n    }, void 0, false, {\n      fileName: _jsxFileName,\n      lineNumber: 96,\n      columnNumber: 7\n    }, this)]\n  }, void 0, true, {\n    fileName: _jsxFileName,\n    lineNumber: 65,\n    columnNumber: 5\n  }, this);\n};\n\n_s(PasswordForgotModal, \"g4WkMIawwrBahYMYonVecg/0JA0=\");\n\n_c = PasswordForgotModal;\nexport default PasswordForgotModal;\n\nvar _c;\n\n$RefreshReg$(_c, \"PasswordForgotModal\");","map":{"version":3,"sources":["C:/Users/Bruger/Desktop/Web-projects/pipit/client/src/pages/login/passwordReset/PasswordForgotModal.jsx"],"names":["React","useState","useRef","useEffect","config","FontAwesomeIcon","MessageModal","PasswordForgotModal","forgotPasswordFormVisibilityState","setForgotPasswordFormVisibilityState","forgotPasswordFormRef","toggleForgotPasswordFormVisible","submitOkMessageModalState","setSubmitOkMessageModalState","username","setUsername","handleUsernameChange","e","target","value","pageClickEvent","current","contains","window","addEventListener","removeEventListener","userInputData","JSON","stringify","email","ForgotPasswordRequestOptions","method","body","handlePasswordForgot","preventDefault"],"mappings":";;;AAAA,OAAOA,KAAP,IAAgBC,QAAhB,EAA0BC,MAA1B,EAAkCC,SAAlC,QAAmD,OAAnD;AACA,OAAOC,MAAP,MAAmB,iBAAnB;AACA,SAASC,eAAT,QAAgC,gCAAhC;AACA,OAAO,2BAAP;AACA,OAAOC,YAAP,MAAyB,+CAAzB;;;AAEA,MAAMC,mBAAmB,GAAG,MAAM;AAAA;;AAChC,QAAM,CAACC,iCAAD,EAAoCC,oCAApC,IAA4ER,QAAQ,CAAC,KAAD,CAA1F;AACA,QAAMS,qBAAqB,GAAGR,MAAM,CAAC,IAAD,CAApC;;AACA,QAAMS,+BAA+B,GAAG,MAAMF,oCAAoC,CAAC,CAACD,iCAAF,CAAlF;;AAEA,QAAM,CAACI,yBAAD,EAA4BC,4BAA5B,IAA4DZ,QAAQ,CAAC,KAAD,CAA1E;AAEA,QAAM,CAACa,QAAD,EAAWC,WAAX,IAA0Bd,QAAQ,CAAC,EAAD,CAAxC;;AACA,QAAMe,oBAAoB,GAAIC,CAAD,IAAO;AAClCF,IAAAA,WAAW,CAACE,CAAC,CAACC,MAAF,CAASC,KAAV,CAAX;AACD,GAFD;;AAIAhB,EAAAA,SAAS,CAAC,MAAM;AACd,UAAMiB,cAAc,GAAIH,CAAD,IAAO;AAC5B,UAAIP,qBAAqB,CAACW,OAAtB,KAAkC,IAAlC,IAA0C,CAACX,qBAAqB,CAACW,OAAtB,CAA8BC,QAA9B,CAAuCL,CAAC,CAACC,MAAzC,CAA/C,EAAiG;AAC/FP,QAAAA,+BAA+B;AAChC;AACF,KAJD,C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E,EAAC,OADL;AACa,gBAAA,IAAI,EAAC,MADlB;AAEE,gBAAA,KAAK,EAAEnB,QAFT;AAGE,gBAAA,QAAQ,EAAEE;AAHZ;AAAA;AAAA;AAAA;AAAA,sBAFF;AAAA;AAAA;AAAA;AAAA;AAAA,oBADF,eAQE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBARF,eAWE;AAAQ,cAAA,SAAS,EAAC,kBAAlB;AAAqC,cAAA,IAAI,EAAC,QAA1C;AAAA,wDAEE,QAAC,eAAD;AAAiB,gBAAA,IAAI,EAAC;AAAtB;AAAA;AAAA;AAAA;AAAA,sBAFF;AAAA;AAAA;AAAA;AAAA;AAAA,oBAXF;AAAA;AAAA;AAAA;AAAA;AAAA,kBAFF;AAAA;AAAA;AAAA;AAAA;AAAA;AADF;AAAA;AAAA;AAAA;AAAA;AADF;AAAA;AAAA;AAAA;AAAA,YARF,eA+BE;AAAA,6BACE,QAAC,YAAD;AAAc,QAAA,WAAW,EAAE,MAAMH,4BAA4B,CAAC,KAAD,CAA7D;AAAsE,QAAA,aAAa,EAAE,kBAArF;AAAyG,QAAA,WAAW,EAAE;AAAtH;AAAA;AAAA;AAAA;AAAA;AADF;AAAA;AAAA;AAAA;AAAA,YA/BF;AAAA;AAAA;AAAA;AAAA;AAAA,UADF;AAsCD,CA/FD;;GAAMN,mB;;KAAAA,mB;AAiGN,eAAeA,mBAAf","sourcesContent":["import React, { useState, useRef, useEffect } from 'react'\r\nimport config from '../../../config'\r\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\r\nimport \"./PasswordForgotModal.css\"\r\nimport MessageModal from '../../../components/messageModal/MessageModal';\r\n\r\nconst PasswordForgotModal = () => {\r\n  const [forgotPasswordFormVisibilityState, setForgotPasswordFormVisibilityState] = useState(false)\r\n  const forgotPasswordFormRef = useRef(null)\r\n  const toggleForgotPasswordFormVisible = () => setForgotPasswordFormVisibilityState(!forgotPasswordFormVisibilityState)\r\n\r\n  const [submitOkMessageModalState, setSubmitOkMessageModalState] = useState(false);\r\n\r\n  const [username, setUsername] = useState('');\r\n  const handleUsernameChange = (e) => {\r\n    setUsername(e.target.value);\r\n  };\r\n\r\n  useEffect(() => {\r\n    const pageClickEvent = (e) => {\r\n      if (forgotPasswordFormRef.current !== null && !forgotPasswordFormRef.current.contains(e.target)) {\r\n        toggleForgotPasswordFormVisible()\r\n      }\r\n    };\r\n\r\n    // If the item is active (ie open) then listen for clicks\r\n    if (forgotPasswordFormVisibilityState) {\r\n      window.addEventListener('click', pageClickEvent);\r\n    }\r\n\r\n    return () => {\r\n      window.removeEventListener('click', pageClickEvent);\r\n    }\r\n\r\n  }, [forgotPasswordFormVisibilityState]);\r\n\r\n  const userInputData = JSON.stringify({\r\n    email: `${username}`,\r\n  })\r\n\r\n  const ForgotPasswordRequestOptions = {\r\n    method: 'PUT',\r\n    body: userInputData\r\n  }\r\n\r\n  const handlePasswordForgot = (e) => {\r\n    e.preventDefault();\r\n\r\n    toggleForgotPasswordFormVisible()\r\n    setSubmitOkMessageModalState(true)\r\n    // fetch(config.serviceAPI.ForgotPasswordURL, ForgotPasswordRequestOptions)\r\n    //   .then((res) => {\r\n    //     if (!res.ok) {\r\n    //       window.alert(\"Error: something went wrong\")\r\n    //       Promise.reject(\"\")\r\n    //       return\r\n    //     }\r\n    //     if (res.ok) {\r\n    //       toggleSubmitOkModalVisible()\r\n    //     }\r\n    //   })\r\n  }\r\n\r\n  return (\r\n    <div>\r\n      <div className=\"password-forgot-prompt\">\r\n        <span>\r\n          <a onClick={toggleForgotPasswordFormVisible}>Forgot password</a>\r\n        </span>\r\n      </div>\r\n\r\n      {/* Forgot password modal */}\r\n      <div className={`modal ${forgotPasswordFormVisibilityState ? \"active\" : \"inactive\"}`}>\r\n        <div ref={forgotPasswordFormRef} className=\"modal-content\">\r\n          <div className=\"recoverPasswordForm\">\r\n            <h2>Recover password</h2>\r\n            <form onSubmit={handlePasswordForgot}>\r\n              <label>\r\n                Email:\r\n                <input\r\n                  id=\"email\" type=\"text\"\r\n                  value={username}\r\n                  onChange={handleUsernameChange} />\r\n              </label>\r\n              <label>\r\n                An email with a password recovery link will be sent if it is registered in our system\r\n              </label>\r\n              <button className=\"formSubmitButton\" type=\"submit\">\r\n                Submit&nbsp;&nbsp;\r\n                <FontAwesomeIcon icon=\"arrow-right\"></FontAwesomeIcon>\r\n              </button>\r\n            </form>\r\n          </div>\r\n        </div>\r\n      </div>\r\n      <div>\r\n        <MessageModal removeModal={() => setSubmitOkMessageModalState(false)} headerMessage={\"Email submitted!\"} bodyMessage={\"An email with a password recovery link will be sent if it is registered in our system\"} />\r\n      </div>\r\n    </div>\r\n\r\n  )\r\n}\r\n\r\nexport default PasswordForgotModal\r\n"]},"metadata":{},"sourceType":"module"}