Commit a26e7d3e authored by Mathias Engelbrecht Pilegård's avatar Mathias Engelbrecht Pilegård
Browse files

fixed forgot password modal popup flow

parent 5690006f
{"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 { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\n\nconst PasswordForgotModal = props => {\n _s();\n\n const [username, setUsername] = useState('');\n const [forgotPasswordFormVisibilityState, showForgotPasswordForm] = useState(false);\n const forgotPasswordFormRef = useRef(null);\n\n const toggleForgotPasswordFormVisible = () => showForgotPasswordForm(!forgotPasswordFormVisibilityState);\n\n const handleUsernameChange = e => {\n setUsername(e.target.value);\n };\n\n useEffect(() => {\n setUsername(props.loginFormUsername);\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 ForgotPasswordRequestOptions = {\n method: 'PUT',\n body: JSON.stringify({\n email: `${username}`\n })\n };\n\n const handlePasswordForgot = () => {\n fetch(config.serviceAPI.ForgotPasswordURL, ForgotPasswordRequestOptions).then(res => {\n if (!res.ok) {\n window.alert(\"Error: something went wrong\");\n Promise.reject(\"\");\n return;\n }\n\n if (res.ok) {// do something\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: 63,\n columnNumber: 11\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 62,\n columnNumber: 9\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 61,\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: 70,\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: 74,\n columnNumber: 17\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 72,\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: 79,\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: 84,\n columnNumber: 17\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 82,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 71,\n columnNumber: 13\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 69,\n columnNumber: 11\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 68,\n columnNumber: 9\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 67,\n columnNumber: 7\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 60,\n columnNumber: 5\n }, this);\n};\n\n_s(PasswordForgotModal, \"zeJfLL+jCx5gDesxF64XnAPVU1k=\");\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","PasswordForgotModal","props","username","setUsername","forgotPasswordFormVisibilityState","showForgotPasswordForm","forgotPasswordFormRef","toggleForgotPasswordFormVisible","handleUsernameChange","e","target","value","loginFormUsername","pageClickEvent","current","contains","window","addEventListener","removeEventListener","ForgotPasswordRequestOptions","method","body","JSON","stringify","email","handlePasswordForgot","fetch","serviceAPI","ForgotPasswordURL","then","res","ok","alert","Promise","reject"],"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;;;AAEA,MAAMC,mBAAmB,GAAIC,KAAD,IAAW;AAAA;;AACrC,QAAM,CAACC,QAAD,EAAWC,WAAX,IAA0BR,QAAQ,CAAC,EAAD,CAAxC;AACA,QAAM,CAACS,iCAAD,E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AAA;AAAA;AAAA;AAAA;AAAA;AADF;AAAA;AAAA;AAAA;AAAA;AADF;AAAA;AAAA;AAAA;AAAA,YAPF;AAAA;AAAA;AAAA;AAAA;AAAA,UADF;AAkCD,CAvFD;;GAAMR,mB;;KAAAA,mB;AAyFN,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\n\r\nconst PasswordForgotModal = (props) => {\r\n const [username, setUsername] = useState('');\r\n const [forgotPasswordFormVisibilityState, showForgotPasswordForm] = useState(false)\r\n const forgotPasswordFormRef = useRef(null);\r\n const toggleForgotPasswordFormVisible = () => showForgotPasswordForm(!forgotPasswordFormVisibilityState)\r\n\r\n const handleUsernameChange = (e) => {\r\n setUsername(e.target.value);\r\n };\r\n\r\n useEffect(() => {\r\n setUsername(props.loginFormUsername)\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 ForgotPasswordRequestOptions = {\r\n method: 'PUT',\r\n body: JSON.stringify({\r\n email: `${username}`\r\n })\r\n }\r\n\r\n const handlePasswordForgot = () => {\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 // do something\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 <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\r\n )\r\n}\r\n\r\nexport default PasswordForgotModal\r\n"]},"metadata":{},"sourceType":"module"}
\ No newline at end of file
{"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 { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\n\nconst PasswordForgotModal = () => {\n _s();\n\n const [username, setUsername] = useState('');\n const [forgotPasswordFormVisibilityState, showForgotPasswordForm] = useState(false);\n const forgotPasswordFormRef = useRef(null);\n\n const toggleForgotPasswordFormVisible = () => showForgotPasswordForm(!forgotPasswordFormVisibilityState);\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 ForgotPasswordRequestOptions = {\n method: 'PUT',\n body: JSON.stringify({\n email: `${username}`\n })\n };\n\n const handlePasswordForgot = () => {\n fetch(config.serviceAPI.ForgotPasswordURL, ForgotPasswordRequestOptions).then(res => {\n if (!res.ok) {\n window.alert(\"Error: something went wrong\");\n Promise.reject(\"\");\n return;\n }\n\n if (res.ok) {// do something\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: 59,\n columnNumber: 11\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 58,\n columnNumber: 9\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 57,\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: 66,\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: 70,\n columnNumber: 17\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 68,\n columnNumber: 15\n }, this), /*#__PURE__*/_jsxDEV(\"label\", {\n children: \"An email with a password recovery link will be sent if registered is our system\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 75,\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: 80,\n columnNumber: 17\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 78,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 67,\n columnNumber: 13\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 65,\n columnNumber: 11\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 64,\n columnNumber: 9\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 63,\n columnNumber: 7\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 56,\n columnNumber: 5\n }, this);\n};\n\n_s(PasswordForgotModal, \"VvmgU4VTr5ZNKM/8uo86UTvcRWY=\");\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","PasswordForgotModal","username","setUsername","forgotPasswordFormVisibilityState","showForgotPasswordForm","forgotPasswordFormRef","toggleForgotPasswordFormVisible","handleUsernameChange","e","target","value","pageClickEvent","current","contains","window","addEventListener","removeEventListener","ForgotPasswordRequestOptions","method","body","JSON","stringify","email","handlePasswordForgot","fetch","serviceAPI","ForgotPasswordURL","then","res","ok","alert","Promise","reject"],"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;;;AAEA,MAAMC,mBAAmB,GAAG,MAAM;AAAA;;AAChC,QAAM,CAACC,QAAD,EAAWC,WAAX,IAA0BP,QAAQ,CAAC,EAAD,CAAxC;AACA,QAAM,CAACQ,iCAAD,EAAoCC,sBAApC,IAA8DT,QAAQ,CAAC,KAAD,CAA5E;AACA,QAAMU,qBAAqB,GAAGT,MAAM,CAAC,IAAD,CAApC;;AACA,QAAMU,+BAA+B,GAAG,MAAMF,sBAAsB,CAAC,CAACD,iCAAF,CAApE;;AAEA,QAAMI,oBAAoB,GAAIC,CAAD,IAAO;AAClCN,IAAAA,WAAW,CAACM,CAAC,CAACC,MAAF,CAASC,KAAV,CAAX;AACD,GAFD;;AAIAb,EAAAA,SAAS,CAAC,MAAM;AACd,UAAMc,cAAc,GAAIH,CAAD,IAAO;AAC5B,UAAIH,qBAAqB,CAACO,OAAtB,KAAkC,IAAlC,IAA0C,CAACP,qBAAqB,CAACO,OAAtB,CAA8BC,QAA9B,CAAuCL,CAAC,CAACC,MAAzC,CAA/C,EAAiG;AAC/FH,QAAAA,+BAA+B;AAChC;AACF,KAJD,CADc,CAOd;;;AACA,QAAIH,iCAAJ,EAAuC;AACrCW,MAAAA,MAAM,CAACC,gBAAP,CAAwB,OAAxB,EAAiCJ,cAAjC;AACD;;AAED,WAAO,MAAM;AACXG,MAAAA,MAAM,CAACE,mBAAP,CAA2B,OAA3B,EAAoCL,cAApC;AACD,KAFD;AAID,GAhBQ,EAgBN,CAACR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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,YAPF;AAAA;AAAA;AAAA;AAAA;AAAA,UADF;AAkCD,CAnFD;;GAAMP,mB;;KAAAA,mB;AAqFN,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\n\r\nconst PasswordForgotModal = () => {\r\n const [username, setUsername] = useState('');\r\n const [forgotPasswordFormVisibilityState, showForgotPasswordForm] = useState(false)\r\n const forgotPasswordFormRef = useRef(null);\r\n const toggleForgotPasswordFormVisible = () => showForgotPasswordForm(!forgotPasswordFormVisibilityState)\r\n\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 ForgotPasswordRequestOptions = {\r\n method: 'PUT',\r\n body: JSON.stringify({\r\n email: `${username}`\r\n })\r\n }\r\n\r\n const handlePasswordForgot = () => {\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 // do something\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 <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 registered is 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\r\n )\r\n}\r\n\r\nexport default PasswordForgotModal\r\n"]},"metadata":{},"sourceType":"module"}
\ No newline at end of file
{"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 { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\n\nconst PasswordForgotModal = ({\n loginFormUsername\n}) => {\n _s();\n\n // Submit ok modal\n const [submitOkModalVisibilityState, showSubmitOkModal] = useState(false);\n const submitOkModalRef = useRef(null);\n\n const toggleSubmitOkModalVisible = () => showSubmitOkModal(!submitOkModalVisibilityState);\n\n const [username, setUsername] = useState(loginFormUsername);\n\n const handleUsernameChange = e => {\n setUsername(e.target.value);\n };\n\n useEffect(() => {\n setUsername(username); // console.log(loginFormUsername)\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 useEffect(() => {\n const pageClickEvent = e => {\n if (submitOkModalRef.current !== null && !submitOkModalRef.current.contains(e.target)) {\n toggleSubmitOkModalVisible();\n }\n }; // If the item is active (ie open) then listen for clicks\n\n\n if (submitOkModalVisibilityState) {\n window.addEventListener('click', pageClickEvent);\n }\n\n return () => {\n window.removeEventListener('click', pageClickEvent);\n };\n }, [submitOkModalVisibilityState]);\n const ForgotPasswordRequestOptions = {\n method: 'PUT',\n body: JSON.stringify({\n email: `${username}`\n })\n };\n\n const handlePasswordForgot = () => {\n fetch(config.serviceAPI.ForgotPasswordURL, ForgotPasswordRequestOptions).then(res => {\n if (!res.ok) {\n window.alert(\"Error: something went wrong\");\n Promise.reject(\"\");\n return;\n }\n\n if (res.ok) {// toggleSubmitOkModalVisible()\n }\n });\n };\n\n return /*#__PURE__*/_jsxDEV(\"div\", {\n children: [/*#__PURE__*/_jsxDEV(\"div\", {\n className: `modal ${forgotPasswordFormVisibilityState ? \"active\" : \"inactive\"}`,\n children: /*#__PURE__*/_jsxDEV(\"div\", {\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: 86,\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: 90,\n columnNumber: 17\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 88,\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: 95,\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: 100,\n columnNumber: 17\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 98,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 87,\n columnNumber: 13\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 85,\n columnNumber: 11\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 84,\n columnNumber: 9\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 83,\n columnNumber: 7\n }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n className: `modal ${submitOkModalVisibilityState ? \"active\" : \"inactive\"}`,\n children: /*#__PURE__*/_jsxDEV(\"div\", {\n ref: submitOkModalRef,\n className: \"modal-content\",\n children: /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"submitOkModal\",\n children: [/*#__PURE__*/_jsxDEV(\"h2\", {\n children: \"Email submitted!\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 111,\n columnNumber: 13\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: 112,\n columnNumber: 13\n }, this), /*#__PURE__*/_jsxDEV(\"button\", {\n className: \"formSubmitButton\",\n type: \"submit\",\n children: \"Ok\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 115,\n columnNumber: 13\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 110,\n columnNumber: 11\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 109,\n columnNumber: 9\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 108,\n columnNumber: 7\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 81,\n columnNumber: 5\n }, this);\n};\n\n_s(PasswordForgotModal, \"4JQ+BydsYPYsI/pVH30y+5l9pH8=\");\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","PasswordForgotModal","loginFormUsername","submitOkModalVisibilityState","showSubmitOkModal","submitOkModalRef","toggleSubmitOkModalVisible","username","setUsername","handleUsernameChange","e","target","value","pageClickEvent","forgotPasswordFormRef","current","contains","toggleForgotPasswordFormVisible","forgotPasswordFormVisibilityState","window","addEventListener","removeEventListener","ForgotPasswordRequestOptions","method","body","JSON","stringify","email","handlePasswordForgot","fetch","serviceAPI","ForgotPasswordURL","then","res","ok","alert","Promise","reject"],"mappings":";;;AAAA,OAA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A;AAAA,UADF;AA4CD,CAtHD;;GAAMJ,mB;;KAAAA,mB;AAwHN,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\n\r\nconst PasswordForgotModal = ({ loginFormUsername }) => {\r\n // Submit ok modal\r\n const [submitOkModalVisibilityState, showSubmitOkModal] = useState(false)\r\n const submitOkModalRef = useRef(null)\r\n const toggleSubmitOkModalVisible = () => showSubmitOkModal(!submitOkModalVisibilityState)\r\n\r\n const [username, setUsername] = useState(loginFormUsername);\r\n\r\n const handleUsernameChange = (e) => {\r\n setUsername(e.target.value);\r\n };\r\n\r\n useEffect(() => {\r\n setUsername(username)\r\n // console.log(loginFormUsername)\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 useEffect(() => {\r\n const pageClickEvent = (e) => {\r\n if (submitOkModalRef.current !== null && !submitOkModalRef.current.contains(e.target)) {\r\n toggleSubmitOkModalVisible()\r\n }\r\n };\r\n\r\n // If the item is active (ie open) then listen for clicks\r\n if (submitOkModalVisibilityState) {\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 }, [submitOkModalVisibilityState]);\r\n\r\n const ForgotPasswordRequestOptions = {\r\n method: 'PUT',\r\n body: JSON.stringify({\r\n email: `${username}`\r\n })\r\n }\r\n\r\n const handlePasswordForgot = () => {\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 {/* Forgot password modal */}\r\n <div className={`modal ${forgotPasswordFormVisibilityState ? \"active\" : \"inactive\"}`}>\r\n <div 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\r\n {/* SubmitOk modal */}\r\n <div className={`modal ${submitOkModalVisibilityState ? \"active\" : \"inactive\"}`}>\r\n <div ref={submitOkModalRef} className=\"modal-content\">\r\n <div className=\"submitOkModal\">\r\n <h2>Email submitted!</h2>\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 Ok\r\n </button>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n )\r\n}\r\n\r\nexport default PasswordForgotModal\r\n"]},"metadata":{},"sourceType":"module"}
\ No newline at end of file
{"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 { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\n\nconst PasswordForgotModal = loginFormUsername => {\n _s();\n\n const [username, setUsername] = useState('');\n const [forgotPasswordFormVisibilityState, showForgotPasswordForm] = useState(false);\n const forgotPasswordFormRef = useRef(null);\n\n const toggleForgotPasswordFormVisible = () => showForgotPasswordForm(!forgotPasswordFormVisibilityState);\n\n const handleUsernameChange = e => {\n setUsername(e.target.value);\n };\n\n useEffect(() => {\n handleUsernameChange(loginFormUsername);\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 ForgotPasswordRequestOptions = {\n method: 'PUT',\n body: JSON.stringify({\n email: `${username}`\n })\n };\n\n const handlePasswordForgot = () => {\n fetch(config.serviceAPI.ForgotPasswordURL, ForgotPasswordRequestOptions).then(res => {\n if (!res.ok) {\n window.alert(\"Error: something went wrong\");\n Promise.reject(\"\");\n return;\n }\n\n if (res.ok) {// do something\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: 63,\n columnNumber: 11\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 62,\n columnNumber: 9\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 61,\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: 70,\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: 74,\n columnNumber: 17\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 72,\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: 79,\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: 84,\n columnNumber: 17\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 82,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 71,\n columnNumber: 13\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 69,\n columnNumber: 11\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 68,\n columnNumber: 9\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 67,\n columnNumber: 7\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 60,\n columnNumber: 5\n }, this);\n};\n\n_s(PasswordForgotModal, \"zeJfLL+jCx5gDesxF64XnAPVU1k=\");\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","PasswordForgotModal","loginFormUsername","username","setUsername","forgotPasswordFormVisibilityState","showForgotPasswordForm","forgotPasswordFormRef","toggleForgotPasswordFormVisible","handleUsernameChange","e","target","value","pageClickEvent","current","contains","window","addEventListener","removeEventListener","ForgotPasswordRequestOptions","method","body","JSON","stringify","email","handlePasswordForgot","fetch","serviceAPI","ForgotPasswordURL","then","res","ok","alert","Promise","reject"],"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;;;AAEA,MAAMC,mBAAmB,GAAIC,iBAAD,IAAuB;AAAA;;AACjD,QAAM,CAACC,QAAD,EAAWC,WAAX,IAA0BR,QAAQ,CAAC,EAAD,CAAxC;AACA,QAAM,CAACS,iCAAD,EAAoCC,sBAApC,IAA8DV,QAAQ,CAAC,KAAD,CAA5E;AACA,QAAMW,qBAAqB,GAAGV,MAAM,CAAC,IAAD,CAApC;;AACA,QAAMW,+BAA+B,GAAG,MAAMF,sBAAsB,CAAC,CAACD,iCAAF,CAApE;;AAEA,QAAMI,oBAAoB,GAAIC,CAAD,IAAO;AAClCN,IAAAA,WAAW,CAACM,CAAC,CAACC,MAAF,CAASC,KAAV,CAAX;AACD,GAFD;;AAIAd,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AEvB,+BAAZ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AADF;AAAA;AAAA;AAAA;AAAA;AADF;AAAA;AAAA;AAAA;AAAA,YADF,eAOE;AAAK,MAAA,SAAS,EAAG,SAAQH,iCAAiC,GAAG,QAAH,GAAc,UAAW,EAAnF;AAAA,6BACE;AAAK,QAAA,GAAG,EAAEE,qBAAV;AAAiC,QAAA,SAAS,EAAC,eAA3C;AAAA,+BACE;AAAK,UAAA,SAAS,EAAC,qBAAf;AAAA,kCACE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBADF,eAEE;AAAM,YAAA,QAAQ,EAAEkB,oBAAhB;AAAA,oCACE;AAAA,gDAEE;AACE,gBAAA,EAAE,EAAC,OADL;AACa,gBAAA,IAAI,EAAC,MADlB;AAEE,gBAAA,KAAK,EAAEtB,QAFT;AAGE,gBAAA,QAAQ,EAAEM;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,YAPF;AAAA;AAAA;AAAA;AAAA;AAAA,UADF;AAkCD,CAvFD;;GAAMR,mB;;KAAAA,mB;AAyFN,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\n\r\nconst PasswordForgotModal = (loginFormUsername) => {\r\n const [username, setUsername] = useState('');\r\n const [forgotPasswordFormVisibilityState, showForgotPasswordForm] = useState(false)\r\n const forgotPasswordFormRef = useRef(null);\r\n const toggleForgotPasswordFormVisible = () => showForgotPasswordForm(!forgotPasswordFormVisibilityState)\r\n\r\n const handleUsernameChange = (e) => {\r\n setUsername(e.target.value);\r\n };\r\n\r\n useEffect(() => {\r\n handleUsernameChange(loginFormUsername)\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 ForgotPasswordRequestOptions = {\r\n method: 'PUT',\r\n body: JSON.stringify({\r\n email: `${username}`\r\n })\r\n }\r\n\r\n const handlePasswordForgot = () => {\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 // do something\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 <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\r\n )\r\n}\r\n\r\nexport default PasswordForgotModal\r\n"]},"metadata":{},"sourceType":"module"}
\ No newline at end of file
{"ast":null,"code":"var _jsxFileName = \"C:\\\\Users\\\\Bruger\\\\Desktop\\\\Web-projects\\\\pipit\\\\client\\\\src\\\\pages\\\\login\\\\Login.jsx\",\n _s = $RefreshSig$();\n\nimport React, { useState, useEffect, useRef } from 'react';\nimport { Redirect } from 'react-router-dom';\nimport { useOktaAuth } from '@okta/okta-react';\nimport \"./Login.css\";\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\nimport { NavLink } from 'react-router-dom';\nimport signUp from './signUp/SignUp';\nimport config from '../../config';\nimport SignUp from './signUp/SignUp';\nimport PasswordForgotModal from './passwordReset/PasswordForgotModal';\nimport { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\n\nconst Login = () => {\n _s();\n\n const {\n authState,\n oktaAuth\n } = useOktaAuth();\n const [sessionToken, setSessionToken] = useState();\n const [username, setUsername] = useState('');\n const [password, setPassword] = useState('');\n\n const getCurrentStateUsername = () => {\n return username;\n };\n\n const handleUsernameChange = e => {\n setUsername(e.target.value);\n };\n\n const handlePasswordChange = e => {\n setPassword(e.target.value);\n };\n\n const userInputData = JSON.stringify({\n email: `${username}`,\n password: `${password}`\n });\n const loginRequestOptions = {\n method: 'POST',\n body: userInputData\n };\n\n const handleSignInFormSubmit = e => {\n e.preventDefault();\n oktaAuth.signInWithCredentials({\n username,\n password\n }).then(res => {\n const sessionToken = res.sessionToken;\n setSessionToken(sessionToken); // sessionToken is a one-use token, so make sure this is only called once\n\n oktaAuth.signInWithRedirect({\n sessionToken,\n originalUri: '/home'\n });\n }).catch(err => console.log('Found an error', err));\n };\n\n if (sessionToken) {\n // Hide form while sessionToken is converted into id/access tokens\n return null;\n }\n\n if (!authState || !authState.isAuthenticated) {\n return /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"pageContainer\",\n children: [/*#__PURE__*/_jsxDEV(SignUp, {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 62,\n columnNumber: 9\n }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"signInForm\",\n children: [/*#__PURE__*/_jsxDEV(\"h2\", {\n children: \"Sign in to PipIt\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 65,\n columnNumber: 11\n }, this), /*#__PURE__*/_jsxDEV(\"form\", {\n onSubmit: handleSignInFormSubmit,\n children: [/*#__PURE__*/_jsxDEV(\"label\", {\n children: [\"Email:\", /*#__PURE__*/_jsxDEV(\"input\", {\n id: \"username\",\n type: \"text\",\n value: username,\n onChange: handleUsernameChange\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 69,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 67,\n columnNumber: 13\n }, this), /*#__PURE__*/_jsxDEV(\"label\", {\n children: [\"Password:\", /*#__PURE__*/_jsxDEV(\"input\", {\n id: \"password\",\n type: \"password\",\n value: password,\n onChange: handlePasswordChange\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 76,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 74,\n columnNumber: 13\n }, this), /*#__PURE__*/_jsxDEV(\"button\", {\n className: \"formSubmitButton\",\n type: \"submit\",\n children: [\"Sign in\\xA0\\xA0\", /*#__PURE__*/_jsxDEV(FontAwesomeIcon, {\n icon: \"sign-in-alt\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 83,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 81,\n columnNumber: 13\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 66,\n columnNumber: 11\n }, this), /*#__PURE__*/_jsxDEV(PasswordForgotModal, {\n loginFormUsername: getCurrentStateUsername()\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 86,\n columnNumber: 11\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 64,\n columnNumber: 9\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 61,\n columnNumber: 7\n }, this);\n } else {\n return /*#__PURE__*/_jsxDEV(Redirect, {\n to: \"/home\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 91,\n columnNumber: 12\n }, this);\n }\n};\n\n_s(Login, \"u8yY6NlW4PSOG6xgLhGhaVL5lVE=\", false, function () {\n return [useOktaAuth];\n});\n\n_c = Login;\nexport default Login;\n\nvar _c;\n\n$RefreshReg$(_c, \"Login\");","map":{"version":3,"sources":["C:/Users/Bruger/Desktop/Web-projects/pipit/client/src/pages/login/Login.jsx"],"names":["React","useState","useEffect","useRef","Redirect","useOktaAuth","FontAwesomeIcon","NavLink","signUp","config","SignUp","PasswordForgotModal","Login","authState","oktaAuth","sessionToken","setSessionToken","username","setUsername","password","setPassword","getCurrentStateUsername","handleUsernameChange","e","target","value","handlePasswordChange","userInputData","JSON","stringify","email","loginRequestOptions","method","body","handleSignInFormSubmit","preventDefault","signInWithCredentials","then","res","signInWithRedirect","originalUri","catch","err","console","log","isAuthenticated"],"mappings":";;;AAAA,OAAOA,KAAP,IAAgBC,QAAhB,EAA0BC,SAA1B,EAAqCC,MAArC,QAAmD,OAAnD;AACA,SAASC,QAAT,QAAyB,kBAAzB;AACA,SAASC,WAAT,QAA4B,kBAA5B;AACA,OAAO,aAAP;AACA,SAASC,eAAT,QAAgC,gCAAhC;AACA,SAASC,OAAT,QAAwB,kBAAxB;AACA,OAAOC,MAAP,MAAmB,iBAAnB;AACA,OAAOC,MAAP,MAAmB,cA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A;AAAA,gBAFF,eAsBE,QAAC,mBAAD;AAAqB,UAAA,iBAAiB,EAAEL,uBAAuB;AAA/D;AAAA;AAAA;AAAA;AAAA,gBAtBF;AAAA;AAAA;AAAA;AAAA;AAAA,cAHF;AAAA;AAAA;AAAA;AAAA;AAAA,YADF;AA8BD,GA/BD,MA+BO;AACL,wBAAO,QAAC,QAAD;AAAU,MAAA,EAAE,EAAC;AAAb;AAAA;AAAA;AAAA;AAAA,YAAP;AACD;AACF,CAjFD;;GAAMT,K;UAC4BP,W;;;KAD5BO,K;AAmFN,eAAeA,KAAf","sourcesContent":["import React, { useState, useEffect, useRef } from 'react';\r\nimport { Redirect } from 'react-router-dom'\r\nimport { useOktaAuth } from '@okta/okta-react';\r\nimport \"./Login.css\"\r\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome'\r\nimport { NavLink } from 'react-router-dom';\r\nimport signUp from './signUp/SignUp';\r\nimport config from '../../config';\r\nimport SignUp from './signUp/SignUp';\r\nimport PasswordForgotModal from './passwordReset/PasswordForgotModal';\r\n\r\nconst Login = () => {\r\n const { authState, oktaAuth } = useOktaAuth();\r\n const [sessionToken, setSessionToken] = useState()\r\n\r\n const [username, setUsername] = useState('');\r\n const [password, setPassword] = useState('');\r\n\r\n const getCurrentStateUsername = () => {\r\n return username\r\n }\r\n\r\n const handleUsernameChange = (e) => {\r\n setUsername(e.target.value);\r\n };\r\n\r\n const handlePasswordChange = (e) => {\r\n setPassword(e.target.value)\r\n }\r\n\r\n const userInputData = JSON.stringify({\r\n email: `${username}`,\r\n password: `${password}`\r\n })\r\n\r\n const loginRequestOptions = {\r\n method: 'POST',\r\n body: userInputData\r\n };\r\n\r\n const handleSignInFormSubmit = (e) => {\r\n e.preventDefault();\r\n\r\n oktaAuth.signInWithCredentials({ username, password })\r\n .then(res => {\r\n const sessionToken = res.sessionToken;\r\n setSessionToken(sessionToken);\r\n // sessionToken is a one-use token, so make sure this is only called once\r\n oktaAuth.signInWithRedirect({ sessionToken, originalUri: '/home' });\r\n })\r\n .catch(err => console.log('Found an error', err));\r\n };\r\n\r\n if (sessionToken) {\r\n // Hide form while sessionToken is converted into id/access tokens\r\n return null;\r\n }\r\n\r\n if (!authState || !authState.isAuthenticated) {\r\n return (\r\n <div className=\"pageContainer\">\r\n <SignUp />\r\n\r\n <div className=\"signInForm\">\r\n <h2>Sign in to PipIt</h2>\r\n <form onSubmit={handleSignInFormSubmit}>\r\n <label>\r\n Email:\r\n <input\r\n id=\"username\" type=\"text\"\r\n value={username}\r\n onChange={handleUsernameChange} />\r\n </label>\r\n <label>\r\n Password:\r\n <input\r\n id=\"password\" type=\"password\"\r\n value={password}\r\n onChange={handlePasswordChange} />\r\n </label>\r\n <button className=\"formSubmitButton\" type=\"submit\">\r\n Sign in&nbsp;&nbsp;\r\n <FontAwesomeIcon icon=\"sign-in-alt\"></FontAwesomeIcon>\r\n </button>\r\n </form>\r\n <PasswordForgotModal loginFormUsername={getCurrentStateUsername()} />\r\n </div>\r\n </div>\r\n )\r\n } else {\r\n return <Redirect to=\"/home\" />\r\n }\r\n}\r\n\r\nexport default Login"]},"metadata":{},"sourceType":"module"}
\ No newline at end of file
{"ast":null,"code":"var _jsxFileName = \"C:\\\\Users\\\\Bruger\\\\Desktop\\\\Web-projects\\\\pipit\\\\client\\\\src\\\\pages\\\\login\\\\Login.jsx\",\n _s = $RefreshSig$();\n\nimport React, { useState, useEffect, useRef } from 'react';\nimport { Redirect } from 'react-router-dom';\nimport { useOktaAuth } from '@okta/okta-react';\nimport \"./Login.css\";\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\nimport { NavLink } from 'react-router-dom';\nimport signUp from './signUp/SignUp';\nimport config from '../../config';\nimport SignUp from './signUp/SignUp';\nimport PasswordForgotModal from './passwordReset/PasswordForgotModal';\nimport { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\n\nconst Login = () => {\n _s();\n\n const {\n authState,\n oktaAuth\n } = useOktaAuth();\n const [sessionToken, setSessionToken] = useState();\n const [username, setUsername] = useState('');\n const [password, setPassword] = useState('');\n const [forgotUsername, setForgotUsername] = useState('');\n useEffect(() => {\n setForgotUsername(username);\n console.log(forgotUsername);\n }, [username]);\n\n const handleUsernameChange = e => {\n setUsername(e.target.value);\n };\n\n const handlePasswordChange = e => {\n setPassword(e.target.value);\n };\n\n const userInputData = JSON.stringify({\n email: `${username}`,\n password: `${password}`\n });\n const loginRequestOptions = {\n method: 'POST',\n body: userInputData\n };\n\n const handleSignInFormSubmit = e => {\n e.preventDefault();\n oktaAuth.signInWithCredentials({\n username,\n password\n }).then(res => {\n const sessionToken = res.sessionToken;\n setSessionToken(sessionToken); // sessionToken is a one-use token, so make sure this is only called once\n\n oktaAuth.signInWithRedirect({\n sessionToken,\n originalUri: '/home'\n });\n }).catch(err => console.log('Found an error', err));\n };\n\n if (sessionToken) {\n // Hide form while sessionToken is converted into id/access tokens\n return null;\n }\n\n if (!authState || !authState.isAuthenticated) {\n return /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"pageContainer\",\n children: [/*#__PURE__*/_jsxDEV(SignUp, {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 65,\n columnNumber: 9\n }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"signInForm\",\n children: [/*#__PURE__*/_jsxDEV(\"h2\", {\n children: \"Sign in to PipIt\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 68,\n columnNumber: 11\n }, this), /*#__PURE__*/_jsxDEV(\"form\", {\n onSubmit: handleSignInFormSubmit,\n children: [/*#__PURE__*/_jsxDEV(\"label\", {\n children: [\"Email:\", /*#__PURE__*/_jsxDEV(\"input\", {\n id: \"username\",\n type: \"text\",\n value: username,\n onChange: handleUsernameChange\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 72,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 70,\n columnNumber: 13\n }, this), /*#__PURE__*/_jsxDEV(\"label\", {\n children: [\"Password:\", /*#__PURE__*/_jsxDEV(\"input\", {\n id: \"password\",\n type: \"password\",\n value: password,\n onChange: handlePasswordChange\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 79,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 77,\n columnNumber: 13\n }, this), /*#__PURE__*/_jsxDEV(\"button\", {\n className: \"formSubmitButton\",\n type: \"submit\",\n children: [\"Sign in\\xA0\\xA0\", /*#__PURE__*/_jsxDEV(FontAwesomeIcon, {\n icon: \"sign-in-alt\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 86,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 84,\n columnNumber: 13\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 69,\n columnNumber: 11\n }, this), /*#__PURE__*/_jsxDEV(PasswordForgotModal, {\n loginFormUsername: username\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 89,\n columnNumber: 11\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 67,\n columnNumber: 9\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 64,\n columnNumber: 7\n }, this);\n } else {\n return /*#__PURE__*/_jsxDEV(Redirect, {\n to: \"/home\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 94,\n columnNumber: 12\n }, this);\n }\n};\n\n_s(Login, \"8cak91jM2hAuqTZEX5oSChwgzO4=\", false, function () {\n return [useOktaAuth];\n});\n\n_c = Login;\nexport default Login;\n\nvar _c;\n\n$RefreshReg$(_c, \"Login\");","map":{"version":3,"sources":["C:/Users/Bruger/Desktop/Web-projects/pipit/client/src/pages/login/Login.jsx"],"names":["React","useState","useEffect","useRef","Redirect","useOktaAuth","FontAwesomeIcon","NavLink","signUp","config","SignUp","PasswordForgotModal","Login","authState","oktaAuth","sessionToken","setSessionToken","username","setUsername","password","setPassword","forgotUsername","setForgotUsername","console","log","handleUsernameChange","e","target","value","handlePasswordChange","userInputData","JSON","stringify","email","loginRequestOptions","method","body","handleSignInFormSubmit","preventDefault","signInWithCredentials","then","res","signInWithRedirect","originalUri","catch","err","isAuthenticated"],"mappings":";;;AAAA,OAAOA,KAAP,IAAgBC,QAAhB,EAA0BC,SAA1B,EAAqCC,MAArC,QAAmD,OAAnD;AACA,SAASC,QAAT,QAAyB,kBAAzB;AACA,SAASC,WAAT,QAA4B,kBAA5B;AACA,OAAO,aAAP;AACA,SAASC,eAAT,QAAgC,gCAAhC;AACA,SAASC,OAAT,QAAwB,kBAAxB;AACA,OAAOC,MAAP,MAAmB,iBAAnB;AACA,OAAOC,MAAP,MAAmB,cAAnB;AACA,OAAOC,MAAP,MAAmB,iBAAnB;AACA,OAAOC,mBAAP,MAAgC,qCAAhC;;;AAEA,MAAMC,KAAK,GAAG,MAAM;AAAA;;AAClB,QAAM;AAAEC,IAAAA,SAAF;AAAaC,IAAAA;AAAb,MAA0BT,WAAW,EAA3C;AACA,QAAM,CAACU,YAAD,EAAeC,eAAf,IAAkCf,QAAQ,EAAhD;AAEA,QAAM,CAACgB,QAAD,EAAWC,WAAX,IAA0BjB,QAAQ,CAAC,EAAD,CAAxC;AACA,QAAM,CAACkB,QAAD,EAAWC,WAAX,IAA0BnB,QAAQ,CAAC,EAAD,CAAxC;AACA,QAAM,CAACoB,cAAD,EAAiBC,iBAAjB,IAAsCrB,QAAQ,CAAC,EAAD,CAApD;AAGAC,EAAAA,SAAS,CAAC,MAAM;AACdoB,IAAAA,iBAAiB,CAACL,QAAD,CAAjB;AACAM,IAAAA,OAAO,CAACC,GAAR,CAAYH,cAAZ;AACD,GAHQ,EAGN,CAACJ,QAAD,CAHM,CAAT;;AAKA,QAAMQ,oBAAoB,GAAIC,CAAD,IAAO;AAClCR,IAAAA,WAAW,CAACQ,CAAC,CAACC,MAAF,CAASC,KAAV,CAAX;AACD,GAFD;;AAIA,QAAMC,oBAAoB,GAA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AAAA,8CAEE;AACE,cAAA,EAAE,EAAC,UADL;AACgB,cAAA,IAAI,EAAC,MADrB;AAEE,cAAA,KAAK,EAAEpB,QAFT;AAGE,cAAA,QAAQ,EAAEQ;AAHZ;AAAA;AAAA;AAAA;AAAA,oBAFF;AAAA;AAAA;AAAA;AAAA;AAAA,kBADF,eAQE;AAAA,iDAEE;AACE,cAAA,EAAE,EAAC,UADL;AACgB,cAAA,IAAI,EAAC,UADrB;AAEE,cAAA,KAAK,EAAEN,QAFT;AAGE,cAAA,QAAQ,EAAEU;AAHZ;AAAA;AAAA;AAAA;AAAA,oBAFF;AAAA;AAAA;AAAA;AAAA;AAAA,kBARF,eAeE;AAAQ,YAAA,SAAS,EAAC,kBAAlB;AAAqC,YAAA,IAAI,EAAC,QAA1C;AAAA,uDAEE,QAAC,eAAD;AAAiB,cAAA,IAAI,EAAC;AAAtB;AAAA;AAAA;AAAA;AAAA,oBAFF;AAAA;AAAA;AAAA;AAAA;AAAA,kBAfF;AAAA;AAAA;AAAA;AAAA;AAAA,gBAFF,eAsBE,QAAC,mBAAD;AAAqB,UAAA,iBAAiB,EAAEZ;AAAxC;AAAA;AAAA;AAAA;AAAA,gBAtBF;AAAA;AAAA;AAAA;AAAA;AAAA,cAHF;AAAA;AAAA;AAAA;AAAA;AAAA,YADF;AA8BD,GA/BD,MA+BO;AACL,wBAAO,QAAC,QAAD;AAAU,MAAA,EAAE,EAAC;AAAb;AAAA;AAAA;AAAA;AAAA,YAAP;AACD;AACF,CApFD;;GAAML,K;UAC4BP,W;;;KAD5BO,K;AAsFN,eAAeA,KAAf","sourcesContent":["import React, { useState, useEffect, useRef } from 'react';\r\nimport { Redirect } from 'react-router-dom'\r\nimport { useOktaAuth } from '@okta/okta-react';\r\nimport \"./Login.css\"\r\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome'\r\nimport { NavLink } from 'react-router-dom';\r\nimport signUp from './signUp/SignUp';\r\nimport config from '../../config';\r\nimport SignUp from './signUp/SignUp';\r\nimport PasswordForgotModal from './passwordReset/PasswordForgotModal';\r\n\r\nconst Login = () => {\r\n const { authState, oktaAuth } = useOktaAuth();\r\n const [sessionToken, setSessionToken] = useState()\r\n\r\n const [username, setUsername] = useState('');\r\n const [password, setPassword] = useState('');\r\n const [forgotUsername, setForgotUsername] = useState('')\r\n\r\n\r\n useEffect(() => {\r\n setForgotUsername(username)\r\n console.log(forgotUsername)\r\n }, [username])\r\n\r\n const handleUsernameChange = (e) => {\r\n setUsername(e.target.value);\r\n };\r\n\r\n const handlePasswordChange = (e) => {\r\n setPassword(e.target.value)\r\n }\r\n\r\n const userInputData = JSON.stringify({\r\n email: `${username}`,\r\n password: `${password}`\r\n })\r\n\r\n const loginRequestOptions = {\r\n method: 'POST',\r\n body: userInputData\r\n };\r\n\r\n const handleSignInFormSubmit = (e) => {\r\n e.preventDefault();\r\n\r\n oktaAuth.signInWithCredentials({ username, password })\r\n .then(res => {\r\n const sessionToken = res.sessionToken;\r\n setSessionToken(sessionToken);\r\n // sessionToken is a one-use token, so make sure this is only called once\r\n oktaAuth.signInWithRedirect({ sessionToken, originalUri: '/home' });\r\n })\r\n .catch(err => console.log('Found an error', err));\r\n };\r\n\r\n if (sessionToken) {\r\n // Hide form while sessionToken is converted into id/access tokens\r\n return null;\r\n }\r\n\r\n if (!authState || !authState.isAuthenticated) {\r\n return (\r\n <div className=\"pageContainer\">\r\n <SignUp />\r\n\r\n <div className=\"signInForm\">\r\n <h2>Sign in to PipIt</h2>\r\n <form onSubmit={handleSignInFormSubmit}>\r\n <label>\r\n Email:\r\n <input\r\n id=\"username\" type=\"text\"\r\n value={username}\r\n onChange={handleUsernameChange} />\r\n </label>\r\n <label>\r\n Password:\r\n <input\r\n id=\"password\" type=\"password\"\r\n value={password}\r\n onChange={handlePasswordChange} />\r\n </label>\r\n <button className=\"formSubmitButton\" type=\"submit\">\r\n Sign in&nbsp;&nbsp;\r\n <FontAwesomeIcon icon=\"sign-in-alt\"></FontAwesomeIcon>\r\n </button>\r\n </form>\r\n <PasswordForgotModal loginFormUsername={username} />\r\n </div>\r\n </div>\r\n )\r\n } else {\r\n return <Redirect to=\"/home\" />\r\n }\r\n}\r\n\r\nexport default Login"]},"metadata":{},"sourceType":"module"}
\ No newline at end of file
{"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'; // TODO : Clean up and make more like the message modal component\n\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 fetch(config.serviceAPI.forgotPasswordURL, ForgotPasswordRequestOptions).then(res => {\n if (!res.ok) {\n window.alert(\"Error: something went wrong\");\n console.log(res);\n Promise.reject(\"\");\n return;\n }\n\n if (res.ok) {\n toggleForgotPasswordFormVisible();\n setSubmitOkMessageModalState(true);\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: 71,\n columnNumber: 11\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 70,\n columnNumber: 9\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 69,\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: 79,\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: 83,\n columnNumber: 17\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 81,\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: 88,\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: 93,\n columnNumber: 17\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 91,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 80,\n columnNumber: 13\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 78,\n columnNumber: 11\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 77,\n columnNumber: 9\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 76,\n columnNumber: 7\n }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n className: `modal ${submitOkMessageModalState ? \"active\" : \"inactive\"}`,\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: 100,\n columnNumber: 9\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 99,\n columnNumber: 7\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 68,\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","fetch","serviceAPI","forgotPasswordURL","then","res","ok","alert","console","log","Promise","reject"],"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,C,CAGA;;;;AACA,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;;AAEA,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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mB;AAkGN,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\n\r\n// TODO : Clean up and make more like the message modal component\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\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 fetch(config.serviceAPI.forgotPasswordURL, ForgotPasswordRequestOptions)\r\n .then((res) => {\r\n if (!res.ok) {\r\n window.alert(\"Error: something went wrong\")\r\n console.log(res)\r\n Promise.reject(\"\")\r\n return\r\n }\r\n if (res.ok) {\r\n toggleForgotPasswordFormVisible()\r\n setSubmitOkMessageModalState(true)\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 className={`modal ${submitOkMessageModalState ? \"active\" : \"inactive\"}`}>\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"}
\ No newline at end of file
{"ast":null,"code":"var _jsxFileName = \"C:\\\\Users\\\\Bruger\\\\Desktop\\\\Web-projects\\\\pipit\\\\client\\\\src\\\\pages\\\\login\\\\Login.jsx\",\n _s = $RefreshSig$();\n\nimport React, { useState, useEffect, useRef } from 'react';\nimport { Redirect } from 'react-router-dom';\nimport { useOktaAuth } from '@okta/okta-react';\nimport \"./Login.css\";\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\nimport { NavLink } from 'react-router-dom';\nimport signUp from './signUp/SignUp';\nimport config from '../../config';\nimport SignUp from './signUp/SignUp';\nimport PasswordForgotModal from './passwordReset/PasswordForgotModal';\nimport { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\n\nconst Login = () => {\n _s();\n\n const {\n authState,\n oktaAuth\n } = useOktaAuth();\n const [sessionToken, setSessionToken] = useState(); // Forgot password form\n\n const [forgotPasswordFormVisibilityState, showForgotPasswordForm] = useState(false);\n const forgotPasswordFormRef = useRef(null);\n\n const toggleForgotPasswordFormVisible = () => showForgotPasswordForm(!forgotPasswordFormVisibilityState); // Submit ok modal\n\n\n const [submitOkModalVisibilityState, showSubmitOkModal] = useState(false);\n const submitOkModalRef = useRef(null);\n\n const toggleSubmitOkModalVisible = () => showSubmitOkModal(!submitOkModalVisibilityState);\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 useEffect(() => {\n const pageClickEvent = e => {\n if (submitOkModalRef.current !== null && !submitOkModalRef.current.contains(e.target)) {\n toggleSubmitOkModalVisible();\n }\n }; // If the item is active (ie open) then listen for clicks\n\n\n if (submitOkModalVisibilityState) {\n window.addEventListener('click', pageClickEvent);\n }\n\n return () => {\n window.removeEventListener('click', pageClickEvent);\n };\n }, [submitOkModalVisibilityState]);\n const [username, setUsername] = useState('');\n const [password, setPassword] = useState('');\n\n const handleUsernameChange = e => {\n setUsername(e.target.value);\n };\n\n const handlePasswordChange = e => {\n setPassword(e.target.value);\n };\n\n const userInputData = JSON.stringify({\n email: `${username}`,\n password: `${password}`\n });\n const loginRequestOptions = {\n method: 'POST',\n body: userInputData\n };\n const ForgotPasswordRequestOptions = {\n method: 'PUT',\n body: JSON.stringify({\n email: `${username}`\n })\n };\n\n const handlePasswordForgot = () => {\n fetch(config.serviceAPI.ForgotPasswordURL, ForgotPasswordRequestOptions).then(res => {\n if (!res.ok) {\n window.alert(\"Error: something went wrong\");\n Promise.reject(\"\");\n return;\n }\n\n if (res.ok) {// toggleSubmitOkModalVisible()\n }\n });\n };\n\n const handleSignInFormSubmit = e => {\n e.preventDefault();\n oktaAuth.signInWithCredentials({\n username,\n password\n }).then(res => {\n const sessionToken = res.sessionToken;\n setSessionToken(sessionToken); // sessionToken is a one-use token, so make sure this is only called once\n\n oktaAuth.signInWithRedirect({\n sessionToken,\n originalUri: '/home'\n });\n }).catch(err => console.log('Found an error', err));\n };\n\n if (sessionToken) {\n // Hide form while sessionToken is converted into id/access tokens\n return null;\n }\n\n if (!authState || !authState.isAuthenticated) {\n return /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"pageContainer\",\n children: [/*#__PURE__*/_jsxDEV(SignUp, {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 125,\n columnNumber: 9\n }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"signInForm\",\n children: [/*#__PURE__*/_jsxDEV(\"h2\", {\n children: \"Sign in to PipIt\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 128,\n columnNumber: 11\n }, this), /*#__PURE__*/_jsxDEV(\"form\", {\n onSubmit: handleSignInFormSubmit,\n children: [/*#__PURE__*/_jsxDEV(\"label\", {\n children: [\"Email:\", /*#__PURE__*/_jsxDEV(\"input\", {\n id: \"username\",\n type: \"text\",\n value: username,\n onChange: handleUsernameChange\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 132,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 130,\n columnNumber: 13\n }, this), /*#__PURE__*/_jsxDEV(\"label\", {\n children: [\"Password:\", /*#__PURE__*/_jsxDEV(\"input\", {\n id: \"password\",\n type: \"password\",\n value: password,\n onChange: handlePasswordChange\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 139,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 137,\n columnNumber: 13\n }, this), /*#__PURE__*/_jsxDEV(\"button\", {\n className: \"formSubmitButton\",\n type: \"submit\",\n children: [\"Sign in\\xA0\\xA0\", /*#__PURE__*/_jsxDEV(FontAwesomeIcon, {\n icon: \"sign-in-alt\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 146,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 144,\n columnNumber: 13\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 129,\n columnNumber: 11\n }, this), /*#__PURE__*/_jsxDEV(PasswordForgotModal, {\n onStateChange: handleUsernameChange\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 149,\n columnNumber: 11\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 127,\n columnNumber: 9\n }, this), /*#__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: 154,\n columnNumber: 13\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 153,\n columnNumber: 11\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 152,\n columnNumber: 9\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: 162,\n columnNumber: 15\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: 166,\n columnNumber: 19\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 164,\n columnNumber: 17\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: 171,\n columnNumber: 17\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: 176,\n columnNumber: 19\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 174,\n columnNumber: 17\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 163,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 161,\n columnNumber: 13\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 160,\n columnNumber: 11\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 159,\n columnNumber: 9\n }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n className: `modal ${submitOkModalVisibilityState ? \"active\" : \"inactive\"}`,\n children: /*#__PURE__*/_jsxDEV(\"div\", {\n ref: submitOkModalRef,\n className: \"modal-content\",\n children: /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"submitOkModal\",\n children: [/*#__PURE__*/_jsxDEV(\"h2\", {\n children: \"Email submitted!\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 187,\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: 188,\n columnNumber: 15\n }, this), /*#__PURE__*/_jsxDEV(\"button\", {\n className: \"formSubmitButton\",\n type: \"submit\",\n children: \"Ok\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 191,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 186,\n columnNumber: 13\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 185,\n columnNumber: 11\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 184,\n columnNumber: 9\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 124,\n columnNumber: 7\n }, this);\n } else {\n return /*#__PURE__*/_jsxDEV(Redirect, {\n to: \"/home\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 200,\n columnNumber: 12\n }, this);\n }\n};\n\n_s(Login, \"OVSfU60ROPeLXwIj+EZ9nxkLfx4=\", false, function () {\n return [useOktaAuth];\n});\n\n_c = Login;\nexport default Login;\n\nvar _c;\n\n$RefreshReg$(_c, \"Login\");","map":{"version":3,"sources":["C:/Users/Bruger/Desktop/Web-projects/pipit/client/src/pages/login/Login.jsx"],"names":["React","useState","useEffect","useRef","Redirect","useOktaAuth","FontAwesomeIcon","NavLink","signUp","config","SignUp","PasswordForgotModal","Login","authState","oktaAuth","sessionToken","setSessionToken","forgotPasswordFormVisibilityState","showForgotPasswordForm","forgotPasswordFormRef","toggleForgotPasswordFormVisible","submitOkModalVisibilityState","showSubmitOkModal","submitOkModalRef","toggleSubmitOkModalVisible","pageClickEvent","e","current","contains","target","window","addEventListener","removeEventListener","username","setUsername","password","setPassword","handleUsernameChange","value","handlePasswordChange","userInputData","JSON","stringify","email","loginRequestOptions","method","body","ForgotPasswordRequestOptions","handlePasswordForgot","fetch","serviceAPI","ForgotPasswordURL","then","res","ok","alert","Promise","reject","handleSignInFormSubmit","preventDefault","signInWithCredentials","signInWithRedirect","originalUri","catch","err","console","log","isAuthenticated"],"mappings":";;;AAAA,OAAOA,KAAP,IAAgBC,QAAhB,EAA0BC,SAA1B,EAAqCC,MAArC,QAAmD,OAAnD;AACA,SAASC,QAAT,QAAyB,kBAAzB;AACA,SAASC,WAAT,QAA4B,kBAA5B;AACA,OAAO,aAAP;AACA,SAASC,eAAT,QAAgC,gCAAhC;AACA,SAASC,OAAT,QAAwB,kBAAxB;AACA,OAAOC,MAAP,MAAmB,iBAAnB;AACA,OAAOC,MAAP,MAAmB,cAAnB;AACA,OAAOC,MAAP,MAAmB,iBAAnB;AACA,OAAOC,mBAAP,MAAgC,qCAAhC;;;AAEA,MAAMC,KAAK,GAAG,MAAM;AAAA;;AAClB,QAAM;AAAEC,IAAAA,SAAF;AAAaC,IAAAA;AAAb,MAA0BT,WAAW,EAA3C;AACA,QAAM,CAACU,YAAD,EAAeC,eAAf,IAAkCf,QAAQ,EAAhD,CAFkB,CAIlB;;AACA,QAAM,CAACgB,iCAAD,EAAoCC,sBAApC,IAA8DjB,QAAQ,CAAC,KAAD,CAA5E;AACA,QAAMkB,qBAAqB,GAAGhB,MAAM,CAAC,IAAD,CAApC;;AACA,QAAMiB,+BAA+B,GAAG,MAAMF,sBAAsB,CAAC,CAACD,iCAAF,CAApE,CAPkB,CASlB;;;AACA,QAAM,CAACI,4BAAD,EAA+BC,iBAA/B,IAAoDrB,QAAQ,CAAC,KAAD,CAAlE;AACA,QAAMsB,gBAAgB,GAAGpB,MAAM,CAAC,IAAD,CAA/B;;AACA,QAAMqB,0BAA0B,GAAG,MAAMF,iBAAiB,CAAC,CAACD,4BAAF,CAA1D;;AAEAnB,EAAAA,SAAS,CAAC,MAAM;AACd,UAAMuB,cAAc,GAAIC,CAAD,IAAO;AAC5B,UAAIP,qBAAqB,CAACQ,OAAtB,KAAkC,IAAlC,IAA0C,CAACR,qBAAqB,CAACQ,OAAtB,CAA8BC,QAA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AA,iCACE;AAAK,YAAA,SAAS,EAAC,eAAf;AAAA,oCACE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBADF,eAEE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAFF,eAKE;AAAQ,cAAA,SAAS,EAAC,kBAAlB;AAAqC,cAAA,IAAI,EAAC,QAA1C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBALF;AAAA;AAAA;AAAA;AAAA;AAAA;AADF;AAAA;AAAA;AAAA;AAAA;AADF;AAAA;AAAA;AAAA;AAAA,cA5DF;AAAA;AAAA;AAAA;AAAA;AAAA,YADF;AA4ED,GA7ED,MA6EO;AACL,wBAAO,QAAC,QAAD;AAAU,MAAA,EAAE,EAAC;AAAb;AAAA;AAAA;AAAA;AAAA,YAAP;AACD;AACF,CA9LD;;GAAMX,K;UAC4BP,W;;;KAD5BO,K;AAgMN,eAAeA,KAAf","sourcesContent":["import React, { useState, useEffect, useRef } from 'react';\r\nimport { Redirect } from 'react-router-dom'\r\nimport { useOktaAuth } from '@okta/okta-react';\r\nimport \"./Login.css\"\r\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome'\r\nimport { NavLink } from 'react-router-dom';\r\nimport signUp from './signUp/SignUp';\r\nimport config from '../../config';\r\nimport SignUp from './signUp/SignUp';\r\nimport PasswordForgotModal from './passwordReset/PasswordForgotModal';\r\n\r\nconst Login = () => {\r\n const { authState, oktaAuth } = useOktaAuth();\r\n const [sessionToken, setSessionToken] = useState()\r\n\r\n // Forgot password form\r\n const [forgotPasswordFormVisibilityState, showForgotPasswordForm] = useState(false)\r\n const forgotPasswordFormRef = useRef(null)\r\n const toggleForgotPasswordFormVisible = () => showForgotPasswordForm(!forgotPasswordFormVisibilityState)\r\n\r\n // Submit ok modal\r\n const [submitOkModalVisibilityState, showSubmitOkModal] = useState(false)\r\n const submitOkModalRef = useRef(null)\r\n const toggleSubmitOkModalVisible = () => showSubmitOkModal(!submitOkModalVisibilityState)\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 useEffect(() => {\r\n const pageClickEvent = (e) => {\r\n if (submitOkModalRef.current !== null && !submitOkModalRef.current.contains(e.target)) {\r\n toggleSubmitOkModalVisible()\r\n }\r\n };\r\n\r\n // If the item is active (ie open) then listen for clicks\r\n if (submitOkModalVisibilityState) {\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 }, [submitOkModalVisibilityState]);\r\n\r\n const [username, setUsername] = useState('');\r\n const [password, setPassword] = useState('');\r\n\r\n const handleUsernameChange = (e) => {\r\n setUsername(e.target.value);\r\n };\r\n\r\n const handlePasswordChange = (e) => {\r\n setPassword(e.target.value)\r\n }\r\n\r\n const userInputData = JSON.stringify({\r\n email: `${username}`,\r\n password: `${password}`\r\n })\r\n\r\n const loginRequestOptions = {\r\n method: 'POST',\r\n body: userInputData\r\n };\r\n\r\n const ForgotPasswordRequestOptions = {\r\n method: 'PUT',\r\n body: JSON.stringify({\r\n email: `${username}`\r\n })\r\n }\r\n\r\n const handlePasswordForgot = () => {\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 const handleSignInFormSubmit = (e) => {\r\n e.preventDefault();\r\n\r\n oktaAuth.signInWithCredentials({ username, password })\r\n .then(res => {\r\n const sessionToken = res.sessionToken;\r\n setSessionToken(sessionToken);\r\n // sessionToken is a one-use token, so make sure this is only called once\r\n oktaAuth.signInWithRedirect({ sessionToken, originalUri: '/home' });\r\n })\r\n .catch(err => console.log('Found an error', err));\r\n };\r\n\r\n if (sessionToken) {\r\n // Hide form while sessionToken is converted into id/access tokens\r\n return null;\r\n }\r\n\r\n if (!authState || !authState.isAuthenticated) {\r\n return (\r\n <div className=\"pageContainer\">\r\n <SignUp />\r\n\r\n <div className=\"signInForm\">\r\n <h2>Sign in to PipIt</h2>\r\n <form onSubmit={handleSignInFormSubmit}>\r\n <label>\r\n Email:\r\n <input\r\n id=\"username\" type=\"text\"\r\n value={username}\r\n onChange={handleUsernameChange} />\r\n </label>\r\n <label>\r\n Password:\r\n <input\r\n id=\"password\" type=\"password\"\r\n value={password}\r\n onChange={handlePasswordChange} />\r\n </label>\r\n <button className=\"formSubmitButton\" type=\"submit\">\r\n Sign in&nbsp;&nbsp;\r\n <FontAwesomeIcon icon=\"sign-in-alt\"></FontAwesomeIcon>\r\n </button>\r\n </form>\r\n <PasswordForgotModal onStateChange={handleUsernameChange} />\r\n </div>\r\n\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\r\n {/* SubmitOk modal */}\r\n <div className={`modal ${submitOkModalVisibilityState ? \"active\" : \"inactive\"}`}>\r\n <div ref={submitOkModalRef} className=\"modal-content\">\r\n <div className=\"submitOkModal\">\r\n <h2>Email submitted!</h2>\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 Ok\r\n </button>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n )\r\n } else {\r\n return <Redirect to=\"/home\" />\r\n }\r\n}\r\n\r\nexport default Login"]},"metadata":{},"sourceType":"module"}
\ No newline at end of file
{"ast":null,"code":"var _jsxFileName = \"C:\\\\Users\\\\Bruger\\\\Desktop\\\\Web-projects\\\\pipit\\\\client\\\\src\\\\pages\\\\login\\\\Login.jsx\",\n _s = $RefreshSig$();\n\nimport React, { useState, useEffect, useRef } from 'react';\nimport { Redirect } from 'react-router-dom';\nimport { useOktaAuth } from '@okta/okta-react';\nimport \"./Login.css\";\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\nimport { NavLink } from 'react-router-dom';\nimport signUp from './signUp/SignUp';\nimport config from '../../config';\nimport SignUp from './signUp/SignUp';\nimport PasswordForgotModal from './passwordReset/PasswordForgotModal';\nimport { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\n\nconst Login = () => {\n _s();\n\n const {\n authState,\n oktaAuth\n } = useOktaAuth();\n const [sessionToken, setSessionToken] = useState();\n const [forgotPasswordFormVisibilityState, setForgotPasswordFormVisibilityState] = useState(false);\n\n const togglePasswordFormVisible = () => setForgotPasswordFormVisibilityState(!forgotPasswordFormVisibilityState);\n\n const [username, setUsername] = useState('');\n const [password, setPassword] = useState('');\n\n const handleUsernameChange = e => {\n setUsername(e.target.value);\n };\n\n const handlePasswordChange = e => {\n setPassword(e.target.value);\n };\n\n const userInputData = JSON.stringify({\n email: `${username}`,\n password: `${password}`\n });\n const loginRequestOptions = {\n method: 'POST',\n body: userInputData\n };\n\n const handleSignInFormSubmit = e => {\n e.preventDefault();\n oktaAuth.signInWithCredentials({\n username,\n password\n }).then(res => {\n const sessionToken = res.sessionToken;\n setSessionToken(sessionToken); // sessionToken is a one-use token, so make sure this is only called once\n\n oktaAuth.signInWithRedirect({\n sessionToken,\n originalUri: '/home'\n });\n }).catch(err => console.log('Found an error', err));\n };\n\n if (sessionToken) {\n // Hide form while sessionToken is converted into id/access tokens\n return null;\n }\n\n if (!authState || !authState.isAuthenticated) {\n return /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"pageContainer\",\n children: [/*#__PURE__*/_jsxDEV(SignUp, {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 61,\n columnNumber: 9\n }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"signInForm\",\n children: [/*#__PURE__*/_jsxDEV(\"h2\", {\n children: \"Sign in to PipIt\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 64,\n columnNumber: 11\n }, this), /*#__PURE__*/_jsxDEV(\"form\", {\n onSubmit: handleSignInFormSubmit,\n children: [/*#__PURE__*/_jsxDEV(\"label\", {\n children: [\"Email:\", /*#__PURE__*/_jsxDEV(\"input\", {\n id: \"username\",\n type: \"text\",\n value: username,\n onChange: handleUsernameChange\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 68,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 66,\n columnNumber: 13\n }, this), /*#__PURE__*/_jsxDEV(\"label\", {\n children: [\"Password:\", /*#__PURE__*/_jsxDEV(\"input\", {\n id: \"password\",\n type: \"password\",\n value: password,\n onChange: handlePasswordChange\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 75,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 73,\n columnNumber: 13\n }, this), /*#__PURE__*/_jsxDEV(\"button\", {\n className: \"formSubmitButton\",\n type: \"submit\",\n children: [\"Sign in\\xA0\\xA0\", /*#__PURE__*/_jsxDEV(FontAwesomeIcon, {\n icon: \"sign-in-alt\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 82,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 80,\n columnNumber: 13\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 65,\n columnNumber: 11\n }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"password-forgot-prompt\",\n children: /*#__PURE__*/_jsxDEV(\"span\", {\n children: /*#__PURE__*/_jsxDEV(\"a\", {\n onClick: togglePasswordFormVisible,\n children: \"Forgot password\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 87,\n columnNumber: 15\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 86,\n columnNumber: 13\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 85,\n columnNumber: 11\n }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n className: `modal ${forgotPasswordFormVisibilityState ? \"active\" : \"inactive\"}`,\n children: /*#__PURE__*/_jsxDEV(PasswordForgotModal, {\n removeModal: () => setForgotPasswordFormVisibilityState(false)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 91,\n columnNumber: 13\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 90,\n columnNumber: 11\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 63,\n columnNumber: 9\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 60,\n columnNumber: 7\n }, this);\n } else {\n return /*#__PURE__*/_jsxDEV(Redirect, {\n to: \"/home\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 97,\n columnNumber: 12\n }, this);\n }\n};\n\n_s(Login, \"XlNc2CmG/vFxCt8acIKy6LZQ9RM=\", false, function () {\n return [useOktaAuth];\n});\n\n_c = Login;\nexport default Login;\n\nvar _c;\n\n$RefreshReg$(_c, \"Login\");","map":{"version":3,"sources":["C:/Users/Bruger/Desktop/Web-projects/pipit/client/src/pages/login/Login.jsx"],"names":["React","useState","useEffect","useRef","Redirect","useOktaAuth","FontAwesomeIcon","NavLink","signUp","config","SignUp","PasswordForgotModal","Login","authState","oktaAuth","sessionToken","setSessionToken","forgotPasswordFormVisibilityState","setForgotPasswordFormVisibilityState","togglePasswordFormVisible","username","setUsername","password","setPassword","handleUsernameChange","e","target","value","handlePasswordChange","userInputData","JSON","stringify","email","loginRequestOptions","method","body","handleSignInFormSubmit","preventDefault","signInWithCredentials","then","res","signInWithRedirect","originalUri","catch","err","console","log","isAuthenticated"],"mappings":";;;AAAA,OAAOA,KAAP,IAAgBC,QAAhB,EAA0BC,SAA1B,EAAqCC,MAArC,QAAmD,OAAnD;AACA,SAASC,QAAT,QAAyB,kBAAzB;AACA,SAASC,WAAT,QAA4B,kBAA5B;AACA,OAAO,aAAP;AACA,SAASC,eAAT,QAAgC,gCAAhC;AACA,SAASC,OAAT,QAAwB,kBAAxB;AACA,OAAOC,MAAP,MAAmB,iBAAnB;AACA,OAAOC,MAAP,MAAmB,cAAnB;AACA,OAAOC,MAAP,MAAmB,iBAAnB;AACA,OAAOC,mBAAP,MAAgC,qCAAhC;;;AAEA,MAAMC,KAAK,GAAG,MAAM;AAAA;;AAClB,QAAM;AAAEC,IAAAA,SAAF;AAAaC,IAAAA;AAAb,MAA0BT,WAAW,EAA3C;AACA,QAAM,CAACU,YAAD,EAAeC,eAAf,IAAkCf,QAAQ,EAAhD;AAEA,QAAM,CAACgB,iCAAD,EAAoCC,oCAApC,IAA4EjB,QAAQ,CAAC,KAAD,CAA1F;;AACA,QAAMkB,yBAAyB,GAAG,MAAMD,oCAAoC,CAAC,CAACD,iCAAF,CAA5E;;AAEA,QAAM,CAACG,QAAD,EAAWC,WAAX,IAA0BpB,QAAQ,CAAC,EAA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5E;AAAA;AAAA;AAAA;AAAA;AADF;AAAA;AAAA;AAAA;AAAA,gBA3BF;AAAA;AAAA;AAAA;AAAA;AAAA,cAHF;AAAA;AAAA;AAAA;AAAA;AAAA,YADF;AAqCD,GAtCD,MAsCO;AACL,wBAAO,QAAC,QAAD;AAAU,MAAA,EAAE,EAAC;AAAb;AAAA;AAAA;AAAA;AAAA,YAAP;AACD;AACF,CAvFD;;GAAMN,K;UAC4BP,W;;;KAD5BO,K;AAyFN,eAAeA,KAAf","sourcesContent":["import React, { useState, useEffect, useRef } from 'react';\r\nimport { Redirect } from 'react-router-dom'\r\nimport { useOktaAuth } from '@okta/okta-react';\r\nimport \"./Login.css\"\r\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome'\r\nimport { NavLink } from 'react-router-dom';\r\nimport signUp from './signUp/SignUp';\r\nimport config from '../../config';\r\nimport SignUp from './signUp/SignUp';\r\nimport PasswordForgotModal from './passwordReset/PasswordForgotModal';\r\n\r\nconst Login = () => {\r\n const { authState, oktaAuth } = useOktaAuth();\r\n const [sessionToken, setSessionToken] = useState()\r\n\r\n const [forgotPasswordFormVisibilityState, setForgotPasswordFormVisibilityState] = useState(false)\r\n const togglePasswordFormVisible = () => setForgotPasswordFormVisibilityState(!forgotPasswordFormVisibilityState)\r\n\r\n const [username, setUsername] = useState('');\r\n const [password, setPassword] = useState('');\r\n\r\n const handleUsernameChange = (e) => {\r\n setUsername(e.target.value);\r\n };\r\n\r\n const handlePasswordChange = (e) => {\r\n setPassword(e.target.value)\r\n }\r\n\r\n const userInputData = JSON.stringify({\r\n email: `${username}`,\r\n password: `${password}`\r\n })\r\n\r\n const loginRequestOptions = {\r\n method: 'POST',\r\n body: userInputData\r\n };\r\n\r\n const handleSignInFormSubmit = (e) => {\r\n e.preventDefault();\r\n\r\n oktaAuth.signInWithCredentials({ username, password })\r\n .then(res => {\r\n const sessionToken = res.sessionToken;\r\n setSessionToken(sessionToken);\r\n // sessionToken is a one-use token, so make sure this is only called once\r\n oktaAuth.signInWithRedirect({ sessionToken, originalUri: '/home' });\r\n })\r\n .catch(err => console.log('Found an error', err));\r\n };\r\n\r\n if (sessionToken) {\r\n // Hide form while sessionToken is converted into id/access tokens\r\n return null;\r\n }\r\n\r\n if (!authState || !authState.isAuthenticated) {\r\n return (\r\n <div className=\"pageContainer\">\r\n <SignUp />\r\n\r\n <div className=\"signInForm\">\r\n <h2>Sign in to PipIt</h2>\r\n <form onSubmit={handleSignInFormSubmit}>\r\n <label>\r\n Email:\r\n <input\r\n id=\"username\" type=\"text\"\r\n value={username}\r\n onChange={handleUsernameChange} />\r\n </label>\r\n <label>\r\n Password:\r\n <input\r\n id=\"password\" type=\"password\"\r\n value={password}\r\n onChange={handlePasswordChange} />\r\n </label>\r\n <button className=\"formSubmitButton\" type=\"submit\">\r\n Sign in&nbsp;&nbsp;\r\n <FontAwesomeIcon icon=\"sign-in-alt\"></FontAwesomeIcon>\r\n </button>\r\n </form>\r\n <div className=\"password-forgot-prompt\">\r\n <span>\r\n <a onClick={togglePasswordFormVisible}>Forgot password</a>\r\n </span>\r\n </div>\r\n <div className={`modal ${forgotPasswordFormVisibilityState ? \"active\" : \"inactive\"}`}>\r\n <PasswordForgotModal removeModal={() => setForgotPasswordFormVisibilityState(false)} />\r\n </div>\r\n </div>\r\n </div>\r\n )\r\n } else {\r\n return <Redirect to=\"/home\" />\r\n }\r\n}\r\n\r\nexport default Login"]},"metadata":{},"sourceType":"module"}
\ No newline at end of file
{"ast":null,"code":"var _jsxFileName = \"C:\\\\Users\\\\Bruger\\\\Desktop\\\\Web-projects\\\\pipit\\\\client\\\\src\\\\pages\\\\login\\\\passwordReset\\\\PasswordResetModal.jsx\",\n _s = $RefreshSig$();\n\nimport React, { useState, useRef, useEffect } from 'react';\nimport config from '../../../config';\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\nimport \"./PasswordResetModal.css\";\nimport { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\n\nconst PasswordResetModal = () => {\n _s();\n\n const [username, setUsername] = useState('');\n const [forgotPasswordFormVisibilityState, showForgotPasswordForm] = useState(false);\n const forgotPasswordFormRef = useRef(null);\n\n const toggleForgotPasswordFormVisible = () => showForgotPasswordForm(!forgotPasswordFormVisibilityState);\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 resetPasswordRequestOptions = {\n method: 'PUT',\n body: JSON.stringify({\n email: `${username}`\n })\n };\n\n const handlePasswordReset = () => {\n fetch(config.serviceAPI.resetPasswordURL, resetPasswordRequestOptions).then(res => {\n if (!res.ok) {\n window.alert(\"Error: something went wrong\");\n Promise.reject(\"\");\n return;\n }\n\n if (res.ok) {// do something\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: 59,\n columnNumber: 11\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 58,\n columnNumber: 9\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 57,\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: \"resetPasswordForm\",\n children: [/*#__PURE__*/_jsxDEV(\"h2\", {\n children: \"Reset password\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 66,\n columnNumber: 13\n }, this), /*#__PURE__*/_jsxDEV(\"form\", {\n onSubmit: handlePasswordReset,\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: 70,\n columnNumber: 17\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 68,\n columnNumber: 15\n }, this), /*#__PURE__*/_jsxDEV(\"button\", {\n className: \"formSubmitButton\",\n type: \"submit\",\n children: [\"Sign Up\\xA0\\xA0\", /*#__PURE__*/_jsxDEV(FontAwesomeIcon, {\n icon: \"arrow-right\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 77,\n columnNumber: 17\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 75,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 67,\n columnNumber: 13\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 65,\n columnNumber: 11\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 64,\n columnNumber: 9\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 63,\n columnNumber: 7\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 56,\n columnNumber: 5\n }, this);\n};\n\n_s(PasswordResetModal, \"VvmgU4VTr5ZNKM/8uo86UTvcRWY=\");\n\n_c = PasswordResetModal;\nexport default PasswordResetModal;\n\nvar _c;\n\n$RefreshReg$(_c, \"PasswordResetModal\");","map":{"version":3,"sources":["C:/Users/Bruger/Desktop/Web-projects/pipit/client/src/pages/login/passwordReset/PasswordResetModal.jsx"],"names":["React","useState","useRef","useEffect","config","FontAwesomeIcon","PasswordResetModal","username","setUsername","forgotPasswordFormVisibilityState","showForgotPasswordForm","forgotPasswordFormRef","toggleForgotPasswordFormVisible","handleUsernameChange","e","target","value","pageClickEvent","current","contains","window","addEventListener","removeEventListener","resetPasswordRequestOptions","method","body","JSON","stringify","email","handlePasswordReset","fetch","serviceAPI","resetPasswordURL","then","res","ok","alert","Promise","reject"],"mappings":";;;AAAA,OAAOA,KAAP,IAAgBC,QAAhB,EAA0BC,MAA1B,EAAkCC,SAAlC,QAAmD,OAAnD;AACA,OAAOC,MAAP,MAAmB,iBAAnB;AACA,SAASC,eAAT,QAAgC,gCAAhC;AACA,OAAO,0BAAP;;;AAEA,MAAMC,kBAAkB,GAAG,MAAM;AAAA;;AAC/B,QAAM,CAACC,QAAD,EAAWC,WAAX,IAA0BP,QAAQ,CAAC,EAAD,CAAxC;AACA,QAAM,CAACQ,iCAAD,EAAoCC,sBAApC,IAA8DT,QAAQ,CAAC,KAAD,CAA5E;AACA,QAAMU,qBAAqB,GAAGT,MAAM,CAAC,IAAD,CAApC;;AACA,QAAMU,+BAA+B,GAAG,MAAMF,sBAAsB,CAAC,CAACD,iCAAF,CAApE;;AAEA,QAAMI,oBAAoB,GAAIC,CAAD,IAAO;AAClCN,IAAAA,WAAW,CAACM,CAAC,CAACC,MAAF,CAASC,KAAV,CAAX;AACD,GAFD;;AAIAb,EAAAA,SAAS,CAAC,MAAM;AACd,UAAMc,cAAc,GAAIH,CAAD,IAAO;AAC5B,UAAIH,qBAAqB,CAACO,OAAtB,KAAkC,IAAlC,IAA0C,CAACP,qBAAqB,CAACO,OAAtB,CAA8BC,QAA9B,CAAuCL,CAAC,CAACC,MAAzC,CAA/C,EAAiG;AAC/FH,QAAAA,+BAA+B;AAChC;AACF,KAJD,CADc,CAOd;;;AACA,QAAIH,iCAAJ,EAAuC;AACrCW,MAAAA,MAAM,CAACC,gBAAP,CA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AAAA,gDAEE;AACE,gBAAA,EAAE,EAAC,OADL;AACa,gBAAA,IAAI,EAAC,MADlB;AAEE,gBAAA,KAAK,EAAEtB,QAFT;AAGE,gBAAA,QAAQ,EAAEM;AAHZ;AAAA;AAAA;AAAA;AAAA,sBAFF;AAAA;AAAA;AAAA;AAAA;AAAA,oBADF,eAQE;AAAQ,cAAA,SAAS,EAAC,kBAAlB;AAAqC,cAAA,IAAI,EAAC,QAA1C;AAAA,yDAEE,QAAC,eAAD;AAAiB,gBAAA,IAAI,EAAC;AAAtB;AAAA;AAAA;AAAA;AAAA,sBAFF;AAAA;AAAA;AAAA;AAAA;AAAA,oBARF;AAAA;AAAA;AAAA;AAAA;AAAA,kBAFF;AAAA;AAAA;AAAA;AAAA;AAAA;AADF;AAAA;AAAA;AAAA;AAAA;AADF;AAAA;AAAA;AAAA;AAAA,YAPF;AAAA;AAAA;AAAA;AAAA;AAAA,UADF;AA+BD,CAhFD;;GAAMP,kB;;KAAAA,kB;AAkFN,eAAeA,kBAAf","sourcesContent":["import React, { useState, useRef, useEffect } from 'react'\r\nimport config from '../../../config'\r\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\r\nimport \"./PasswordResetModal.css\"\r\n\r\nconst PasswordResetModal = () => {\r\n const [username, setUsername] = useState('');\r\n const [forgotPasswordFormVisibilityState, showForgotPasswordForm] = useState(false)\r\n const forgotPasswordFormRef = useRef(null);\r\n const toggleForgotPasswordFormVisible = () => showForgotPasswordForm(!forgotPasswordFormVisibilityState)\r\n\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 resetPasswordRequestOptions = {\r\n method: 'PUT',\r\n body: JSON.stringify({\r\n email: `${username}`\r\n })\r\n }\r\n\r\n const handlePasswordReset = () => {\r\n fetch(config.serviceAPI.resetPasswordURL, resetPasswordRequestOptions)\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 // do something\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 <div className={`modal ${forgotPasswordFormVisibilityState ? \"active\" : \"inactive\"}`}>\r\n <div ref={forgotPasswordFormRef} className=\"modal-content\">\r\n <div className=\"resetPasswordForm\">\r\n <h2>Reset password</h2>\r\n <form onSubmit={handlePasswordReset}>\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 <button className=\"formSubmitButton\" type=\"submit\">\r\n Sign Up&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\r\n )\r\n}\r\n\r\nexport default PasswordResetModal\r\n"]},"metadata":{},"sourceType":"module"}
\ No newline at end of file
{"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 removeModal\n}) => {\n _s();\n\n const [submitOkMessageModalState, setSubmitOkMessageModalState] = useState(false);\n\n const stopProp = e => {\n e.stopPropagation();\n };\n\n const [username, setUsername] = useState('');\n\n const handleUsernameChange = e => {\n setUsername(e.target.value);\n };\n\n const userInputData = JSON.stringify({\n email: `${username}`\n });\n const ForgotPasswordRequestOptions = {\n method: 'PUT',\n body: userInputData\n };\n {\n /* <div className={`modal ${submitOkMessageModalState ? \"active\" : \"inactive\"}`}>\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> */\n }\n\n const handlePasswordForgot = e => {\n e.preventDefault();\n removeModal();\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 className: \"modal-content\",\n onClick: e => removeModal(),\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: 53,\n columnNumber: 9\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: 57,\n columnNumber: 13\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 55,\n columnNumber: 11\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: 64,\n columnNumber: 13\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 62,\n columnNumber: 11\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 54,\n columnNumber: 9\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 52,\n columnNumber: 7\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 51,\n columnNumber: 5\n }, this);\n};\n\n_s(PasswordForgotModal, \"ccs9TXv4Z39DCQsrqL8dXg2nBZI=\");\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","removeModal","submitOkMessageModalState","setSubmitOkMessageModalState","stopProp","e","stopPropagation","username","setUsername","handleUsernameChange","target","value","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,CAAC;AAAEC,EAAAA;AAAF,CAAD,KAAqB;AAAA;;AAC/C,QAAM,CAACC,yBAAD,EAA4BC,4BAA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AAA,SAAS,EAAC,kBAAlB;AAAqC,UAAA,IAAI,EAAC,QAA1C;AAAA,oDAEE,QAAC,eAAD;AAAiB,YAAA,IAAI,EAAC;AAAtB;AAAA;AAAA;AAAA;AAAA,kBAFF;AAAA;AAAA;AAAA;AAAA;AAAA,gBARF;AAAA;AAAA;AAAA;AAAA;AAAA,cAFF;AAAA;AAAA;AAAA;AAAA;AAAA;AADF;AAAA;AAAA;AAAA;AAAA,UADF;AAoBD,CA/DD;;GAAMT,mB;;KAAAA,mB;AAiEN,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 = ({ removeModal }) => {\r\n const [submitOkMessageModalState, setSubmitOkMessageModalState] = useState(false);\r\n\r\n const stopProp = e => {\r\n e.stopPropagation()\r\n }\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 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 {/* <div className={`modal ${submitOkMessageModalState ? \"active\" : \"inactive\"}`}>\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\r\n const handlePasswordForgot = (e) => {\r\n e.preventDefault();\r\n\r\n removeModal()\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 className=\"modal-content\" onClick={e => removeModal()}>\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 <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 )\r\n}\r\n\r\nexport default PasswordForgotModal\r\n"]},"metadata":{},"sourceType":"module"}
\ No newline at end of file
{"ast":null,"code":"var _jsxFileName = \"C:\\\\Users\\\\Bruger\\\\Desktop\\\\Web-projects\\\\pipit\\\\client\\\\src\\\\pages\\\\login\\\\passwordReset\\\\PasswordResetModal.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 { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\n\nconst PasswordForgotModal = () => {\n _s();\n\n const [username, setUsername] = useState('');\n const [forgotPasswordFormVisibilityState, showForgotPasswordForm] = useState(false);\n const forgotPasswordFormRef = useRef(null);\n\n const toggleForgotPasswordFormVisible = () => showForgotPasswordForm(!forgotPasswordFormVisibilityState);\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 ForgotPasswordRequestOptions = {\n method: 'PUT',\n body: JSON.stringify({\n email: `${username}`\n })\n };\n\n const handlePasswordForgot = () => {\n fetch(config.serviceAPI.ForgotPasswordURL, ForgotPasswordRequestOptions).then(res => {\n if (!res.ok) {\n window.alert(\"Error: something went wrong\");\n Promise.reject(\"\");\n return;\n }\n\n if (res.ok) {// do something\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: 59,\n columnNumber: 11\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 58,\n columnNumber: 9\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 57,\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: 66,\n columnNumber: 13\n }, this), /*#__PURE__*/_jsxDEV(\"form\", {\n onSubmit: handlePasswordRecover,\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: 70,\n columnNumber: 17\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 68,\n columnNumber: 15\n }, this), /*#__PURE__*/_jsxDEV(\"button\", {\n className: \"formSubmitButton\",\n type: \"submit\",\n children: [\"Sign Up\\xA0\\xA0\", /*#__PURE__*/_jsxDEV(FontAwesomeIcon, {\n icon: \"arrow-right\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 77,\n columnNumber: 17\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 75,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 67,\n columnNumber: 13\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 65,\n columnNumber: 11\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 64,\n columnNumber: 9\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 63,\n columnNumber: 7\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 56,\n columnNumber: 5\n }, this);\n};\n\n_s(PasswordForgotModal, \"VvmgU4VTr5ZNKM/8uo86UTvcRWY=\");\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/PasswordResetModal.jsx"],"names":["React","useState","useRef","useEffect","config","FontAwesomeIcon","PasswordForgotModal","username","setUsername","forgotPasswordFormVisibilityState","showForgotPasswordForm","forgotPasswordFormRef","toggleForgotPasswordFormVisible","handleUsernameChange","e","target","value","pageClickEvent","current","contains","window","addEventListener","removeEventListener","ForgotPasswordRequestOptions","method","body","JSON","stringify","email","handlePasswordForgot","fetch","serviceAPI","ForgotPasswordURL","then","res","ok","alert","Promise","reject","handlePasswordRecover"],"mappings":";;;AAAA,OAAOA,KAAP,IAAgBC,QAAhB,EAA0BC,MAA1B,EAAkCC,SAAlC,QAAmD,OAAnD;AACA,OAAOC,MAAP,MAAmB,iBAAnB;AACA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;AAAA;AAAA,kBAFF;AAAA;AAAA;AAAA;AAAA;AAAA;AADF;AAAA;AAAA;AAAA;AAAA;AADF;AAAA;AAAA;AAAA;AAAA,YAPF;AAAA;AAAA;AAAA;AAAA;AAAA,UADF;AA+BD,CAhFD;;GAAMP,mB;;KAAAA,mB;AAkFN,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\n\r\nconst PasswordForgotModal = () => {\r\n const [username, setUsername] = useState('');\r\n const [forgotPasswordFormVisibilityState, showForgotPasswordForm] = useState(false)\r\n const forgotPasswordFormRef = useRef(null);\r\n const toggleForgotPasswordFormVisible = () => showForgotPasswordForm(!forgotPasswordFormVisibilityState)\r\n\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 ForgotPasswordRequestOptions = {\r\n method: 'PUT',\r\n body: JSON.stringify({\r\n email: `${username}`\r\n })\r\n }\r\n\r\n const handlePasswordForgot = () => {\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 // do something\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 <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={handlePasswordRecover}>\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 <button className=\"formSubmitButton\" type=\"submit\">\r\n Sign Up&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\r\n )\r\n}\r\n\r\nexport default PasswordForgotModal\r\n"]},"metadata":{},"sourceType":"module"}
\ No newline at end of file
{"ast":null,"code":"var _jsxFileName = \"C:\\\\Users\\\\Bruger\\\\Desktop\\\\Web-projects\\\\pipit\\\\client\\\\src\\\\components\\\\messageModal\\\\MessageModal.jsx\",\n _s = $RefreshSig$();\n\nimport React from 'react';\nimport { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\n\nconst MessageModal = props => {\n _s();\n\n const [modalVisibilityState, showModal] = useState(props.activeState);\n\n const toggleModalVisible = () => showModal(!modalVisibilityState);\n\n return /*#__PURE__*/_jsxDEV(\"div\", {\n className: `modal ${modalVisibilityState ? \"active\" : \"inactive\"}`,\n children: /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"modal-content\",\n children: /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"submitOkModal\",\n children: [/*#__PURE__*/_jsxDEV(\"h2\", {\n children: props.headerMessage\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 11,\n columnNumber: 11\n }, this), /*#__PURE__*/_jsxDEV(\"label\", {\n children: props.bodyMessage\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 12,\n columnNumber: 11\n }, this), /*#__PURE__*/_jsxDEV(\"button\", {\n className: \"formSubmitButton\",\n type: \"submit\",\n children: \"Ok\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 15,\n columnNumber: 11\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 10,\n columnNumber: 9\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 9,\n columnNumber: 7\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 8,\n columnNumber: 5\n }, this);\n};\n\n_s(MessageModal, \"a0j9JHC4UO7g+PPm+oPuJjfBun8=\");\n\n_c = MessageModal;\nexport default MessageModal;\n\nvar _c;\n\n$RefreshReg$(_c, \"MessageModal\");","map":{"version":3,"sources":["C:/Users/Bruger/Desktop/Web-projects/pipit/client/src/components/messageModal/MessageModal.jsx"],"names":["React","MessageModal","props","modalVisibilityState","showModal","useState","activeState","toggleModalVisible","headerMessage","bodyMessage"],"mappings":";;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;;;AAEA,MAAMC,YAAY,GAAIC,KAAD,IAAW;AAAA;;AAC9B,QAAM,CAACC,oBAAD,EAAuBC,SAAvB,IAAoCC,QAAQ,CAACH,KAAK,CAACI,WAAP,CAAlD;;AACA,QAAMC,kBAAkB,GAAG,MAAMH,SAAS,CAAC,CAACD,oBAAF,CAA1C;;AAEA,sBACE;AAAK,IAAA,SAAS,EAAG,SAAQA,oBAAoB,GAAG,QAAH,GAAc,UAAW,EAAtE;AAAA,2BACE;AAAK,MAAA,SAAS,EAAC,eAAf;AAAA,6BACE;AAAK,QAAA,SAAS,EAAC,eAAf;AAAA,gCACE;AAAA,oBAAKD,KAAK,CAACM;AAAX;AAAA;AAAA;AAAA;AAAA,gBADF,eAEE;AAAA,oBACGN,KAAK,CAACO;AADT;AAAA;AAAA;AAAA;AAAA,gBAFF,eAKE;AAAQ,UAAA,SAAS,EAAC,kBAAlB;AAAqC,UAAA,IAAI,EAAC,QAA1C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBALF;AAAA;AAAA;AAAA;AAAA;AAAA;AADF;AAAA;AAAA;AAAA;AAAA;AADF;AAAA;AAAA;AAAA;AAAA,UADF;AAeD,CAnBD;;GAAMR,Y;;KAAAA,Y;AAqBN,eAAeA,YAAf","sourcesContent":["import React from 'react'\r\n\r\nconst MessageModal = (props) => {\r\n const [modalVisibilityState, showModal] = useState(props.activeState)\r\n const toggleModalVisible = () => showModal(!modalVisibilityState)\r\n\r\n return (\r\n <div className={`modal ${modalVisibilityState ? \"active\" : \"inactive\"}`}>\r\n <div className=\"modal-content\">\r\n <div className=\"submitOkModal\">\r\n <h2>{props.headerMessage}</h2>\r\n <label>\r\n {props.bodyMessage}\r\n </label>\r\n <button className=\"formSubmitButton\" type=\"submit\">\r\n Ok\r\n </button>\r\n </div>\r\n </div>\r\n </div >\r\n )\r\n}\r\n\r\nexport default MessageModal\r\n"]},"metadata":{},"sourceType":"module"}
\ No newline at end of file
{"ast":null,"code":"var _jsxFileName = \"C:\\\\Users\\\\Bruger\\\\Desktop\\\\Web-projects\\\\pipit\\\\client\\\\src\\\\pages\\\\login\\\\Login.jsx\",\n _s = $RefreshSig$();\n\nimport React, { useState, useEffect, useRef } from 'react';\nimport { Redirect } from 'react-router-dom';\nimport { useOktaAuth } from '@okta/okta-react';\nimport \"./Login.css\";\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\nimport { NavLink } from 'react-router-dom';\nimport signUp from './signUp/SignUp';\nimport config from '../../config';\nimport SignUp from './signUp/SignUp';\nimport PasswordForgotModal from './passwordReset/PasswordForgotModal';\nimport { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\n\nconst Login = () => {\n _s();\n\n const {\n authState,\n oktaAuth\n } = useOktaAuth();\n const [sessionToken, setSessionToken] = useState();\n const [username, setUsername] = useState('');\n const [password, setPassword] = useState('');\n\n const handleUsernameChange = e => {\n setUsername(e.target.value);\n };\n\n const handlePasswordChange = e => {\n setPassword(e.target.value);\n };\n\n const userInputData = JSON.stringify({\n email: `${username}`,\n password: `${password}`\n });\n const loginRequestOptions = {\n method: 'POST',\n body: userInputData\n };\n\n const handleSignInFormSubmit = e => {\n e.preventDefault();\n oktaAuth.signInWithCredentials({\n username,\n password\n }).then(res => {\n const sessionToken = res.sessionToken;\n setSessionToken(sessionToken); // sessionToken is a one-use token, so make sure this is only called once\n\n oktaAuth.signInWithRedirect({\n sessionToken,\n originalUri: '/home'\n });\n }).catch(err => console.log('Found an error', err));\n };\n\n if (sessionToken) {\n // Hide form while sessionToken is converted into id/access tokens\n return null;\n }\n\n if (!authState || !authState.isAuthenticated) {\n return /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"pageContainer\",\n children: [/*#__PURE__*/_jsxDEV(SignUp, {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 58,\n columnNumber: 9\n }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"signInForm\",\n children: [/*#__PURE__*/_jsxDEV(\"h2\", {\n children: \"Sign in to PipIt\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 61,\n columnNumber: 11\n }, this), /*#__PURE__*/_jsxDEV(\"form\", {\n onSubmit: handleSignInFormSubmit,\n children: [/*#__PURE__*/_jsxDEV(\"label\", {\n children: [\"Email:\", /*#__PURE__*/_jsxDEV(\"input\", {\n id: \"username\",\n type: \"text\",\n value: username,\n onChange: handleUsernameChange\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 65,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 63,\n columnNumber: 13\n }, this), /*#__PURE__*/_jsxDEV(\"label\", {\n children: [\"Password:\", /*#__PURE__*/_jsxDEV(\"input\", {\n id: \"password\",\n type: \"password\",\n value: password,\n onChange: handlePasswordChange\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 72,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 70,\n columnNumber: 13\n }, this), /*#__PURE__*/_jsxDEV(\"button\", {\n className: \"formSubmitButton\",\n type: \"submit\",\n children: [\"Sign in\\xA0\\xA0\", /*#__PURE__*/_jsxDEV(FontAwesomeIcon, {\n icon: \"sign-in-alt\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 79,\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: 62,\n columnNumber: 11\n }, this), /*#__PURE__*/_jsxDEV(PasswordForgotModal, {\n loginFormUsername: \"username\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 82,\n columnNumber: 11\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 60,\n columnNumber: 9\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 57,\n columnNumber: 7\n }, this);\n } else {\n return /*#__PURE__*/_jsxDEV(Redirect, {\n to: \"/home\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 87,\n columnNumber: 12\n }, this);\n }\n};\n\n_s(Login, \"u8yY6NlW4PSOG6xgLhGhaVL5lVE=\", false, function () {\n return [useOktaAuth];\n});\n\n_c = Login;\nexport default Login;\n\nvar _c;\n\n$RefreshReg$(_c, \"Login\");","map":{"version":3,"sources":["C:/Users/Bruger/Desktop/Web-projects/pipit/client/src/pages/login/Login.jsx"],"names":["React","useState","useEffect","useRef","Redirect","useOktaAuth","FontAwesomeIcon","NavLink","signUp","config","SignUp","PasswordForgotModal","Login","authState","oktaAuth","sessionToken","setSessionToken","username","setUsername","password","setPassword","handleUsernameChange","e","target","value","handlePasswordChange","userInputData","JSON","stringify","email","loginRequestOptions","method","body","handleSignInFormSubmit","preventDefault","signInWithCredentials","then","res","signInWithRedirect","originalUri","catch","err","console","log","isAuthenticated"],"mappings":";;;AAAA,OAAOA,KAAP,IAAgBC,QAAhB,EAA0BC,SA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AAAqC,YAAA,IAAI,EAAC,QAA1C;AAAA,uDAEE,QAAC,eAAD;AAAiB,cAAA,IAAI,EAAC;AAAtB;AAAA;AAAA;AAAA;AAAA,oBAFF;AAAA;AAAA;AAAA;AAAA;AAAA,kBAfF;AAAA;AAAA;AAAA;AAAA;AAAA,gBAFF,eAsBE,QAAC,mBAAD;AAAqB,UAAA,iBAAiB,EAAE;AAAxC;AAAA;AAAA;AAAA;AAAA,gBAtBF;AAAA;AAAA;AAAA;AAAA;AAAA,cAHF;AAAA;AAAA;AAAA;AAAA;AAAA,YADF;AA8BD,GA/BD,MA+BO;AACL,wBAAO,QAAC,QAAD;AAAU,MAAA,EAAE,EAAC;AAAb;AAAA;AAAA;AAAA;AAAA,YAAP;AACD;AACF,CA7ED;;GAAMb,K;UAC4BP,W;;;KAD5BO,K;AA+EN,eAAeA,KAAf","sourcesContent":["import React, { useState, useEffect, useRef } from 'react';\r\nimport { Redirect } from 'react-router-dom'\r\nimport { useOktaAuth } from '@okta/okta-react';\r\nimport \"./Login.css\"\r\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome'\r\nimport { NavLink } from 'react-router-dom';\r\nimport signUp from './signUp/SignUp';\r\nimport config from '../../config';\r\nimport SignUp from './signUp/SignUp';\r\nimport PasswordForgotModal from './passwordReset/PasswordForgotModal';\r\n\r\nconst Login = () => {\r\n const { authState, oktaAuth } = useOktaAuth();\r\n const [sessionToken, setSessionToken] = useState()\r\n\r\n const [username, setUsername] = useState('');\r\n const [password, setPassword] = useState('');\r\n\r\n const handleUsernameChange = (e) => {\r\n setUsername(e.target.value);\r\n };\r\n\r\n const handlePasswordChange = (e) => {\r\n setPassword(e.target.value)\r\n }\r\n\r\n const userInputData = JSON.stringify({\r\n email: `${username}`,\r\n password: `${password}`\r\n })\r\n\r\n const loginRequestOptions = {\r\n method: 'POST',\r\n body: userInputData\r\n };\r\n\r\n const handleSignInFormSubmit = (e) => {\r\n e.preventDefault();\r\n\r\n oktaAuth.signInWithCredentials({ username, password })\r\n .then(res => {\r\n const sessionToken = res.sessionToken;\r\n setSessionToken(sessionToken);\r\n // sessionToken is a one-use token, so make sure this is only called once\r\n oktaAuth.signInWithRedirect({ sessionToken, originalUri: '/home' });\r\n })\r\n .catch(err => console.log('Found an error', err));\r\n };\r\n\r\n if (sessionToken) {\r\n // Hide form while sessionToken is converted into id/access tokens\r\n return null;\r\n }\r\n\r\n if (!authState || !authState.isAuthenticated) {\r\n return (\r\n <div className=\"pageContainer\">\r\n <SignUp />\r\n\r\n <div className=\"signInForm\">\r\n <h2>Sign in to PipIt</h2>\r\n <form onSubmit={handleSignInFormSubmit}>\r\n <label>\r\n Email:\r\n <input\r\n id=\"username\" type=\"text\"\r\n value={username}\r\n onChange={handleUsernameChange} />\r\n </label>\r\n <label>\r\n Password:\r\n <input\r\n id=\"password\" type=\"password\"\r\n value={password}\r\n onChange={handlePasswordChange} />\r\n </label>\r\n <button className=\"formSubmitButton\" type=\"submit\">\r\n Sign in&nbsp;&nbsp;\r\n <FontAwesomeIcon icon=\"sign-in-alt\"></FontAwesomeIcon>\r\n </button>\r\n </form>\r\n <PasswordForgotModal loginFormUsername={\"username\"} />\r\n </div>\r\n </div>\r\n )\r\n } else {\r\n return <Redirect to=\"/home\" />\r\n }\r\n}\r\n\r\nexport default Login"]},"metadata":{},"sourceType":"module"}
\ No newline at end of file
{"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 { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\n\nconst PasswordForgotModal = () => {\n _s();\n\n const [username, setUsername] = useState('');\n const [forgotPasswordFormVisibilityState, showForgotPasswordForm] = useState(false);\n const forgotPasswordFormRef = useRef(null);\n\n const toggleForgotPasswordFormVisible = () => showForgotPasswordForm(!forgotPasswordFormVisibilityState);\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 ForgotPasswordRequestOptions = {\n method: 'PUT',\n body: JSON.stringify({\n email: `${username}`\n })\n };\n\n const handlePasswordForgot = () => {\n fetch(config.serviceAPI.ForgotPasswordURL, ForgotPasswordRequestOptions).then(res => {\n if (!res.ok) {\n window.alert(\"Error: something went wrong\");\n Promise.reject(\"\");\n return;\n }\n\n if (res.ok) {// do something\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: 59,\n columnNumber: 11\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 58,\n columnNumber: 9\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 57,\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: 66,\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: 70,\n columnNumber: 17\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 68,\n columnNumber: 15\n }, this), /*#__PURE__*/_jsxDEV(\"label\", {\n children: \"An email with a password recovery link will be sent if registered is our system\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 75,\n columnNumber: 15\n }, this), /*#__PURE__*/_jsxDEV(\"button\", {\n className: \"formSubmitButton\",\n type: \"submit\",\n children: [\"Sign Up\\xA0\\xA0\", /*#__PURE__*/_jsxDEV(FontAwesomeIcon, {\n icon: \"arrow-right\"\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)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 67,\n columnNumber: 13\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 65,\n columnNumber: 11\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 64,\n columnNumber: 9\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 63,\n columnNumber: 7\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 56,\n columnNumber: 5\n }, this);\n};\n\n_s(PasswordForgotModal, \"VvmgU4VTr5ZNKM/8uo86UTvcRWY=\");\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","PasswordForgotModal","username","setUsername","forgotPasswordFormVisibilityState","showForgotPasswordForm","forgotPasswordFormRef","toggleForgotPasswordFormVisible","handleUsernameChange","e","target","value","pageClickEvent","current","contains","window","addEventListener","removeEventListener","ForgotPasswordRequestOptions","method","body","JSON","stringify","email","handlePasswordForgot","fetch","serviceAPI","ForgotPasswordURL","then","res","ok","alert","Promise","reject"],"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;;;AAEA,MAAMC,mBAAmB,GAAG,MAAM;AAAA;;AAChC,QAAM,CAACC,QAAD,EAAWC,WAAX,IAA0BP,QAAQ,CAAC,EAAD,CAAxC;AACA,QAAM,CAACQ,iCAAD,EAAoCC,sBAApC,IAA8DT,QAAQ,CAAC,KAAD,CAA5E;AACA,QAAMU,qBAAqB,GAAGT,MAAM,CAAC,IAAD,CAApC;;AACA,QAAMU,+BAA+B,GAAG,MAAMF,sBAAsB,CAAC,CAACD,iCAAF,CAApE;;AAEA,QAAMI,oBAAoB,GAAIC,CAAD,IAAO;AAClCN,IAAAA,WAAW,CAACM,CAAC,CAACC,MAAF,CAASC,KAAV,CAAX;AACD,GAFD;;AAIAb,EAAAA,SAAS,CAAC,MAAM;AACd,UAAMc,cAAc,GAAIH,CAAD,IAAO;AAC5B,UAAIH,qBAAqB,CAACO,OAAtB,KAAkC,IAAlC,IAA0C,CAACP,qBAAqB,CAACO,OAAtB,CAA8BC,QAA9B,CAAuCL,CAAC,CAACC,MAAzC,CAA/C,EAAiG;AAC/FH,QAAAA,+BAA+B;AAChC;AACF,KAJD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A;AAAA;AAAA;AAAA,kBADF,eAEE;AAAM,YAAA,QAAQ,EAAEkB,oBAAhB;AAAA,oCACE;AAAA,gDAEE;AACE,gBAAA,EAAE,EAAC,OADL;AACa,gBAAA,IAAI,EAAC,MADlB;AAEE,gBAAA,KAAK,EAAEtB,QAFT;AAGE,gBAAA,QAAQ,EAAEM;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,yDAEE,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,YAPF;AAAA;AAAA;AAAA;AAAA;AAAA,UADF;AAkCD,CAnFD;;GAAMP,mB;;KAAAA,mB;AAqFN,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\n\r\nconst PasswordForgotModal = () => {\r\n const [username, setUsername] = useState('');\r\n const [forgotPasswordFormVisibilityState, showForgotPasswordForm] = useState(false)\r\n const forgotPasswordFormRef = useRef(null);\r\n const toggleForgotPasswordFormVisible = () => showForgotPasswordForm(!forgotPasswordFormVisibilityState)\r\n\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 ForgotPasswordRequestOptions = {\r\n method: 'PUT',\r\n body: JSON.stringify({\r\n email: `${username}`\r\n })\r\n }\r\n\r\n const handlePasswordForgot = () => {\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 // do something\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 <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 registered is our system\r\n </label>\r\n <button className=\"formSubmitButton\" type=\"submit\">\r\n Sign Up&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\r\n )\r\n}\r\n\r\nexport default PasswordForgotModal\r\n"]},"metadata":{},"sourceType":"module"}
\ No newline at end of file
{"ast":null,"code":"var _jsxFileName = \"C:\\\\Users\\\\Bruger\\\\Desktop\\\\Web-projects\\\\pipit\\\\client\\\\src\\\\pages\\\\login\\\\Login.jsx\",\n _s = $RefreshSig$();\n\nimport React, { useState, useEffect, useRef } from 'react';\nimport { Redirect } from 'react-router-dom';\nimport { useOktaAuth } from '@okta/okta-react';\nimport \"./Login.css\";\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\nimport { NavLink } from 'react-router-dom';\nimport signUp from './signUp/SignUp';\nimport config from '../../config';\nimport SignUp from './signUp/SignUp';\nimport { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\n\nconst Login = () => {\n _s();\n\n const {\n authState,\n oktaAuth\n } = useOktaAuth();\n const [sessionToken, setSessionToken] = useState();\n const [username, setUsername] = useState('');\n const [password, setPassword] = useState('');\n\n const handleUsernameChange = e => {\n setUsername(e.target.value);\n };\n\n const handlePasswordChange = e => {\n setPassword(e.target.value);\n };\n\n const userInputData = JSON.stringify({\n email: `${username}`,\n password: `${password}`\n });\n const loginRequestOptions = {\n method: 'POST',\n body: userInputData\n };\n\n const handleSignInFormSubmit = e => {\n e.preventDefault();\n oktaAuth.signInWithCredentials({\n username,\n password\n }).then(res => {\n const sessionToken = res.sessionToken;\n setSessionToken(sessionToken); // sessionToken is a one-use token, so make sure this is only called once\n\n oktaAuth.signInWithRedirect({\n sessionToken,\n originalUri: '/home'\n });\n }).catch(err => console.log('Found an error', err));\n };\n\n if (sessionToken) {\n // Hide form while sessionToken is converted into id/access tokens\n return null;\n }\n\n if (!authState || !authState.isAuthenticated) {\n return /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"pageContainer\",\n children: [/*#__PURE__*/_jsxDEV(SignUp, {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 57,\n columnNumber: 9\n }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"signInForm\",\n children: [/*#__PURE__*/_jsxDEV(\"h2\", {\n children: \"Sign in to PipIt\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 60,\n columnNumber: 11\n }, this), /*#__PURE__*/_jsxDEV(\"form\", {\n onSubmit: handleSignInFormSubmit,\n children: [/*#__PURE__*/_jsxDEV(\"label\", {\n children: [\"Email:\", /*#__PURE__*/_jsxDEV(\"input\", {\n id: \"username\",\n type: \"text\",\n value: username,\n onChange: handleUsernameChange\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 64,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 62,\n columnNumber: 13\n }, this), /*#__PURE__*/_jsxDEV(\"label\", {\n children: [\"Password:\", /*#__PURE__*/_jsxDEV(\"input\", {\n id: \"password\",\n type: \"password\",\n value: password,\n onChange: handlePasswordChange\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 71,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 69,\n columnNumber: 13\n }, this), /*#__PURE__*/_jsxDEV(\"button\", {\n className: \"formSubmitButton\",\n type: \"submit\",\n children: [\"Sign in\\xA0\\xA0\", /*#__PURE__*/_jsxDEV(FontAwesomeIcon, {\n icon: \"sign-in-alt\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 78,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 76,\n columnNumber: 13\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 61,\n columnNumber: 11\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 59,\n columnNumber: 9\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 56,\n columnNumber: 7\n }, this);\n } else {\n return /*#__PURE__*/_jsxDEV(Redirect, {\n to: \"/home\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 85,\n columnNumber: 12\n }, this);\n }\n};\n\n_s(Login, \"u8yY6NlW4PSOG6xgLhGhaVL5lVE=\", false, function () {\n return [useOktaAuth];\n});\n\n_c = Login;\nexport default Login;\n\nvar _c;\n\n$RefreshReg$(_c, \"Login\");","map":{"version":3,"sources":["C:/Users/Bruger/Desktop/Web-projects/pipit/client/src/pages/login/Login.jsx"],"names":["React","useState","useEffect","useRef","Redirect","useOktaAuth","FontAwesomeIcon","NavLink","signUp","config","SignUp","Login","authState","oktaAuth","sessionToken","setSessionToken","username","setUsername","password","setPassword","handleUsernameChange","e","target","value","handlePasswordChange","userInputData","JSON","stringify","email","loginRequestOptions","method","body","handleSignInFormSubmit","preventDefault","signInWithCredentials","then","res","signInWithRedirect","originalUri","catch","err","console","log","isAuthenticated"],"mappings":";;;AAAA,OAAOA,KAAP,IAAgBC,QAAhB,EAA0BC,SAA1B,EAAqCC,MAArC,QAAmD,OAAnD;AACA,SAASC,QAAT,QAAyB,kBAAzB;AACA,SAASC,WAAT,QAA4B,kBAA5B;AACA,OAAO,aAAP;AACA,SAASC,eAAT,QAAgC,gCAAhC;AACA,SAASC,OAAT,QAAwB,kBAAxB;AACA,OAAOC,MAAP,MAAmB,iBAAnB;AACA,OAAOC,MAAP,MAAmB,cAAnB;AACA,OAAOC,MAAP,MAAmB,iBAAnB;;;AAEA,MAAMC,KAAK,GAAG,MAAM;AAAA;;AAClB,QAAM;AAAEC,IAAAA,SAAF;AAAaC,IAAAA;AAAb,MAA0BR,WAAW,EAA3C;AACA,QAAM,CAACS,YAAD,EAAeC,eAAf,IAAkCd,QAAQ,EAAhD;AAEA,QAAM,CAACe,QAAD,EAAWC,WAAX,IAA0BhB,QAAQ,CAAC,EAAD,CAAxC;AACA,QAAM,CAACiB,QAAD,EAAWC,WAAX,IAA0BlB,QAAQ,CAAC,EAAD,CAAxC;;AAEA,QAAMmB,oBAAoB,GAAIC,CAAD,IAAO;AAClCJ,IAAAA,WAAW,CAACI,CAAC,CAACC,MAAF,CAASC,KAAV,CAAX;AACD,GAFD;;AAIA,QAAMC,oBAAoB,GAAIH,CAAD,IAAO;AAClCF,IAAAA,WAAW,CAACE,CAAC,CAACC,MAAF,CAASC,KAAV,CAAX;AACD,GAFD;;AAIA,QAAME,aAAa,GAA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QAAQ,EAAEI;AAHZ;AAAA;AAAA;AAAA;AAAA,oBAFF;AAAA;AAAA;AAAA;AAAA;AAAA,kBADF,eAQE;AAAA,iDAEE;AACE,cAAA,EAAE,EAAC,UADL;AACgB,cAAA,IAAI,EAAC,UADrB;AAEE,cAAA,KAAK,EAAEF,QAFT;AAGE,cAAA,QAAQ,EAAEM;AAHZ;AAAA;AAAA;AAAA;AAAA,oBAFF;AAAA;AAAA;AAAA;AAAA;AAAA,kBARF,eAeE;AAAQ,YAAA,SAAS,EAAC,kBAAlB;AAAqC,YAAA,IAAI,EAAC,QAA1C;AAAA,uDAEE,QAAC,eAAD;AAAiB,cAAA,IAAI,EAAC;AAAtB;AAAA;AAAA;AAAA;AAAA,oBAFF;AAAA;AAAA;AAAA;AAAA;AAAA,kBAfF;AAAA;AAAA;AAAA;AAAA;AAAA,gBAFF;AAAA;AAAA;AAAA;AAAA;AAAA,cAHF;AAAA;AAAA;AAAA;AAAA;AAAA,YADF;AA6BD,GA9BD,MA8BO;AACL,wBAAO,QAAC,QAAD;AAAU,MAAA,EAAE,EAAC;AAAb;AAAA;AAAA;AAAA;AAAA,YAAP;AACD;AACF,CA5ED;;GAAMb,K;UAC4BN,W;;;KAD5BM,K;AA8EN,eAAeA,KAAf","sourcesContent":["import React, { useState, useEffect, useRef } from 'react';\r\nimport { Redirect } from 'react-router-dom'\r\nimport { useOktaAuth } from '@okta/okta-react';\r\nimport \"./Login.css\"\r\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome'\r\nimport { NavLink } from 'react-router-dom';\r\nimport signUp from './signUp/SignUp';\r\nimport config from '../../config';\r\nimport SignUp from './signUp/SignUp';\r\n\r\nconst Login = () => {\r\n const { authState, oktaAuth } = useOktaAuth();\r\n const [sessionToken, setSessionToken] = useState()\r\n\r\n const [username, setUsername] = useState('');\r\n const [password, setPassword] = useState('');\r\n\r\n const handleUsernameChange = (e) => {\r\n setUsername(e.target.value);\r\n };\r\n\r\n const handlePasswordChange = (e) => {\r\n setPassword(e.target.value)\r\n }\r\n\r\n const userInputData = JSON.stringify({\r\n email: `${username}`,\r\n password: `${password}`\r\n })\r\n\r\n const loginRequestOptions = {\r\n method: 'POST',\r\n body: userInputData\r\n };\r\n\r\n const handleSignInFormSubmit = (e) => {\r\n e.preventDefault();\r\n\r\n oktaAuth.signInWithCredentials({ username, password })\r\n .then(res => {\r\n const sessionToken = res.sessionToken;\r\n setSessionToken(sessionToken);\r\n // sessionToken is a one-use token, so make sure this is only called once\r\n oktaAuth.signInWithRedirect({ sessionToken, originalUri: '/home' });\r\n })\r\n .catch(err => console.log('Found an error', err));\r\n };\r\n\r\n if (sessionToken) {\r\n // Hide form while sessionToken is converted into id/access tokens\r\n return null;\r\n }\r\n\r\n if (!authState || !authState.isAuthenticated) {\r\n return (\r\n <div className=\"pageContainer\">\r\n <SignUp />\r\n\r\n <div className=\"signInForm\">\r\n <h2>Sign in to PipIt</h2>\r\n <form onSubmit={handleSignInFormSubmit}>\r\n <label>\r\n Email:\r\n <input\r\n id=\"username\" type=\"text\"\r\n value={username}\r\n onChange={handleUsernameChange} />\r\n </label>\r\n <label>\r\n Password:\r\n <input\r\n id=\"password\" type=\"password\"\r\n value={password}\r\n onChange={handlePasswordChange} />\r\n </label>\r\n <button className=\"formSubmitButton\" type=\"submit\">\r\n Sign in&nbsp;&nbsp;\r\n <FontAwesomeIcon icon=\"sign-in-alt\"></FontAwesomeIcon>\r\n </button>\r\n </form>\r\n </div>\r\n </div>\r\n )\r\n } else {\r\n return <Redirect to=\"/home\" />\r\n }\r\n}\r\n\r\nexport default Login"]},"metadata":{},"sourceType":"module"}
\ No newline at end of file
{"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 { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\n\nconst PasswordForgotModal = ({\n loginFormUsername\n}) => {\n _s();\n\n // Submit ok modal\n const [submitOkModalVisibilityState, showSubmitOkModal] = useState(false);\n const submitOkModalRef = useRef(null);\n\n const toggleSubmitOkModalVisible = () => showSubmitOkModal(!submitOkModalVisibilityState); // Forgot password form\n\n\n const [forgotPasswordFormVisibilityState, showForgotPasswordForm] = useState(false);\n const forgotPasswordFormRef = useRef(null);\n\n const toggleForgotPasswordFormVisible = () => showForgotPasswordForm(!forgotPasswordFormVisibilityState);\n\n const [username, setUsername] = useState('');\n\n const handleUsernameChange = e => {\n setUsername(e.target.value);\n };\n\n useEffect(() => {\n setUsername(loginFormUsername);\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 useEffect(() => {\n const pageClickEvent = e => {\n if (submitOkModalRef.current !== null && !submitOkModalRef.current.contains(e.target)) {\n toggleSubmitOkModalVisible();\n }\n }; // If the item is active (ie open) then listen for clicks\n\n\n if (submitOkModalVisibilityState) {\n window.addEventListener('click', pageClickEvent);\n }\n\n return () => {\n window.removeEventListener('click', pageClickEvent);\n };\n }, [submitOkModalVisibilityState]);\n const ForgotPasswordRequestOptions = {\n method: 'PUT',\n body: JSON.stringify({\n email: `${username}`\n })\n };\n\n const handlePasswordForgot = () => {\n fetch(config.serviceAPI.ForgotPasswordURL, ForgotPasswordRequestOptions).then(res => {\n if (!res.ok) {\n window.alert(\"Error: something went wrong\");\n Promise.reject(\"\");\n return;\n }\n\n if (res.ok) {// 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: 89,\n columnNumber: 11\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 88,\n columnNumber: 9\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 87,\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: 97,\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: 101,\n columnNumber: 17\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 99,\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: 106,\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: 111,\n columnNumber: 17\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 109,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 98,\n columnNumber: 13\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 96,\n columnNumber: 11\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 95,\n columnNumber: 9\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 94,\n columnNumber: 7\n }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n className: `modal ${submitOkModalVisibilityState ? \"active\" : \"inactive\"}`,\n children: /*#__PURE__*/_jsxDEV(\"div\", {\n ref: submitOkModalRef,\n className: \"modal-content\",\n children: /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"submitOkModal\",\n children: [/*#__PURE__*/_jsxDEV(\"h2\", {\n children: \"Email submitted!\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 122,\n columnNumber: 13\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: 123,\n columnNumber: 13\n }, this), /*#__PURE__*/_jsxDEV(\"button\", {\n className: \"formSubmitButton\",\n type: \"submit\",\n children: \"Ok\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 126,\n columnNumber: 13\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 121,\n columnNumber: 11\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 120,\n columnNumber: 9\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 119,\n columnNumber: 7\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 86,\n columnNumber: 5\n }, this);\n};\n\n_s(PasswordForgotModal, \"6nRVeLyPRLhEC+nG9QEudfxhhrM=\");\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","PasswordForgotModal","loginFormUsername","submitOkModalVisibilityState","showSubmitOkModal","submitOkModalRef","toggleSubmitOkModalVisible","forgotPasswordFormVisibilityState","showForgotPasswordForm","forgotPasswordFormRef","toggleForgotPasswordFormVisible","username","setUsername","handleUsernameChange","e","target","value","pageClickEvent","current","contains","window","addEventListener","removeEventListener","ForgotPasswordRequestOptions","method","body","JSON","stringify","email","handlePasswordForgot","fetch","serviceAPI","ForgotPasswordURL","then","res","ok","alert","Promise","reject"],"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;;;AAEA,MAAMC,mBAAmB,GAAG,CAAC;AAAEC,EAAAA;AAAF,CAAD,KAA2B;AAAA;;AACrD;AACA,QAAM,CAACC,4BAAD,EAA+BC,iBAA/B,IAAoDR,QAAQ,CAAC,KAAD,CAAlE;AACA,QAAMS,gBAAgB,GAAGR,MAAM,CAAC,IAAD,CAA/B;;AACA,QAAMS,0BAA0B,GAAG,MAAMF,iBAAiB,CAAC,CAACD,4BAAF,CAA1D,CAJqD,CAMrD;;;AACA,QAAM,CAACI,iCAAD,EAAoCC,sBAApC,IAA8DZ,QAAQ,CAAC,KAAD,CAA5E;AACA,QAAMa,qBAAqB,GAAGZ,MAAM,CAAC,IAAD,CAApC;;AACA,QAAMa,+BAA+B,GAAG,MAAM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EAAC,MADlB;AAEE,gBAAA,KAAK,EAAElB,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,eAiCE;AAAK,MAAA,SAAS,EAAG,SAAQV,4BAA4B,GAAG,QAAH,GAAc,UAAW,EAA9E;AAAA,6BACE;AAAK,QAAA,GAAG,EAAEE,gBAAV;AAA4B,QAAA,SAAS,EAAC,eAAtC;AAAA,+BACE;AAAK,UAAA,SAAS,EAAC,eAAf;AAAA,kCACE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBADF,eAEE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAFF,eAKE;AAAQ,YAAA,SAAS,EAAC,kBAAlB;AAAqC,YAAA,IAAI,EAAC,QAA1C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBALF;AAAA;AAAA;AAAA;AAAA;AAAA;AADF;AAAA;AAAA;AAAA;AAAA;AADF;AAAA;AAAA;AAAA;AAAA,YAjCF;AAAA;AAAA;AAAA;AAAA;AAAA,UADF;AAkDD,CAjID;;GAAMJ,mB;;KAAAA,mB;AAmIN,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\n\r\nconst PasswordForgotModal = ({ loginFormUsername }) => {\r\n // Submit ok modal\r\n const [submitOkModalVisibilityState, showSubmitOkModal] = useState(false)\r\n const submitOkModalRef = useRef(null)\r\n const toggleSubmitOkModalVisible = () => showSubmitOkModal(!submitOkModalVisibilityState)\r\n\r\n // Forgot password form\r\n const [forgotPasswordFormVisibilityState, showForgotPasswordForm] = useState(false)\r\n const forgotPasswordFormRef = useRef(null)\r\n const toggleForgotPasswordFormVisible = () => showForgotPasswordForm(!forgotPasswordFormVisibilityState)\r\n\r\n\r\n const [username, setUsername] = useState('');\r\n\r\n const handleUsernameChange = (e) => {\r\n setUsername(e.target.value);\r\n };\r\n\r\n useEffect(() => {\r\n setUsername(loginFormUsername)\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 useEffect(() => {\r\n const pageClickEvent = (e) => {\r\n if (submitOkModalRef.current !== null && !submitOkModalRef.current.contains(e.target)) {\r\n toggleSubmitOkModalVisible()\r\n }\r\n };\r\n\r\n // If the item is active (ie open) then listen for clicks\r\n if (submitOkModalVisibilityState) {\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 }, [submitOkModalVisibilityState]);\r\n\r\n const ForgotPasswordRequestOptions = {\r\n method: 'PUT',\r\n body: JSON.stringify({\r\n email: `${username}`\r\n })\r\n }\r\n\r\n const handlePasswordForgot = () => {\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\r\n {/* SubmitOk modal */}\r\n <div className={`modal ${submitOkModalVisibilityState ? \"active\" : \"inactive\"}`}>\r\n <div ref={submitOkModalRef} className=\"modal-content\">\r\n <div className=\"submitOkModal\">\r\n <h2>Email submitted!</h2>\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 Ok\r\n </button>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n )\r\n}\r\n\r\nexport default PasswordForgotModal\r\n"]},"metadata":{},"sourceType":"module"}
\ No newline at end of file
{"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 removeModal\n}) => {\n _s();\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 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 removeModal();\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 className: \"modal-content\",\n onClick: e => removeModal(),\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: 45,\n columnNumber: 9\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: 49,\n columnNumber: 13\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 47,\n columnNumber: 11\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: 56,\n columnNumber: 13\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 54,\n columnNumber: 11\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 46,\n columnNumber: 9\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 44,\n columnNumber: 7\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 43,\n columnNumber: 5\n }, this);\n};\n\n_s(PasswordForgotModal, \"ccs9TXv4Z39DCQsrqL8dXg2nBZI=\");\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","removeModal","submitOkMessageModalState","setSubmitOkMessageModalState","username","setUsername","handleUsernameChange","e","target","value","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,CAAC;AAAEC,EAAAA;AAAF,CAAD,KAAqB;AAAA;;AAC/C,QAAM,CAACC,yBAAD,EAA4BC,4BAA5B,IAA4DT,QAAQ,CAAC,KAAD,CAA1E;AAEA,QAAM,CAACU,QAAD,EAA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AAA;AAAA;AAAA;AAAA;AAAA,cAFF;AAAA;AAAA;AAAA;AAAA;AAAA;AADF;AAAA;AAAA;AAAA;AAAA,UADF;AAoBD,CAvDD;;GAAMN,mB;;KAAAA,mB;AAyDN,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 = ({ removeModal }) => {\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 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 removeModal()\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 className=\"modal-content\" onClick={e => removeModal()}>\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 <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 )\r\n}\r\n\r\nexport default PasswordForgotModal\r\n"]},"metadata":{},"sourceType":"module"}
\ No newline at end of file
{"ast":null,"code":"var _jsxFileName = \"C:\\\\Users\\\\Bruger\\\\Desktop\\\\Web-projects\\\\pipit\\\\client\\\\src\\\\pages\\\\login\\\\Login.jsx\",\n _s = $RefreshSig$();\n\nimport React, { useState, useEffect, useRef } from 'react';\nimport { Redirect } from 'react-router-dom';\nimport { useOktaAuth } from '@okta/okta-react';\nimport \"./Login.css\";\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\nimport { NavLink } from 'react-router-dom';\nimport signUp from './signUp/SignUp';\nimport config from '../../config';\nimport SignUp from './signUp/SignUp';\nimport PasswordResetModal from './passwordReset/PasswordResetModal';\nimport { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\n\nconst Login = () => {\n _s();\n\n const {\n authState,\n oktaAuth\n } = useOktaAuth();\n const [sessionToken, setSessionToken] = useState();\n const [username, setUsername] = useState('');\n const [password, setPassword] = useState('');\n\n const handleUsernameChange = e => {\n setUsername(e.target.value);\n };\n\n const handlePasswordChange = e => {\n setPassword(e.target.value);\n };\n\n const userInputData = JSON.stringify({\n email: `${username}`,\n password: `${password}`\n });\n const loginRequestOptions = {\n method: 'POST',\n body: userInputData\n };\n\n const handleSignInFormSubmit = e => {\n e.preventDefault();\n oktaAuth.signInWithCredentials({\n username,\n password\n }).then(res => {\n const sessionToken = res.sessionToken;\n setSessionToken(sessionToken); // sessionToken is a one-use token, so make sure this is only called once\n\n oktaAuth.signInWithRedirect({\n sessionToken,\n originalUri: '/home'\n });\n }).catch(err => console.log('Found an error', err));\n };\n\n if (sessionToken) {\n // Hide form while sessionToken is converted into id/access tokens\n return null;\n }\n\n if (!authState || !authState.isAuthenticated) {\n return /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"pageContainer\",\n children: [/*#__PURE__*/_jsxDEV(SignUp, {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 58,\n columnNumber: 9\n }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"signInForm\",\n children: [/*#__PURE__*/_jsxDEV(\"h2\", {\n children: \"Sign in to PipIt\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 61,\n columnNumber: 11\n }, this), /*#__PURE__*/_jsxDEV(\"form\", {\n onSubmit: handleSignInFormSubmit,\n children: [/*#__PURE__*/_jsxDEV(\"label\", {\n children: [\"Email:\", /*#__PURE__*/_jsxDEV(\"input\", {\n id: \"username\",\n type: \"text\",\n value: username,\n onChange: handleUsernameChange\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 65,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 63,\n columnNumber: 13\n }, this), /*#__PURE__*/_jsxDEV(\"label\", {\n children: [\"Password:\", /*#__PURE__*/_jsxDEV(\"input\", {\n id: \"password\",\n type: \"password\",\n value: password,\n onChange: handlePasswordChange\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 72,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 70,\n columnNumber: 13\n }, this), /*#__PURE__*/_jsxDEV(\"button\", {\n className: \"formSubmitButton\",\n type: \"submit\",\n children: [\"Sign in\\xA0\\xA0\", /*#__PURE__*/_jsxDEV(FontAwesomeIcon, {\n icon: \"sign-in-alt\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 79,\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: 62,\n columnNumber: 11\n }, this), /*#__PURE__*/_jsxDEV(PasswordResetModal, {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 82,\n columnNumber: 11\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 60,\n columnNumber: 9\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 57,\n columnNumber: 7\n }, this);\n } else {\n return /*#__PURE__*/_jsxDEV(Redirect, {\n to: \"/home\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 87,\n columnNumber: 12\n }, this);\n }\n};\n\n_s(Login, \"u8yY6NlW4PSOG6xgLhGhaVL5lVE=\", false, function () {\n return [useOktaAuth];\n});\n\n_c = Login;\nexport default Login;\n\nvar _c;\n\n$RefreshReg$(_c, \"Login\");","map":{"version":3,"sources":["C:/Users/Bruger/Desktop/Web-projects/pipit/client/src/pages/login/Login.jsx"],"names":["React","useState","useEffect","useRef","Redirect","useOktaAuth","FontAwesomeIcon","NavLink","signUp","config","SignUp","PasswordResetModal","Login","authState","oktaAuth","sessionToken","setSessionToken","username","setUsername","password","setPassword","handleUsernameChange","e","target","value","handlePasswordChange","userInputData","JSON","stringify","email","loginRequestOptions","method","body","handleSignInFormSubmit","preventDefault","signInWithCredentials","then","res","signInWithRedirect","originalUri","catch","err","console","log","isAuthenticated"],"mappings":";;;AAAA,OAAOA,KAAP,IAAgBC,QAAhB,EAA0BC,SAA1B,EAAqCC,MAArC,QAAmD,OAAnD;AACA,SAASC,QAAT,QAAyB,kBAAzB;AACA,SAASC,WAAT,QAA4B,kBAA5B;AACA,OAAO,aAAP;AACA,SAASC,eAAT,QAAgC,gCAAhC;AACA,SAASC,OAAT,QAAwB,kBAAxB;AACA,OAAOC,MAAP,MAAmB,iBAAnB;AACA,OAAOC,MAAP,MAAmB,cAAnB;AACA,OAAOC,MAAP,MAAmB,iBAAnB;AACA,OAAOC,kBAAP,MAA+B,oCAA/B;;;AAEA,MAAMC,KAAK,GAAG,MAAM;AAAA;;AAClB,QAAM;AAAEC,IAAAA,SAAF;AAAaC,IAAAA;AAAb,MAA0BT,WAAW,EAA3C;AACA,QAAM,CAACU,YAAD,EAAeC,eAAf,IAAkCf,QAAQ,EAAhD;AAEA,QAAM,CAACgB,QAAD,EAAWC,WAAX,IAA0BjB,QAAQ,CAAC,EAAD,CAAxC;AACA,Q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ktaAuth } from '@okta/okta-react';\r\nimport \"./Login.css\"\r\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome'\r\nimport { NavLink } from 'react-router-dom';\r\nimport signUp from './signUp/SignUp';\r\nimport config from '../../config';\r\nimport SignUp from './signUp/SignUp';\r\nimport PasswordResetModal from './passwordReset/PasswordResetModal';\r\n\r\nconst Login = () => {\r\n const { authState, oktaAuth } = useOktaAuth();\r\n const [sessionToken, setSessionToken] = useState()\r\n\r\n const [username, setUsername] = useState('');\r\n const [password, setPassword] = useState('');\r\n\r\n const handleUsernameChange = (e) => {\r\n setUsername(e.target.value);\r\n };\r\n\r\n const handlePasswordChange = (e) => {\r\n setPassword(e.target.value)\r\n }\r\n\r\n const userInputData = JSON.stringify({\r\n email: `${username}`,\r\n password: `${password}`\r\n })\r\n\r\n const loginRequestOptions = {\r\n method: 'POST',\r\n body: userInputData\r\n };\r\n\r\n const handleSignInFormSubmit = (e) => {\r\n e.preventDefault();\r\n\r\n oktaAuth.signInWithCredentials({ username, password })\r\n .then(res => {\r\n const sessionToken = res.sessionToken;\r\n setSessionToken(sessionToken);\r\n // sessionToken is a one-use token, so make sure this is only called once\r\n oktaAuth.signInWithRedirect({ sessionToken, originalUri: '/home' });\r\n })\r\n .catch(err => console.log('Found an error', err));\r\n };\r\n\r\n if (sessionToken) {\r\n // Hide form while sessionToken is converted into id/access tokens\r\n return null;\r\n }\r\n\r\n if (!authState || !authState.isAuthenticated) {\r\n return (\r\n <div className=\"pageContainer\">\r\n <SignUp />\r\n\r\n <div className=\"signInForm\">\r\n <h2>Sign in to PipIt</h2>\r\n <form onSubmit={handleSignInFormSubmit}>\r\n <label>\r\n Email:\r\n <input\r\n id=\"username\" type=\"text\"\r\n value={username}\r\n onChange={handleUsernameChange} />\r\n </label>\r\n <label>\r\n Password:\r\n <input\r\n id=\"password\" type=\"password\"\r\n value={password}\r\n onChange={handlePasswordChange} />\r\n </label>\r\n <button className=\"formSubmitButton\" type=\"submit\">\r\n Sign in&nbsp;&nbsp;\r\n <FontAwesomeIcon icon=\"sign-in-alt\"></FontAwesomeIcon>\r\n </button>\r\n </form>\r\n <PasswordResetModal />\r\n </div>\r\n </div>\r\n )\r\n } else {\r\n return <Redirect to=\"/home\" />\r\n }\r\n}\r\n\r\nexport default Login"]},"metadata":{},"sourceType":"module"}
\ No newline at end of file
{"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(); // toggleForgotPasswordFormVisible()\n // setSubmitOkMessageModalState(true)\n\n fetch(config.serviceAPI.ForgotPasswordURL, ForgotPasswordRequestOptions).then(res => {\n if (!res.ok) {\n window.alert(\"Error: something went wrong\");\n Promise.reject(\"\");\n return;\n }\n\n if (res.ok) {\n toggleForgotPasswordFormVisible();\n setSubmitOkMessageModalState(true);\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: 70,\n columnNumber: 11\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 69,\n columnNumber: 9\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 68,\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: 78,\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: 82,\n columnNumber: 17\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 80,\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: 87,\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: 92,\n columnNumber: 17\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 90,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 79,\n columnNumber: 13\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 77,\n columnNumber: 11\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 76,\n columnNumber: 9\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 75,\n columnNumber: 7\n }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n className: `modal ${submitOkMessageModalState ? \"active\" : \"inactive\"}`,\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: 99,\n columnNumber: 9\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 98,\n columnNumber: 7\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 67,\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","fetch","serviceAPI","ForgotPasswordURL","then","res","ok","alert","Promise","reject"],"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;;AAEA,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,CAAuC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,CAjGD;;GAAMN,mB;;KAAAA,mB;AAmGN,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\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 // toggleForgotPasswordFormVisible()\r\n // setSubmitOkMessageModalState(true)\r\n\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 toggleForgotPasswordFormVisible()\r\n setSubmitOkMessageModalState(true)\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 className={`modal ${submitOkMessageModalState ? \"active\" : \"inactive\"}`}>\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"}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment