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

Merge branch 'addLogin' into 'master'

Add login

See merge request au593919/pipit!1
parents 0d588800 2c3853a1
{"ast":null,"code":"import baseFlatten from './_baseFlatten.js';\n/**\n * Flattens `array` a single level deep.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Array\n * @param {Array} array The array to flatten.\n * @returns {Array} Returns the new flattened array.\n * @example\n *\n * _.flatten([1, [2, [3, [4]], 5]]);\n * // => [1, 2, [3, [4]], 5]\n */\n\nfunction flatten(array) {\n var length = array == null ? 0 : array.length;\n return length ? baseFlatten(array, 1) : [];\n}\n\nexport default flatten;","map":{"version":3,"sources":["C:/Users/Bruger/Desktop/Web-projects/pipit/client/node_modules/lodash-es/flatten.js"],"names":["baseFlatten","flatten","array","length"],"mappings":"AAAA,OAAOA,WAAP,MAAwB,mBAAxB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,OAAT,CAAiBC,KAAjB,EAAwB;AACtB,MAAIC,MAAM,GAAGD,KAAK,IAAI,IAAT,GAAgB,CAAhB,GAAoBA,KAAK,CAACC,MAAvC;AACA,SAAOA,MAAM,GAAGH,WAAW,CAACE,KAAD,EAAQ,CAAR,CAAd,GAA2B,EAAxC;AACD;;AAED,eAAeD,OAAf","sourcesContent":["import baseFlatten from './_baseFlatten.js';\n\n/**\n * Flattens `array` a single level deep.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Array\n * @param {Array} array The array to flatten.\n * @returns {Array} Returns the new flattened array.\n * @example\n *\n * _.flatten([1, [2, [3, [4]], 5]]);\n * // => [1, 2, [3, [4]], 5]\n */\nfunction flatten(array) {\n var length = array == null ? 0 : array.length;\n return length ? baseFlatten(array, 1) : [];\n}\n\nexport default flatten;\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\\\\home\\\\Home.jsx\";\nimport React from 'react';\nimport { NavLink } from 'react-router-dom';\nimport \"./Home.css\";\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\nimport Updates from './updates/Updates';\nimport { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\n\nconst Home = () => {\n return /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"homepage-container\",\n children: [/*#__PURE__*/_jsxDEV(\"div\", {\n className: \"content-header\",\n children: [/*#__PURE__*/_jsxDEV(\"h2\", {\n className: \"welcome-text\",\n children: [\"Welcome \", userInfo.given_name, \"!\"]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 12,\n columnNumber: 9\n }, this), /*#__PURE__*/_jsxDEV(NavLink, {\n to: \"/reportissue\",\n children: /*#__PURE__*/_jsxDEV(\"button\", {\n className: \"report-new-issue-button\",\n children: [/*#__PURE__*/_jsxDEV(FontAwesomeIcon, {\n icon: \"exclamation-triangle\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 15,\n columnNumber: 13\n }, this), \"\\xA0\\xA0Report issues\"]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 14,\n columnNumber: 11\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 13,\n columnNumber: 9\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 11,\n columnNumber: 7\n }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"homepage-content\",\n children: /*#__PURE__*/_jsxDEV(Updates, {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 21,\n columnNumber: 9\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 20,\n columnNumber: 7\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 10,\n columnNumber: 5\n }, this);\n};\n\n_c = Home;\nexport default Home;\n\nvar _c;\n\n$RefreshReg$(_c, \"Home\");","map":{"version":3,"sources":["C:/Users/Bruger/Desktop/Web-projects/pipit/client/src/components/home/Home.jsx"],"names":["React","NavLink","FontAwesomeIcon","Updates","Home","userInfo","given_name"],"mappings":";AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,OAAT,QAAwB,kBAAxB;AACA,OAAO,YAAP;AACA,SAASC,eAAT,QAAgC,gCAAhC;AACA,OAAOC,OAAP,MAAoB,mBAApB;;;AAEA,MAAMC,IAAI,GAAG,MAAM;AAEjB,sBACE;AAAK,IAAA,SAAS,EAAC,oBAAf;AAAA,4BACE;AAAK,MAAA,SAAS,EAAC,gBAAf;AAAA,8BACE;AAAI,QAAA,SAAS,EAAC,cAAd;AAAA,+BAAsCC,QAAQ,CAACC,UAA/C;AAAA;AAAA;AAAA;AAAA;AAAA,cADF,eAEE,QAAC,OAAD;AAAS,QAAA,EAAE,EAAC,cAAZ;AAAA,+BACE;AAAQ,UAAA,SAAS,EAAC,yBAAlB;AAAA,kCACE,QAAC,eAAD;AAAiB,YAAA,IAAI,EAAC;AAAtB;AAAA;AAAA;AAAA;AAAA,kBADF;AAAA;AAAA;AAAA;AAAA;AAAA;AADF;AAAA;AAAA;AAAA;AAAA,cAFF;AAAA;AAAA;AAAA;AAAA;AAAA,YADF,eAUE;AAAK,MAAA,SAAS,EAAC,kBAAf;AAAA,6BACE,QAAC,OAAD;AAAA;AAAA;AAAA;AAAA;AADF;AAAA;AAAA;AAAA;AAAA,YAVF;AAAA;AAAA;AAAA;AAAA;AAAA,UADF;AAgBD,CAlBD;;KAAMF,I;AAoBN,eAAeA,IAAf","sourcesContent":["import React from 'react'\r\nimport { NavLink } from 'react-router-dom'\r\nimport \"./Home.css\"\r\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome'\r\nimport Updates from './updates/Updates'\r\n\r\nconst Home = () => {\r\n\r\n return (\r\n <div className=\"homepage-container\">\r\n <div className=\"content-header\">\r\n <h2 className=\"welcome-text\">Welcome {userInfo.given_name}!</h2>\r\n <NavLink to=\"/reportissue\">\r\n <button className=\"report-new-issue-button\">\r\n <FontAwesomeIcon icon=\"exclamation-triangle\"></FontAwesomeIcon>\r\n &nbsp;&nbsp;Report issues\r\n </button>\r\n </NavLink>\r\n </div>\r\n <div className=\"homepage-content\">\r\n <Updates />\r\n </div>\r\n </div>\r\n )\r\n}\r\n\r\nexport default Home"]},"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 { 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\n const toggleSignInFormVisible = () => showSignUpForm(!signUpFormVisibilityState);\n\n const [username, setUsername] = useState('');\n const [password, setPassword] = useState('');\n useEffect(() => {\n const pageClickEvent = e => {\n console.log(\"Click\");\n\n if (signUpFormRef.current !== null && !signUpFormRef.current.contains(e.target)) {\n console.log(\"Form visible: \" + signUpFormVisibilityState);\n toggleSignInFormVisible();\n }\n }; // If the item is active (ie open) then listen for clicks\n\n\n if (signUpFormVisibilityState) {\n console.log(\"Add eventlistener\");\n window.addEventListener('click', pageClickEvent);\n }\n\n return () => {\n console.log(\"Remove eventlistener\");\n window.removeEventListener('click', pageClickEvent);\n };\n }, [signUpFormVisibilityState]);\n const userInputData = JSON.stringify({\n firstname: `${firstname}`,\n lastname: `${lastname}`,\n email: `${username}`,\n password: `${password}`\n });\n const loginRequestOptions = {\n method: 'POST',\n body: userInputData\n };\n const resetPasswordRequestOptions = {\n method: 'PUT',\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 const handlefirstnameChange = e => {\n setfirstname(e.target.value);\n };\n\n const handlelastnameChange = e => {\n setlastname(e.target.value);\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 handleConfirmPasswordChange = e => {\n setConfirmPassword(e.target.value);\n };\n\n if (sessionToken) {\n // Hide form while sessionToken is converted into id/access tokens\n return null;\n }\n\n const handlePasswordReset = () => {\n if (!username == '') {\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 } else {\n window.alert(\"Please enter a valid email into the login form\");\n }\n };\n\n if (!authState || !authState.isAuthenticated) {\n return /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"pageContainer\",\n children: [/*#__PURE__*/_jsxDEV(\"div\", {\n className: \"spacer\",\n children: /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"text-container\",\n children: [/*#__PURE__*/_jsxDEV(\"h1\", {\n children: \"Get started with PipIt\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 118,\n columnNumber: 13\n }, this), /*#__PURE__*/_jsxDEV(\"h5\", {\n children: \"Track bugs and usabilty issues\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 119,\n columnNumber: 13\n }, this), /*#__PURE__*/_jsxDEV(\"button\", {\n className: \"signUpForm-show-button\",\n onClick: toggleSignInFormVisible,\n children: \"Sign up\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 120,\n columnNumber: 13\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 117,\n columnNumber: 11\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 116,\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: 127,\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: signUpFormVisibilityState ? null : username,\n onChange: handleUsernameChange\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 131,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 129,\n columnNumber: 13\n }, this), /*#__PURE__*/_jsxDEV(\"label\", {\n children: [\"Password:\", /*#__PURE__*/_jsxDEV(\"input\", {\n id: \"password\",\n type: \"password\",\n value: signUpFormVisibilityState ? null : password,\n onChange: handlePasswordChange\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 138,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 136,\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: 145,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 143,\n columnNumber: 13\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 128,\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: handlePasswordReset,\n children: \"Forgot password\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 150,\n columnNumber: 15\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 149,\n columnNumber: 13\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 148,\n columnNumber: 11\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 126,\n columnNumber: 9\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 115,\n columnNumber: 7\n }, this);\n } else {\n return /*#__PURE__*/_jsxDEV(Redirect, {\n to: \"/home\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 157,\n columnNumber: 12\n }, this);\n }\n};\n\n_s(Login, \"wrhmVp2lhpyin9y/fggBjGZq26c=\", 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","Login","authState","oktaAuth","sessionToken","setSessionToken","toggleSignInFormVisible","showSignUpForm","signUpFormVisibilityState","username","setUsername","password","setPassword","pageClickEvent","e","console","log","signUpFormRef","current","contains","target","window","addEventListener","removeEventListener","userInputData","JSON","stringify","firstname","lastname","email","loginRequestOptions","method","body","resetPasswordRequestOptions","handleSignInFormSubmit","preventDefault","signInWithCredentials","then","res","signInWithRedirect","originalUri","catch","err","handlefirstnameChange","setfirstname","value","handlelastnameChange","setlastname","handleUsernameChange","handlePasswordChange","handleConfirmPasswordChange","setConfirmPassword","handlePasswordReset","fetch","config","serviceAPI","resetPasswordURL","ok","alert","Promise","reject","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;;;AAEA,MAAMC,KAAK,GAAG,MAAM;AAAA;;AAClB,QAAM;AAAEC,IAAAA,SAAF;AAAaC,IAAAA;AAAb,MAA0BN,WAAW,EAA3C;AACA,QAAM,CAACO,YAAD,EAAeC,eAAf,IAAkCZ,QAAQ,EAAhD;;AACA,QAAMa,uBAAuB,GAAG,MAAMC,cAAc,CAAC,CAACC,yBAAF,CAApD;;AAEA,QAAM,CAACC,QAAD,EAAWC,WAAX,IAA0BjB,QAAQ,CAAC,EAAD,CAAxC;AACA,QAAM,CAACkB,QAAD,EAAWC,WAAX,IAA0BnB,QAAQ,CAAC,EAAD,CAAxC;AAEAC,EAAAA,SAAS,CAAC,MAAM;AACd,UAAMmB,cAAc,GAAIC,CAAD,IAAO;AAC5BC,MAAAA,OAAO,CAACC,GAAR,CAAY,OAAZ;;AACA,UAAIC,aAAa,CAACC,OAAd,KAA0B,IAA1B,IAAkC,CAACD,aAAa,CAACC,OAAd,CAAsBC,QAAtB,CAA+BL,CAAC,CAACM,MAAjC,CAAvC,EAAiF;AAC/EL,QAAAA,OAAO,CAACC,GAAR,CAAY,mBAAmBR,yBAA/B;AACAF,QAAAA,uBAAuB;AACxB;AACF,KAND,CADc,CASd;;;AACA,QAAIE,yBAAJ,EAA+B;AAC7BO,MAAAA,OAAO,CAACC,GAAR,CAAY,mBAAZ;AACAK,MAAAA,MAAM,CAACC,gBAAP,CAAwB,OAAxB,EAAiCT,cAAj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;AAAA,mCACE;AAAG,cAAA,OAAO,EAAEG,mBAAZ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AADF;AAAA;AAAA;AAAA;AAAA;AADF;AAAA;AAAA;AAAA;AAAA,gBAtBF;AAAA;AAAA;AAAA;AAAA;AAAA,cAXF;AAAA;AAAA;AAAA;AAAA;AAAA,YADF;AA0CD,GA3CD,MA2CO;AACL,wBAAO,QAAC,QAAD;AAAU,MAAA,EAAE,EAAC;AAAb;AAAA;AAAA;AAAA;AAAA,YAAP;AACD;AACF,CAtJD;;GAAMnD,K;UAC4BJ,W;;;KAD5BI,K;AAwJN,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\n\r\nconst Login = () => {\r\n const { authState, oktaAuth } = useOktaAuth();\r\n const [sessionToken, setSessionToken] = useState()\r\n const toggleSignInFormVisible = () => showSignUpForm(!signUpFormVisibilityState)\r\n\r\n const [username, setUsername] = useState('');\r\n const [password, setPassword] = useState('');\r\n\r\n useEffect(() => {\r\n const pageClickEvent = (e) => {\r\n console.log(\"Click\")\r\n if (signUpFormRef.current !== null && !signUpFormRef.current.contains(e.target)) {\r\n console.log(\"Form visible: \" + signUpFormVisibilityState)\r\n toggleSignInFormVisible()\r\n }\r\n };\r\n\r\n // If the item is active (ie open) then listen for clicks\r\n if (signUpFormVisibilityState) {\r\n console.log(\"Add eventlistener\")\r\n window.addEventListener('click', pageClickEvent);\r\n }\r\n\r\n return () => {\r\n console.log(\"Remove eventlistener\")\r\n window.removeEventListener('click', pageClickEvent);\r\n }\r\n\r\n }, [signUpFormVisibilityState]);\r\n\r\n const userInputData = JSON.stringify({\r\n firstname: `${firstname}`,\r\n lastname: `${lastname}`,\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 resetPasswordRequestOptions = {\r\n method: 'PUT',\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 const handlefirstnameChange = (e) => {\r\n setfirstname(e.target.value)\r\n }\r\n\r\n const handlelastnameChange = (e) => {\r\n setlastname(e.target.value)\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 handleConfirmPasswordChange = (e) => {\r\n setConfirmPassword(e.target.value)\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 const handlePasswordReset = () => {\r\n if (!username == '') {\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 else {\r\n window.alert(\"Please enter a valid email into the login form\")\r\n }\r\n }\r\n\r\n if (!authState || !authState.isAuthenticated) {\r\n return (\r\n <div className=\"pageContainer\">\r\n <div className=\"spacer\">\r\n <div className=\"text-container\">\r\n <h1>Get started with PipIt</h1>\r\n <h5>Track bugs and usabilty issues</h5>\r\n <button className=\"signUpForm-show-button\" onClick={toggleSignInFormVisible}>\r\n Sign up\r\n </button>\r\n </div>\r\n </div>\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={signUpFormVisibilityState ? null : 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={signUpFormVisibilityState ? null : 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={handlePasswordReset}>Forgot password</a>\r\n </span>\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":"","map":{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[""]},"metadata":{},"sourceType":"module"}
\ No newline at end of file
{"ast":null,"code":"/** Used to stand-in for `undefined` hash values. */\nvar HASH_UNDEFINED = '__lodash_hash_undefined__';\n/**\n * Adds `value` to the array cache.\n *\n * @private\n * @name add\n * @memberOf SetCache\n * @alias push\n * @param {*} value The value to cache.\n * @returns {Object} Returns the cache instance.\n */\n\nfunction setCacheAdd(value) {\n this.__data__.set(value, HASH_UNDEFINED);\n\n return this;\n}\n\nexport default setCacheAdd;","map":{"version":3,"sources":["C:/Users/Bruger/Desktop/Web-projects/pipit/client/node_modules/lodash-es/_setCacheAdd.js"],"names":["HASH_UNDEFINED","setCacheAdd","value","__data__","set"],"mappings":"AAAA;AACA,IAAIA,cAAc,GAAG,2BAArB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,WAAT,CAAqBC,KAArB,EAA4B;AAC1B,OAAKC,QAAL,CAAcC,GAAd,CAAkBF,KAAlB,EAAyBF,cAAzB;;AACA,SAAO,IAAP;AACD;;AAED,eAAeC,WAAf","sourcesContent":["/** Used to stand-in for `undefined` hash values. */\nvar HASH_UNDEFINED = '__lodash_hash_undefined__';\n\n/**\n * Adds `value` to the array cache.\n *\n * @private\n * @name add\n * @memberOf SetCache\n * @alias push\n * @param {*} value The value to cache.\n * @returns {Object} Returns the cache instance.\n */\nfunction setCacheAdd(value) {\n this.__data__.set(value, HASH_UNDEFINED);\n return this;\n}\n\nexport default setCacheAdd;\n"]},"metadata":{},"sourceType":"module"}
\ No newline at end of file
{"ast":null,"code":"import baseGet from './_baseGet.js';\nimport baseSlice from './_baseSlice.js';\n/**\n * Gets the parent value at `path` of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {Array} path The path to get the parent value of.\n * @returns {*} Returns the parent value.\n */\n\nfunction parent(object, path) {\n return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));\n}\n\nexport default parent;","map":{"version":3,"sources":["C:/Users/Bruger/Desktop/Web-projects/pipit/client/node_modules/lodash-es/_parent.js"],"names":["baseGet","baseSlice","parent","object","path","length"],"mappings":"AAAA,OAAOA,OAAP,MAAoB,eAApB;AACA,OAAOC,SAAP,MAAsB,iBAAtB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,MAAT,CAAgBC,MAAhB,EAAwBC,IAAxB,EAA8B;AAC5B,SAAOA,IAAI,CAACC,MAAL,GAAc,CAAd,GAAkBF,MAAlB,GAA2BH,OAAO,CAACG,MAAD,EAASF,SAAS,CAACG,IAAD,EAAO,CAAP,EAAU,CAAC,CAAX,CAAlB,CAAzC;AACD;;AAED,eAAeF,MAAf","sourcesContent":["import baseGet from './_baseGet.js';\nimport baseSlice from './_baseSlice.js';\n\n/**\n * Gets the parent value at `path` of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {Array} path The path to get the parent value of.\n * @returns {*} Returns the parent value.\n */\nfunction parent(object, path) {\n return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));\n}\n\nexport default parent;\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\\\\confirmRemoveAccountModal\\\\ConfirmRemoveAccountModal.jsx\";\nimport React from 'react';\nimport { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\n\nconst ConfirmRemoveAccountModal = ({\n removeModal,\n headerMessage,\n bodyMessage\n}) => {\n const stopProp = e => {\n e.stopPropagation();\n };\n\n return /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"modal-content\",\n onClick: e => removeModal(),\n children: /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"confirmRemoveAccountModal\",\n children: [/*#__PURE__*/_jsxDEV(\"h2\", {\n children: \"Delete account\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 11,\n columnNumber: 9\n }, this), /*#__PURE__*/_jsxDEV(\"label\", {\n children: \"You are about to delete your account. Are you sure?\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 12,\n columnNumber: 9\n }, this), /*#__PURE__*/_jsxDEV(\"button\", {\n children: \"Yes\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 15,\n columnNumber: 9\n }, this), /*#__PURE__*/_jsxDEV(\"button\", {\n className: \"formSubmitButton\",\n onClick: e => removeModal(),\n children: \"No\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 18,\n columnNumber: 9\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 10,\n columnNumber: 7\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 9,\n columnNumber: 5\n }, this);\n};\n\n_c = ConfirmRemoveAccountModal;\nexport default ConfirmRemoveAccountModal;\n\nvar _c;\n\n$RefreshReg$(_c, \"ConfirmRemoveAccountModal\");","map":{"version":3,"sources":["C:/Users/Bruger/Desktop/Web-projects/pipit/client/src/components/confirmRemoveAccountModal/ConfirmRemoveAccountModal.jsx"],"names":["React","ConfirmRemoveAccountModal","removeModal","headerMessage","bodyMessage","stopProp","e","stopPropagation"],"mappings":";AAAA,OAAOA,KAAP,MAAkB,OAAlB;;;AAEA,MAAMC,yBAAyB,GAAG,CAAC;AAAEC,EAAAA,WAAF;AAAeC,EAAAA,aAAf;AAA8BC,EAAAA;AAA9B,CAAD,KAAiD;AACjF,QAAMC,QAAQ,GAAGC,CAAC,IAAI;AACpBA,IAAAA,CAAC,CAACC,eAAF;AACD,GAFD;;AAIA,sBACE;AAAK,IAAA,SAAS,EAAC,eAAf;AAA+B,IAAA,OAAO,EAAED,CAAC,IAAIJ,WAAW,EAAxD;AAAA,2BACE;AAAK,MAAA,SAAS,EAAC,2BAAf;AAAA,8BACE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,cADF,eAEE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,cAFF,eAKE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,cALF,eAQE;AAAQ,QAAA,SAAS,EAAC,kBAAlB;AAAqC,QAAA,OAAO,EAAEI,CAAC,IAAIJ,WAAW,EAA9D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,cARF;AAAA;AAAA;AAAA;AAAA;AAAA;AADF;AAAA;AAAA;AAAA;AAAA,UADF;AAgBD,CArBD;;KAAMD,yB;AAuBN,eAAeA,yBAAf","sourcesContent":["import React from 'react'\r\n\r\nconst ConfirmRemoveAccountModal = ({ removeModal, headerMessage, bodyMessage }) => {\r\n const stopProp = e => {\r\n e.stopPropagation()\r\n }\r\n\r\n return (\r\n <div className=\"modal-content\" onClick={e => removeModal()}>\r\n <div className=\"confirmRemoveAccountModal\">\r\n <h2>Delete account</h2>\r\n <label>\r\n You are about to delete your account. Are you sure?\r\n </label>\r\n <button>\r\n Yes\r\n </button>\r\n <button className=\"formSubmitButton\" onClick={e => removeModal()}>\r\n No\r\n </button>\r\n </div>\r\n </div>\r\n )\r\n}\r\n\r\nexport default ConfirmRemoveAccountModal\r\n"]},"metadata":{},"sourceType":"module"}
\ No newline at end of file
Markdown is supported
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