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

added new branch addTeam. Fixed user data update bug on cancel. Minor refactoring

parent 2c3853a1
This diff is collapsed.
{"ast":null,"code":"var _jsxFileName = \"C:\\\\Users\\\\Bruger\\\\Desktop\\\\Web-projects\\\\pipit\\\\client\\\\src\\\\components\\\\updateUserData\\\\updateUserDataModal\\\\UpdateUserDataModal.js\",\n _s = $RefreshSig$();\n\nimport React, { useState, useEffect } from 'react';\nimport \"./UpdateUserDataModal.css\";\nimport { useOktaAuth } from '@okta/okta-react';\nimport config from '../../../config';\nimport { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\n\nconst UpdateUserDataModal = ({\n removeModal\n}) => {\n _s();\n\n const {\n authState,\n oktaAuth\n } = useOktaAuth();\n const [userInfo, setUserInfo] = useState(null);\n const accessToken = oktaAuth.getAccessToken();\n\n const stopProp = e => {\n e.stopPropagation();\n e.preventDefault();\n };\n\n useEffect(() => {\n if (!authState.isAuthenticated) {\n // When user isn't authenticated, forget any user info\n setUserInfo(null);\n } else {\n oktaAuth.getUser().then(info => {\n setUserInfo(info);\n });\n }\n }, [authState, oktaAuth]); // Update if authState changes\n\n useEffect(() => {\n userInfo && setFirstname(userInfo.given_name);\n userInfo && setLastname(userInfo.family_name);\n userInfo && setUsername(userInfo.email);\n }, [userInfo]);\n const [firstname, setFirstname] = useState('');\n const [lastname, setLastname] = useState('');\n const [username, setUsername] = useState('');\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 userInputData = JSON.stringify({\n firstname: `${firstname}`,\n lastname: `${lastname}`,\n email: `${username}`\n });\n const updateUserDataRequestOptions = {\n method: 'PUT',\n headers: {\n Authorization: `Bearer ${accessToken}`\n },\n body: userInputData\n };\n\n const handleUpdateUserDataFormSubmit = e => {\n e.preventDefault();\n fetch(config.serviceAPI.updateUserDataURL, updateUserDataRequestOptions).then(res => {\n if (!res.ok) {\n window.alert(\"Error\");\n Promise.reject(\"\");\n return;\n }\n\n if (res.ok) {\n removeModal();\n }\n });\n };\n\n return /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"modal-content\",\n children: /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"updateUserDataModal\",\n children: [/*#__PURE__*/_jsxDEV(\"h2\", {\n children: \"Update information\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 90,\n columnNumber: 9\n }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n userDataSubmitForm: true,\n children: /*#__PURE__*/_jsxDEV(\"form\", {\n children: [/*#__PURE__*/_jsxDEV(\"label\", {\n children: [\"First name:\", /*#__PURE__*/_jsxDEV(\"input\", {\n id: \"firstname\",\n type: \"text\",\n value: firstname,\n onChange: handlefirstnameChange\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 95,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 93,\n columnNumber: 13\n }, this), /*#__PURE__*/_jsxDEV(\"label\", {\n children: [\"Last Name:\", /*#__PURE__*/_jsxDEV(\"input\", {\n id: \"lastname\",\n type: \"text\",\n value: lastname,\n onChange: handlelastnameChange\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 102,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 100,\n columnNumber: 13\n }, this), /*#__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: 109,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 107,\n columnNumber: 13\n }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"buttonContainer\",\n children: [/*#__PURE__*/_jsxDEV(\"button\", {\n className: \"noButton\",\n onClick: e => removeModal(),\n children: \"Cancel\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 115,\n columnNumber: 15\n }, this), /*#__PURE__*/_jsxDEV(\"button\", {\n className: \"yesButton\",\n onClick: handleUpdateUserDataFormSubmit,\n children: \"Update\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 118,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 114,\n columnNumber: 13\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 92,\n columnNumber: 11\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 91,\n columnNumber: 9\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 89,\n columnNumber: 7\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 88,\n columnNumber: 5\n }, this);\n};\n\n_s(UpdateUserDataModal, \"AxzdzHC979Yq9E6/6HJDjeCl4CA=\", false, function () {\n return [useOktaAuth];\n});\n\n_c = UpdateUserDataModal;\nexport default UpdateUserDataModal;\n\nvar _c;\n\n$RefreshReg$(_c, \"UpdateUserDataModal\");","map":{"version":3,"sources":["C:/Users/Bruger/Desktop/Web-projects/pipit/client/src/components/updateUserData/updateUserDataModal/UpdateUserDataModal.js"],"names":["React","useState","useEffect","useOktaAuth","config","UpdateUserDataModal","removeModal","authState","oktaAuth","userInfo","setUserInfo","accessToken","getAccessToken","stopProp","e","stopPropagation","preventDefault","isAuthenticated","getUser","then","info","setFirstname","given_name","setLastname","family_name","setUsername","email","firstname","lastname","username","handlefirstnameChange","target","value","handlelastnameChange","handleUsernameChange","userInputData","JSON","stringify","updateUserDataRequestOptions","method","headers","Authorization","body","handleUpdateUserDataFormSubmit","fetch","serviceAPI","updateUserDataURL","res","ok","window","alert","Promise","reject"],"mappings":";;;AAAA,OAAOA,KAAP,IAAgBC,QAAhB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;AAAA;AAAA;AAAA;AAAA,cAFF;AAAA;AAAA;AAAA;AAAA;AAAA;AADF;AAAA;AAAA;AAAA;AAAA,UADF;AAwCD,CAzHD;;GAAMtC,mB;UAC4BF,W;;;KAD5BE,mB;AA2HN,eAAeA,mBAAf","sourcesContent":["import React, { useState, useEffect } from 'react'\r\nimport \"./UpdateUserDataModal.css\"\r\nimport { useOktaAuth } from '@okta/okta-react';\r\nimport config from '../../../config';\r\n\r\nconst UpdateUserDataModal = ({ removeModal }) => {\r\n const { authState, oktaAuth } = useOktaAuth();\r\n const [userInfo, setUserInfo] = useState(null);\r\n const accessToken = oktaAuth.getAccessToken();\r\n\r\n const stopProp = e => {\r\n e.stopPropagation()\r\n e.preventDefault()\r\n }\r\n\r\n useEffect(() => {\r\n if (!authState.isAuthenticated) {\r\n // When user isn't authenticated, forget any user info\r\n setUserInfo(null);\r\n } else {\r\n oktaAuth.getUser().then(info => {\r\n setUserInfo(info);\r\n });\r\n }\r\n }, [authState, oktaAuth]); // Update if authState changes\r\n\r\n useEffect(() => {\r\n userInfo && (\r\n setFirstname(userInfo.given_name)\r\n )\r\n\r\n userInfo && (\r\n setLastname(userInfo.family_name)\r\n )\r\n\r\n userInfo && (\r\n setUsername(userInfo.email)\r\n )\r\n }, [userInfo])\r\n\r\n const [firstname, setFirstname] = useState('')\r\n const [lastname, setLastname] = useState('')\r\n const [username, setUsername] = useState('');\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 userInputData = JSON.stringify({\r\n firstname: `${firstname}`,\r\n lastname: `${lastname}`,\r\n email: `${username}`\r\n })\r\n\r\n const updateUserDataRequestOptions = {\r\n method: 'PUT',\r\n headers: {\r\n Authorization: `Bearer ${accessToken}`,\r\n },\r\n body: userInputData\r\n };\r\n\r\n const handleUpdateUserDataFormSubmit = (e) => {\r\n e.preventDefault();\r\n\r\n fetch(config.serviceAPI.updateUserDataURL, updateUserDataRequestOptions)\r\n .then((res) => {\r\n if (!res.ok) {\r\n window.alert(\"Error\")\r\n Promise.reject(\"\")\r\n return\r\n }\r\n if (res.ok) {\r\n removeModal()\r\n }\r\n })\r\n }\r\n\r\n return (\r\n <div className=\"modal-content\">\r\n <div className=\"updateUserDataModal\">\r\n <h2>Update information</h2>\r\n <div userDataSubmitForm>\r\n <form>\r\n <label>\r\n First name:\r\n <input\r\n id=\"firstname\" type=\"text\"\r\n value={firstname}\r\n onChange={handlefirstnameChange} />\r\n </label>\r\n <label>\r\n Last Name:\r\n <input\r\n id=\"lastname\" type=\"text\"\r\n value={lastname}\r\n onChange={handlelastnameChange} />\r\n </label>\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 <div className=\"buttonContainer\">\r\n <button className=\"noButton\" onClick={e => removeModal()}>\r\n Cancel\r\n </button>\r\n <button className=\"yesButton\" onClick={handleUpdateUserDataFormSubmit}>\r\n Update\r\n </button>\r\n </div>\r\n </form>\r\n </div>\r\n </div>\r\n </div>\r\n )\r\n}\r\n\r\nexport default UpdateUserDataModal\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.js\";\nimport React from 'react';\nimport { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\n\nconst MessageModal = ({\n removeModal,\n headerMessage,\n bodyMessage\n}) => {\n return /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"modal-content\",\n children: /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"submitOkModal\",\n children: [/*#__PURE__*/_jsxDEV(\"h2\", {\n children: headerMessage\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 8,\n columnNumber: 9\n }, this), /*#__PURE__*/_jsxDEV(\"label\", {\n children: bodyMessage\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 9,\n columnNumber: 9\n }, this), /*#__PURE__*/_jsxDEV(\"button\", {\n className: \"formSubmitButton\",\n onClick: e => removeModal(),\n children: \"Ok\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 12,\n columnNumber: 9\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 7,\n columnNumber: 7\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 6,\n columnNumber: 5\n }, this);\n};\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.js"],"names":["React","MessageModal","removeModal","headerMessage","bodyMessage","e"],"mappings":";AAAA,OAAOA,KAAP,MAAkB,OAAlB;;;AAEA,MAAMC,YAAY,GAAG,CAAC;AAAEC,EAAAA,WAAF;AAAeC,EAAAA,aAAf;AAA8BC,EAAAA;AAA9B,CAAD,KAAiD;AAEpE,sBACE;AAAK,IAAA,SAAS,EAAC,eAAf;AAAA,2BACE;AAAK,MAAA,SAAS,EAAC,eAAf;AAAA,8BACE;AAAA,kBAAKD;AAAL;AAAA;AAAA;AAAA;AAAA,cADF,eAEE;AAAA,kBACGC;AADH;AAAA;AAAA;AAAA;AAAA,cAFF,eAKE;AAAQ,QAAA,SAAS,EAAC,kBAAlB;AAAqC,QAAA,OAAO,EAAEC,CAAC,IAAIH,WAAW,EAA9D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,cALF;AAAA;AAAA;AAAA;AAAA;AAAA;AADF;AAAA;AAAA;AAAA;AAAA,UADF;AAaD,CAfD;;KAAMD,Y;AAiBN,eAAeA,YAAf","sourcesContent":["import React from 'react'\r\n\r\nconst MessageModal = ({ removeModal, headerMessage, bodyMessage }) => {\r\n\r\n return (\r\n <div className=\"modal-content\">\r\n <div className=\"submitOkModal\">\r\n <h2>{headerMessage}</h2>\r\n <label>\r\n {bodyMessage}\r\n </label>\r\n <button className=\"formSubmitButton\" onClick={e => removeModal()}>\r\n Ok\r\n </button>\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\\\\components\\\\updateUserData\\\\updateUserDataModal\\\\UpdateUserDataModal.js\",\n _s = $RefreshSig$();\n\nimport React, { useState, useEffect } from 'react';\nimport \"./UpdateUserDataModal.css\";\nimport { useOktaAuth } from '@okta/okta-react';\nimport config from '../../../config';\nimport { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\n\nconst UpdateUserDataModal = ({\n removeModal\n}) => {\n _s();\n\n const {\n authState,\n oktaAuth\n } = useOktaAuth();\n const [userInfo, setUserInfo] = useState(null);\n const accessToken = oktaAuth.getAccessToken();\n\n const stopProp = e => {\n e.preventDefault();\n e.stopPropagation();\n };\n\n useEffect(() => {\n if (!authState.isAuthenticated) {\n // When user isn't authenticated, forget any user info\n setUserInfo(null);\n } else {\n oktaAuth.getUser().then(info => {\n setUserInfo(info);\n });\n }\n }, [authState, oktaAuth]); // Update if authState changes\n\n useEffect(() => {\n userInfo && setFirstname(userInfo.given_name);\n userInfo && setLastname(userInfo.family_name);\n userInfo && setUsername(userInfo.email);\n }, [userInfo]);\n const [firstname, setFirstname] = useState('');\n const [lastname, setLastname] = useState('');\n const [username, setUsername] = useState('');\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 userInputData = JSON.stringify({\n firstname: `${firstname}`,\n lastname: `${lastname}`,\n email: `${username}`\n });\n const updateUserDataRequestOptions = {\n method: 'PUT',\n headers: {\n Authorization: `Bearer ${accessToken}`\n },\n body: userInputData\n };\n\n const handleUpdateUserDataFormSubmit = e => {\n e.preventDefault();\n fetch(config.serviceAPI.updateUserDataURL, updateUserDataRequestOptions).then(res => {\n if (!res.ok) {\n window.alert(\"Error\");\n Promise.reject(\"\");\n return;\n }\n\n if (res.ok) {\n removeModal();\n }\n });\n };\n\n return /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"modal-content\",\n children: /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"updateUserDataModal\",\n children: [/*#__PURE__*/_jsxDEV(\"h2\", {\n children: \"Update information\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 90,\n columnNumber: 9\n }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n userDataSubmitForm: true,\n children: /*#__PURE__*/_jsxDEV(\"form\", {\n children: [/*#__PURE__*/_jsxDEV(\"label\", {\n children: [\"First name:\", /*#__PURE__*/_jsxDEV(\"input\", {\n id: \"firstname\",\n type: \"text\",\n value: firstname,\n onChange: handlefirstnameChange\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 95,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 93,\n columnNumber: 13\n }, this), /*#__PURE__*/_jsxDEV(\"label\", {\n children: [\"Last Name:\", /*#__PURE__*/_jsxDEV(\"input\", {\n id: \"lastname\",\n type: \"text\",\n value: lastname,\n onChange: handlelastnameChange\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 102,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 100,\n columnNumber: 13\n }, this), /*#__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: 109,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 107,\n columnNumber: 13\n }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"buttonContainer\",\n children: [/*#__PURE__*/_jsxDEV(\"button\", {\n className: \"noButton\",\n onClick: stopProp,\n children: \"Cancel\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 115,\n columnNumber: 15\n }, this), /*#__PURE__*/_jsxDEV(\"button\", {\n className: \"yesButton\",\n onClick: handleUpdateUserDataFormSubmit,\n children: \"Update\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 118,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 114,\n columnNumber: 13\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 92,\n columnNumber: 11\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 91,\n columnNumber: 9\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 89,\n columnNumber: 7\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 88,\n columnNumber: 5\n }, this);\n};\n\n_s(UpdateUserDataModal, \"AxzdzHC979Yq9E6/6HJDjeCl4CA=\", false, function () {\n return [useOktaAuth];\n});\n\n_c = UpdateUserDataModal;\nexport default UpdateUserDataModal;\n\nvar _c;\n\n$RefreshReg$(_c, \"UpdateUserDataModal\");","map":{"version":3,"sources":["C:/Users/Bruger/Desktop/Web-projects/pipit/client/src/components/updateUserData/updateUserDataModal/UpdateUserDataModal.js"],"names":["React","useState","useEffect","useOktaAuth","config","UpdateUserDataModal","removeModal","authState","oktaAuth","userInfo","setUserInfo","accessToken","getAccessToken","stopProp","e","preventDefault","stopPropagation","isAuthenticated","getUser","then","info","setFirstname","given_name","setLastname","family_name","setUsername","email","firstname","lastname","username","handlefirstnameChange","target","value","handlelastnameChange","handleUsernameChange","userInputData","JSON","stringify","updateUserDataRequestOptions","method","headers","Authorization","body","handleUpdateUserDataFormSubmit","fetch","serviceAPI","updateUserDataURL","res","ok","window","alert","Promise","reject"],"mappings":";;;AAAA,OAAOA,KAAP,IAAgBC,QAAhB,EAA0BC,SAA1B,QAA2C,OAA3C;AACA,OAAO,2BAAP;AACA,SAASC,WAAT,QAA4B,kBAA5B;AACA,OAAOC,MAAP,MAAmB,iBAAnB;;;AAEA,MAAMC,mBAAmB,GAAG,CAAC;AAAEC,EAAAA;AAAF,CAAD,KAAqB;AAAA;;AAC/C,QAAM;AAAEC,IAAAA,SAAF;AAAaC,IAAAA;AAAb,MAA0BL,WAAW,EAA3C;AACA,QAAM,CAACM,QAAD,EAAWC,WAAX,IAA0BT,QAAQ,CAAC,IAAD,CAAxC;AACA,QAAMU,WAAW,GAAGH,QAAQ,CAACI,cAAT,EAApB;;AAEA,QAAMC,QAAQ,GAAGC,CAAC,IAAI;AACpBA,IAAAA,CAAC,CAACC,cAAF;AACAD,IAAAA,CAAC,CAACE,eAAF;AACD,GAHD;;AAKAd,EAAAA,SAAS,CAAC,MAAM;AACd,QAAI,CAACK,SAAS,CAACU,eAAf,EAAgC;AAC9B;AACAP,MAAAA,WAAW,CAAC,IAAD,CAAX;AACD,KAHD,MAGO;AACLF,MAAAA,QAAQ,CAACU,OAAT,GAAmBC,IAAnB,CAAwBC,IAAI,IAAI;AAC9BV,QAAAA,WAAW,CAACU,IAAD,CAAX;AACD,OAFD;AAGD;AACF,GATQ,EASN,CAACb,SAAD,EAAYC,QAAZ,CATM,CAAT,CAV+C,CAmBpB;;AAE3BN,EAAAA,SAAS,CAAC,MAAM;AACdO,IAAAA,QAAQ,IACNY,YAAY,CAACZ,QAAQ,CAACa,UAAV,CADd;AAIAb,IAAAA,QAAQ,IACNc,WAAW,CAACd,QAAQ,CAACe,WAAV,CADb;AAIAf,IAAAA,QAAQ,IACNgB,WAAW,CAAChB,QAAQ,CAACiB,KAAV,CADb;AAGD,GAZQ,EAYN,CAACjB,QA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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAJF;AAAA;AAAA;AAAA;AAAA;AAAA,kBAtBF;AAAA;AAAA;AAAA;AAAA;AAAA;AADF;AAAA;AAAA;AAAA;AAAA,cAFF;AAAA;AAAA;AAAA;AAAA;AAAA;AADF;AAAA;AAAA;AAAA;AAAA,UADF;AAwCD,CAzHD;;GAAMtC,mB;UAC4BF,W;;;KAD5BE,mB;AA2HN,eAAeA,mBAAf","sourcesContent":["import React, { useState, useEffect } from 'react'\r\nimport \"./UpdateUserDataModal.css\"\r\nimport { useOktaAuth } from '@okta/okta-react';\r\nimport config from '../../../config';\r\n\r\nconst UpdateUserDataModal = ({ removeModal }) => {\r\n const { authState, oktaAuth } = useOktaAuth();\r\n const [userInfo, setUserInfo] = useState(null);\r\n const accessToken = oktaAuth.getAccessToken();\r\n\r\n const stopProp = e => {\r\n e.preventDefault()\r\n e.stopPropagation()\r\n }\r\n\r\n useEffect(() => {\r\n if (!authState.isAuthenticated) {\r\n // When user isn't authenticated, forget any user info\r\n setUserInfo(null);\r\n } else {\r\n oktaAuth.getUser().then(info => {\r\n setUserInfo(info);\r\n });\r\n }\r\n }, [authState, oktaAuth]); // Update if authState changes\r\n\r\n useEffect(() => {\r\n userInfo && (\r\n setFirstname(userInfo.given_name)\r\n )\r\n\r\n userInfo && (\r\n setLastname(userInfo.family_name)\r\n )\r\n\r\n userInfo && (\r\n setUsername(userInfo.email)\r\n )\r\n }, [userInfo])\r\n\r\n const [firstname, setFirstname] = useState('')\r\n const [lastname, setLastname] = useState('')\r\n const [username, setUsername] = useState('');\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 userInputData = JSON.stringify({\r\n firstname: `${firstname}`,\r\n lastname: `${lastname}`,\r\n email: `${username}`\r\n })\r\n\r\n const updateUserDataRequestOptions = {\r\n method: 'PUT',\r\n headers: {\r\n Authorization: `Bearer ${accessToken}`,\r\n },\r\n body: userInputData\r\n };\r\n\r\n const handleUpdateUserDataFormSubmit = (e) => {\r\n e.preventDefault();\r\n\r\n fetch(config.serviceAPI.updateUserDataURL, updateUserDataRequestOptions)\r\n .then((res) => {\r\n if (!res.ok) {\r\n window.alert(\"Error\")\r\n Promise.reject(\"\")\r\n return\r\n }\r\n if (res.ok) {\r\n removeModal()\r\n }\r\n })\r\n }\r\n\r\n return (\r\n <div className=\"modal-content\">\r\n <div className=\"updateUserDataModal\">\r\n <h2>Update information</h2>\r\n <div userDataSubmitForm>\r\n <form>\r\n <label>\r\n First name:\r\n <input\r\n id=\"firstname\" type=\"text\"\r\n value={firstname}\r\n onChange={handlefirstnameChange} />\r\n </label>\r\n <label>\r\n Last Name:\r\n <input\r\n id=\"lastname\" type=\"text\"\r\n value={lastname}\r\n onChange={handlelastnameChange} />\r\n </label>\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 <div className=\"buttonContainer\">\r\n <button className=\"noButton\" onClick={stopProp}>\r\n Cancel\r\n </button>\r\n <button className=\"yesButton\" onClick={handleUpdateUserDataFormSubmit}>\r\n Update\r\n </button>\r\n </div>\r\n </form>\r\n </div>\r\n </div>\r\n </div>\r\n )\r\n}\r\n\r\nexport default UpdateUserDataModal\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\\\\updateUserData\\\\updateUserDataModal\\\\UpdateUserDataModal.js\",\n _s = $RefreshSig$();\n\nimport React, { useState, useEffect } from 'react';\nimport \"./UpdateUserDataModal.css\";\nimport { useOktaAuth } from '@okta/okta-react';\nimport config from '../../../config';\nimport { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\n\nconst UpdateUserDataModal = ({\n removeModal\n}) => {\n _s();\n\n const {\n authState,\n oktaAuth\n } = useOktaAuth();\n const [userInfo, setUserInfo] = useState(null);\n const accessToken = oktaAuth.getAccessToken();\n\n const stopProp = e => {\n // e.stopPropagation()\n e.preventDefault();\n };\n\n useEffect(() => {\n if (!authState.isAuthenticated) {\n // When user isn't authenticated, forget any user info\n setUserInfo(null);\n } else {\n oktaAuth.getUser().then(info => {\n setUserInfo(info);\n });\n }\n }, [authState, oktaAuth]); // Update if authState changes\n\n useEffect(() => {\n userInfo && setFirstname(userInfo.given_name);\n userInfo && setLastname(userInfo.family_name);\n userInfo && setUsername(userInfo.email);\n }, [userInfo]);\n const [firstname, setFirstname] = useState('');\n const [lastname, setLastname] = useState('');\n const [username, setUsername] = useState('');\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 userInputData = JSON.stringify({\n firstname: `${firstname}`,\n lastname: `${lastname}`,\n email: `${username}`\n });\n const updateUserDataRequestOptions = {\n method: 'PUT',\n headers: {\n Authorization: `Bearer ${accessToken}`\n },\n body: userInputData\n };\n\n const handleUpdateUserDataFormSubmit = e => {\n e.preventDefault();\n fetch(config.serviceAPI.updateUserDataURL, updateUserDataRequestOptions).then(res => {\n if (!res.ok) {\n window.alert(\"Error\");\n Promise.reject(\"\");\n return;\n }\n\n if (res.ok) {\n removeModal();\n }\n });\n };\n\n return /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"modal-content\",\n children: /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"updateUserDataModal\",\n children: [/*#__PURE__*/_jsxDEV(\"h2\", {\n children: \"Update information\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 90,\n columnNumber: 9\n }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n userDataSubmitForm: true,\n children: /*#__PURE__*/_jsxDEV(\"form\", {\n children: [/*#__PURE__*/_jsxDEV(\"label\", {\n children: [\"First name:\", /*#__PURE__*/_jsxDEV(\"input\", {\n id: \"firstname\",\n type: \"text\",\n value: firstname,\n onChange: handlefirstnameChange\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 95,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 93,\n columnNumber: 13\n }, this), /*#__PURE__*/_jsxDEV(\"label\", {\n children: [\"Last Name:\", /*#__PURE__*/_jsxDEV(\"input\", {\n id: \"lastname\",\n type: \"text\",\n value: lastname,\n onChange: handlelastnameChange\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 102,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 100,\n columnNumber: 13\n }, this), /*#__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: 109,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 107,\n columnNumber: 13\n }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"buttonContainer\",\n children: [/*#__PURE__*/_jsxDEV(\"button\", {\n className: \"noButton\",\n onClick: e => removeModal(),\n children: \"Cancel\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 115,\n columnNumber: 15\n }, this), /*#__PURE__*/_jsxDEV(\"button\", {\n className: \"yesButton\",\n onClick: handleUpdateUserDataFormSubmit,\n children: \"Update\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 118,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 114,\n columnNumber: 13\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 92,\n columnNumber: 11\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 91,\n columnNumber: 9\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 89,\n columnNumber: 7\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 88,\n columnNumber: 5\n }, this);\n};\n\n_s(UpdateUserDataModal, \"AxzdzHC979Yq9E6/6HJDjeCl4CA=\", false, function () {\n return [useOktaAuth];\n});\n\n_c = UpdateUserDataModal;\nexport default UpdateUserDataModal;\n\nvar _c;\n\n$RefreshReg$(_c, \"UpdateUserDataModal\");","map":{"version":3,"sources":["C:/Users/Bruger/Desktop/Web-projects/pipit/client/src/components/updateUserData/updateUserDataModal/UpdateUserDataModal.js"],"names":["React","useState","useEffect","useOktaAuth","config","UpdateUserDataModal","removeModal","authState","oktaAuth","userInfo","setUserInfo","accessToken","getAccessToken","stopProp","e","preventDefault","isAuthenticated","getUser","then","info","setFirstname","given_name","setLastname","family_name","setUsername","email","firstname","lastname","username","handlefirstnameChange","target","value","handlelastnameChange","handleUsernameChange","userInputData","JSON","stringify","updateUserDataRequestOptions","method","headers","Authorization","body","handleUpdateUserDataFormSubmit","fetch","serviceAPI","updateUserDataURL","res","ok","window","alert","Promise","reject"],"mappings":";;;AAAA,OAAOA,KAAP,IAAgBC,QAAhB,EAA0BC,SAA1B,QAA2C,OAA3C;AACA,OAAO,2BAAP;AACA,SAASC,WAAT,QAA4B,kBAA5B;AACA,OAAOC,MAAP,MAAmB,iBAAnB;;;AAEA,MAAMC,mBAAmB,GAAG,CAAC;AAAEC,EAAAA;AAAF,CAAD,KAAqB;AAAA;;AAC/C,QAAM;AAAEC,IAAAA,SAAF;AAAaC,IAAAA;AAAb,MAA0BL,WAAW,EAA3C;AACA,QAAM,CAACM,QAAD,EAAWC,WAAX,IAA0BT,QAAQ,CAAC,IAAD,CAAxC;AACA,QAAMU,WAAW,GAAGH,QAAQ,CAACI,cAAT,EAApB;;AAEA,QAAMC,QAAQ,GAAGC,CAA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AAA,kDAEE;AACE,cAAA,EAAE,EAAC,UADL;AACgB,cAAA,IAAI,EAAC,MADrB;AAEE,cAAA,KAAK,EAAEF,QAFT;AAGE,cAAA,QAAQ,EAAEK;AAHZ;AAAA;AAAA;AAAA;AAAA,oBAFF;AAAA;AAAA;AAAA;AAAA;AAAA,kBARF,eAeE;AAAA,8CAEE;AACE,cAAA,EAAE,EAAC,OADL;AACa,cAAA,IAAI,EAAC,MADlB;AAEE,cAAA,KAAK,EAAEJ,QAFT;AAGE,cAAA,QAAQ,EAAEK;AAHZ;AAAA;AAAA;AAAA;AAAA,oBAFF;AAAA;AAAA;AAAA;AAAA;AAAA,kBAfF,eAsBE;AAAK,YAAA,SAAS,EAAC,iBAAf;AAAA,oCACE;AAAQ,cAAA,SAAS,EAAC,UAAlB;AAA6B,cAAA,OAAO,EAAEnB,CAAC,IAAIR,WAAW,EAAtD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBADF,eAIE;AAAQ,cAAA,SAAS,EAAC,WAAlB;AAA8B,cAAA,OAAO,EAAEoC,8BAAvC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAJF;AAAA;AAAA;AAAA;AAAA;AAAA,kBAtBF;AAAA;AAAA;AAAA;AAAA;AAAA;AADF;AAAA;AAAA;AAAA;AAAA,cAFF;AAAA;AAAA;AAAA;AAAA;AAAA;AADF;AAAA;AAAA;AAAA;AAAA,UADF;AAwCD,CAzHD;;GAAMrC,mB;UAC4BF,W;;;KAD5BE,mB;AA2HN,eAAeA,mBAAf","sourcesContent":["import React, { useState, useEffect } from 'react'\r\nimport \"./UpdateUserDataModal.css\"\r\nimport { useOktaAuth } from '@okta/okta-react';\r\nimport config from '../../../config';\r\n\r\nconst UpdateUserDataModal = ({ removeModal }) => {\r\n const { authState, oktaAuth } = useOktaAuth();\r\n const [userInfo, setUserInfo] = useState(null);\r\n const accessToken = oktaAuth.getAccessToken();\r\n\r\n const stopProp = e => {\r\n // e.stopPropagation()\r\n e.preventDefault()\r\n }\r\n\r\n useEffect(() => {\r\n if (!authState.isAuthenticated) {\r\n // When user isn't authenticated, forget any user info\r\n setUserInfo(null);\r\n } else {\r\n oktaAuth.getUser().then(info => {\r\n setUserInfo(info);\r\n });\r\n }\r\n }, [authState, oktaAuth]); // Update if authState changes\r\n\r\n useEffect(() => {\r\n userInfo && (\r\n setFirstname(userInfo.given_name)\r\n )\r\n\r\n userInfo && (\r\n setLastname(userInfo.family_name)\r\n )\r\n\r\n userInfo && (\r\n setUsername(userInfo.email)\r\n )\r\n }, [userInfo])\r\n\r\n const [firstname, setFirstname] = useState('')\r\n const [lastname, setLastname] = useState('')\r\n const [username, setUsername] = useState('');\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 userInputData = JSON.stringify({\r\n firstname: `${firstname}`,\r\n lastname: `${lastname}`,\r\n email: `${username}`\r\n })\r\n\r\n const updateUserDataRequestOptions = {\r\n method: 'PUT',\r\n headers: {\r\n Authorization: `Bearer ${accessToken}`,\r\n },\r\n body: userInputData\r\n };\r\n\r\n const handleUpdateUserDataFormSubmit = (e) => {\r\n e.preventDefault();\r\n\r\n fetch(config.serviceAPI.updateUserDataURL, updateUserDataRequestOptions)\r\n .then((res) => {\r\n if (!res.ok) {\r\n window.alert(\"Error\")\r\n Promise.reject(\"\")\r\n return\r\n }\r\n if (res.ok) {\r\n removeModal()\r\n }\r\n })\r\n }\r\n\r\n return (\r\n <div className=\"modal-content\">\r\n <div className=\"updateUserDataModal\">\r\n <h2>Update information</h2>\r\n <div userDataSubmitForm>\r\n <form>\r\n <label>\r\n First name:\r\n <input\r\n id=\"firstname\" type=\"text\"\r\n value={firstname}\r\n onChange={handlefirstnameChange} />\r\n </label>\r\n <label>\r\n Last Name:\r\n <input\r\n id=\"lastname\" type=\"text\"\r\n value={lastname}\r\n onChange={handlelastnameChange} />\r\n </label>\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 <div className=\"buttonContainer\">\r\n <button className=\"noButton\" onClick={e => removeModal()}>\r\n Cancel\r\n </button>\r\n <button className=\"yesButton\" onClick={handleUpdateUserDataFormSubmit}>\r\n Update\r\n </button>\r\n </div>\r\n </form>\r\n </div>\r\n </div>\r\n </div>\r\n )\r\n}\r\n\r\nexport default UpdateUserDataModal\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\\\\updateUserData\\\\updateUserDataModal\\\\UpdateUserDataModal.js\",\n _s = $RefreshSig$();\n\nimport React, { useState, useEffect } from 'react';\nimport \"./UpdateUserDataModal.css\";\nimport { useOktaAuth } from '@okta/okta-react';\nimport config from '../../../config';\nimport { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\n\nconst UpdateUserDataModal = ({\n removeModal\n}) => {\n _s();\n\n const {\n authState,\n oktaAuth\n } = useOktaAuth();\n const [userInfo, setUserInfo] = useState(null);\n const accessToken = oktaAuth.getAccessToken();\n\n const stopProp = e => {\n e.preventDefault();\n e.stopPropagation();\n };\n\n useEffect(() => {\n if (!authState.isAuthenticated) {\n // When user isn't authenticated, forget any user info\n setUserInfo(null);\n } else {\n oktaAuth.getUser().then(info => {\n setUserInfo(info);\n });\n }\n }, [authState, oktaAuth]); // Update if authState changes\n\n useEffect(() => {\n userInfo && setFirstname(userInfo.given_name);\n userInfo && setLastname(userInfo.family_name);\n userInfo && setUsername(userInfo.email);\n }, [userInfo]);\n const [firstname, setFirstname] = useState('');\n const [lastname, setLastname] = useState('');\n const [username, setUsername] = useState('');\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 userInputData = JSON.stringify({\n firstname: `${firstname}`,\n lastname: `${lastname}`,\n email: `${username}`\n });\n const updateUserDataRequestOptions = {\n method: 'PUT',\n headers: {\n Authorization: `Bearer ${accessToken}`\n },\n body: userInputData\n };\n\n const handleUpdateUserDataFormSubmit = e => {\n e.preventDefault();\n fetch(config.serviceAPI.updateUserDataURL, updateUserDataRequestOptions).then(res => {\n if (!res.ok) {\n window.alert(\"Error\");\n Promise.reject(\"\");\n return;\n }\n\n if (res.ok) {\n removeModal();\n }\n });\n };\n\n return /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"modal-content\",\n children: /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"updateUserDataModal\",\n children: [/*#__PURE__*/_jsxDEV(\"h2\", {\n children: \"Update information\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 90,\n columnNumber: 9\n }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n userDataSubmitForm: true,\n children: /*#__PURE__*/_jsxDEV(\"form\", {\n children: [/*#__PURE__*/_jsxDEV(\"label\", {\n children: [\"First name:\", /*#__PURE__*/_jsxDEV(\"input\", {\n id: \"firstname\",\n type: \"text\",\n value: firstname,\n onChange: handlefirstnameChange\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 95,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 93,\n columnNumber: 13\n }, this), /*#__PURE__*/_jsxDEV(\"label\", {\n children: [\"Last Name:\", /*#__PURE__*/_jsxDEV(\"input\", {\n id: \"lastname\",\n type: \"text\",\n value: lastname,\n onChange: handlelastnameChange\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 102,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 100,\n columnNumber: 13\n }, this), /*#__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: 109,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 107,\n columnNumber: 13\n }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"buttonContainer\",\n children: [/*#__PURE__*/_jsxDEV(\"button\", {\n className: \"noButton\",\n onClick: e => removeModal(),\n children: \"Cancel\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 115,\n columnNumber: 15\n }, this), /*#__PURE__*/_jsxDEV(\"button\", {\n className: \"yesButton\",\n onClick: handleUpdateUserDataFormSubmit,\n children: \"Update\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 118,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 114,\n columnNumber: 13\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 92,\n columnNumber: 11\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 91,\n columnNumber: 9\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 89,\n columnNumber: 7\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 88,\n columnNumber: 5\n }, this);\n};\n\n_s(UpdateUserDataModal, \"AxzdzHC979Yq9E6/6HJDjeCl4CA=\", false, function () {\n return [useOktaAuth];\n});\n\n_c = UpdateUserDataModal;\nexport default UpdateUserDataModal;\n\nvar _c;\n\n$RefreshReg$(_c, \"UpdateUserDataModal\");","map":{"version":3,"sources":["C:/Users/Bruger/Desktop/Web-projects/pipit/client/src/components/updateUserData/updateUserDataModal/UpdateUserDataModal.js"],"names":["React","useState","useEffect","useOktaAuth","config","UpdateUserDataModal","removeModal","authState","oktaAuth","userInfo","setUserInfo","accessToken","getAccessToken","stopProp","e","preventDefault","stopPropagation","isAuthenticated","getUser","then","info","setFirstname","given_name","setLastname","family_name","setUsername","email","firstname","lastname","username","handlefirstnameChange","target","value","handlelastnameChange","handleUsernameChange","userInputData","JSON","stringify","updateUserDataRequestOptions","method","headers","Authorization","body","handleUpdateUserDataFormSubmit","fetch","serviceAPI","updateUserDataURL","res","ok","window","alert","Promise","reject"],"mappings":";;;AAAA,OAAOA,KAAP,IAAgBC,QAAhB,EAA0BC,SAA1B,QAA2C,OAA3C;AACA,OAAO,2BAAP;AACA,SAASC,WAAT,QAA4B,kBAA5B;AACA,OAAOC,MAAP,MAAmB,iBAAnB;;;AAEA,MAAMC,mBAAmB,GAAG,CAAC;AAAEC,EAAAA;AAAF,CAAD,KAAqB;AAAA;;AAC/C,QAAM;AAAEC,IAAAA,SAAF;AAAaC,IAAAA;AAAb,MAA0BL,WAAW,EAA3C;AACA,QAAM,CAACM,QAAD,EAAWC,WAAX,IAA0BT,QAAQ,CAAC,IAAD,CAAxC;AACA,QAAMU,WAAW,GAAGH,QAAQ,CAACI,cAAT,EAApB;;AAEA,QAAMC,QAAQ,GAAGC,CAAC,IAAI;AACpBA,IAAAA,CAAC,CAACC,cAAF;AACAD,IAAAA,CAAC,CAACE,eAAF;AACD,GAHD;;AAKAd,EAAAA,SAAS,CAAC,MAAM;AACd,QAAI,CAACK,SAAS,CAACU,eAAf,EAAgC;AAC9B;AACAP,MAAAA,WAAW,CAAC,IAAD,CAAX;AACD,KAHD,MAGO;AACLF,MAAAA,QAAQ,CAACU,OAAT,GAAmBC,IAAnB,CAAwBC,IAAI,IAAI;AAC9BV,QAAAA,WAAW,CAACU,IAAD,CAAX;AACD,OAFD;AAGD;AACF,GATQ,EASN,CAACb,SAAD,EAAYC,QAAZ,CATM,CAAT,CAV+C,CAmBpB;;AAE3BN,EAAAA,SAAS,CAAC,MAAM;AACdO,IAAAA,QAAQ,IACNY,YAAY,CAACZ,QAAQ,CAACa,UAAV,CADd;AAIAb,IAAAA,QAAQ,IACNc,WAAW,CAACd,QA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C,IAAIR,WAAW,EAAtD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBADF,eAIE;AAAQ,cAAA,SAAS,EAAC,WAAlB;AAA8B,cAAA,OAAO,EAAEqC,8BAAvC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAJF;AAAA;AAAA;AAAA;AAAA;AAAA,kBAtBF;AAAA;AAAA;AAAA;AAAA;AAAA;AADF;AAAA;AAAA;AAAA;AAAA,cAFF;AAAA;AAAA;AAAA;AAAA;AAAA;AADF;AAAA;AAAA;AAAA;AAAA,UADF;AAwCD,CAzHD;;GAAMtC,mB;UAC4BF,W;;;KAD5BE,mB;AA2HN,eAAeA,mBAAf","sourcesContent":["import React, { useState, useEffect } from 'react'\r\nimport \"./UpdateUserDataModal.css\"\r\nimport { useOktaAuth } from '@okta/okta-react';\r\nimport config from '../../../config';\r\n\r\nconst UpdateUserDataModal = ({ removeModal }) => {\r\n const { authState, oktaAuth } = useOktaAuth();\r\n const [userInfo, setUserInfo] = useState(null);\r\n const accessToken = oktaAuth.getAccessToken();\r\n\r\n const stopProp = e => {\r\n e.preventDefault()\r\n e.stopPropagation()\r\n }\r\n\r\n useEffect(() => {\r\n if (!authState.isAuthenticated) {\r\n // When user isn't authenticated, forget any user info\r\n setUserInfo(null);\r\n } else {\r\n oktaAuth.getUser().then(info => {\r\n setUserInfo(info);\r\n });\r\n }\r\n }, [authState, oktaAuth]); // Update if authState changes\r\n\r\n useEffect(() => {\r\n userInfo && (\r\n setFirstname(userInfo.given_name)\r\n )\r\n\r\n userInfo && (\r\n setLastname(userInfo.family_name)\r\n )\r\n\r\n userInfo && (\r\n setUsername(userInfo.email)\r\n )\r\n }, [userInfo])\r\n\r\n const [firstname, setFirstname] = useState('')\r\n const [lastname, setLastname] = useState('')\r\n const [username, setUsername] = useState('');\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 userInputData = JSON.stringify({\r\n firstname: `${firstname}`,\r\n lastname: `${lastname}`,\r\n email: `${username}`\r\n })\r\n\r\n const updateUserDataRequestOptions = {\r\n method: 'PUT',\r\n headers: {\r\n Authorization: `Bearer ${accessToken}`,\r\n },\r\n body: userInputData\r\n };\r\n\r\n const handleUpdateUserDataFormSubmit = (e) => {\r\n e.preventDefault();\r\n\r\n fetch(config.serviceAPI.updateUserDataURL, updateUserDataRequestOptions)\r\n .then((res) => {\r\n if (!res.ok) {\r\n window.alert(\"Error\")\r\n Promise.reject(\"\")\r\n return\r\n }\r\n if (res.ok) {\r\n removeModal()\r\n }\r\n })\r\n }\r\n\r\n return (\r\n <div className=\"modal-content\">\r\n <div className=\"updateUserDataModal\">\r\n <h2>Update information</h2>\r\n <div userDataSubmitForm>\r\n <form>\r\n <label>\r\n First name:\r\n <input\r\n id=\"firstname\" type=\"text\"\r\n value={firstname}\r\n onChange={handlefirstnameChange} />\r\n </label>\r\n <label>\r\n Last Name:\r\n <input\r\n id=\"lastname\" type=\"text\"\r\n value={lastname}\r\n onChange={handlelastnameChange} />\r\n </label>\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 <div className=\"buttonContainer\">\r\n <button className=\"noButton\" onClick={e => removeModal()}>\r\n Cancel\r\n </button>\r\n <button className=\"yesButton\" onClick={handleUpdateUserDataFormSubmit}>\r\n Update\r\n </button>\r\n </div>\r\n </form>\r\n </div>\r\n </div>\r\n </div>\r\n )\r\n}\r\n\r\nexport default UpdateUserDataModal\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\\\\navbar\\\\Navbar.js\",\n _s = $RefreshSig$();\n\nimport React from 'react';\nimport { useOktaAuth } from '@okta/okta-react';\nimport \"./Navbar.css\";\nimport Logo from './logo/Logo';\nimport NavLinks from './navLinks/NavLinks';\nimport Searchbar from './searchbar/Searchbar';\nimport NavbarDropdownMenu from './dropdownMenu/NavbarDropdownMenu';\nimport { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\n\nconst Navbar = () => {\n _s();\n\n const {\n authState\n } = useOktaAuth();\n\n if (!authState || !authState.isAuthenticated) {\n return null;\n }\n\n return /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"navbar\",\n children: /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"header-content\",\n children: [/*#__PURE__*/_jsxDEV(\"div\", {\n className: \"title-navigation-links-container\",\n children: [/*#__PURE__*/_jsxDEV(Logo, {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 20,\n columnNumber: 11\n }, this), /*#__PURE__*/_jsxDEV(NavLinks, {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 21,\n columnNumber: 11\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 19,\n columnNumber: 9\n }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"searchbar-profile-container\",\n children: /*#__PURE__*/_jsxDEV(\"ul\", {\n className: \"right-unstyled-navbar\",\n children: [/*#__PURE__*/_jsxDEV(Searchbar, {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 25,\n columnNumber: 13\n }, this), /*#__PURE__*/_jsxDEV(NavbarDropdownMenu, {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 26,\n columnNumber: 13\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 24,\n columnNumber: 11\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 23,\n columnNumber: 9\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 18,\n columnNumber: 7\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 17,\n columnNumber: 5\n }, this);\n};\n\n_s(Navbar, \"oAW1RknmsiQ8MLimpuaVoCQZavU=\", false, function () {\n return [useOktaAuth];\n});\n\n_c = Navbar;\nexport default Navbar;\n\nvar _c;\n\n$RefreshReg$(_c, \"Navbar\");","map":{"version":3,"sources":["C:/Users/Bruger/Desktop/Web-projects/pipit/client/src/components/navbar/Navbar.js"],"names":["React","useOktaAuth","Logo","NavLinks","Searchbar","NavbarDropdownMenu","Navbar","authState","isAuthenticated"],"mappings":";;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,WAAT,QAA4B,kBAA5B;AACA,OAAO,cAAP;AACA,OAAOC,IAAP,MAAiB,aAAjB;AACA,OAAOC,QAAP,MAAqB,qBAArB;AACA,OAAOC,SAAP,MAAsB,uBAAtB;AACA,OAAOC,kBAAP,MAA+B,mCAA/B;;;AAEA,MAAMC,MAAM,GAAG,MAAM;AAAA;;AACnB,QAAM;AAAEC,IAAAA;AAAF,MAAgBN,WAAW,EAAjC;;AAEA,MAAI,CAACM,SAAD,IAAc,CAACA,SAAS,CAACC,eAA7B,EAA8C;AAC5C,WAAO,IAAP;AACD;;AAED,sBACE;AAAK,IAAA,SAAS,EAAC,QAAf;AAAA,2BACE;AAAK,MAAA,SAAS,EAAC,gBAAf;AAAA,8BACE;AAAK,QAAA,SAAS,EAAC,kCAAf;AAAA,gCACE,QAAC,IAAD;AAAA;AAAA;AAAA;AAAA,gBADF,eAEE,QAAC,QAAD;AAAA;AAAA;AAAA;AAAA,gBAFF;AAAA;AAAA;AAAA;AAAA;AAAA,cADF,eAKE;AAAK,QAAA,SAAS,EAAC,6BAAf;AAAA,+BACE;AAAI,UAAA,SAAS,EAAC,uBAAd;AAAA,kCACE,QAAC,SAAD;AAAA;AAAA;AAAA;AAAA,kBADF,eAEE,QAAC,kBAAD;AAAA;AAAA;AAAA;AAAA,kBAFF;AAAA;AAAA;AAAA;AAAA;AAAA;AADF;AAAA;AAAA;AAAA;AAAA,cALF;AAAA;AAAA;AAAA;AAAA;AAAA;AADF;AAAA;AAAA;AAAA;AAAA,UADF;AAgBD,CAvBD;;GAAMF,M;UACkBL,W;;;KADlBK,M;AAyBN,eAAeA,MAAf","sourcesContent":["import React from 'react'\r\nimport { useOktaAuth } from '@okta/okta-react';\r\nimport \"./Navbar.css\"\r\nimport Logo from './logo/Logo'\r\nimport NavLinks from './navLinks/NavLinks'\r\nimport Searchbar from './searchbar/Searchbar'\r\nimport NavbarDropdownMenu from './dropdownMenu/NavbarDropdownMenu'\r\n\r\nconst Navbar = () => {\r\n const { authState } = useOktaAuth();\r\n\r\n if (!authState || !authState.isAuthenticated) {\r\n return null;\r\n }\r\n\r\n return (\r\n <div className=\"navbar\" >\r\n <div className=\"header-content\">\r\n <div className=\"title-navigation-links-container\">\r\n <Logo />\r\n <NavLinks />\r\n </div>\r\n <div className=\"searchbar-profile-container\">\r\n <ul className=\"right-unstyled-navbar\">\r\n <Searchbar />\r\n <NavbarDropdownMenu />\r\n </ul>\r\n </div>\r\n </div>\r\n </div >\r\n )\r\n}\r\n\r\nexport default Navbar"]},"metadata":{},"sourceType":"module"}
\ No newline at end of file
{"ast":null,"code":"var _jsxFileName = \"C:\\\\Users\\\\Bruger\\\\Desktop\\\\Web-projects\\\\pipit\\\\client\\\\src\\\\components\\\\updateUserData\\\\updateUserDataModal\\\\UpdateUserDataModal.js\",\n _s = $RefreshSig$();\n\nimport React, { useState, useEffect } from 'react';\nimport \"./UpdateUserDataModal.css\";\nimport { useOktaAuth } from '@okta/okta-react';\nimport config from '../../../config';\nimport { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\n\nconst UpdateUserDataModal = ({\n removeModal\n}) => {\n _s();\n\n const {\n authState,\n oktaAuth\n } = useOktaAuth();\n const [userInfo, setUserInfo] = useState(null);\n const accessToken = oktaAuth.getAccessToken();\n useEffect(() => {\n if (!authState.isAuthenticated) {\n // When user isn't authenticated, forget any user info\n setUserInfo(null);\n } else {\n oktaAuth.getUser().then(info => {\n setUserInfo(info);\n });\n }\n }, [authState, oktaAuth]); // Update if authState changes\n\n useEffect(() => {\n userInfo && setFirstname(userInfo.given_name);\n userInfo && setLastname(userInfo.family_name);\n userInfo && setUsername(userInfo.email);\n }, [userInfo]);\n const [firstname, setFirstname] = useState('');\n const [lastname, setLastname] = useState('');\n const [username, setUsername] = useState('');\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 userInputData = JSON.stringify({\n firstname: `${firstname}`,\n lastname: `${lastname}`,\n email: `${username}`\n });\n const updateUserDataRequestOptions = {\n method: 'PUT',\n headers: {\n Authorization: `Bearer ${accessToken}`\n },\n body: userInputData\n };\n\n const handleUpdateUserDataFormSubmit = e => {\n e.preventDefault();\n fetch(config.serviceAPI.updateUserDataURL, updateUserDataRequestOptions).then(res => {\n if (!res.ok) {\n window.alert(\"Error\");\n Promise.reject(\"\");\n return;\n }\n\n if (res.ok) {\n removeModal();\n }\n });\n };\n\n return /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"modal-content\",\n children: /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"updateUserDataModal\",\n children: [/*#__PURE__*/_jsxDEV(\"h2\", {\n children: \"Update information\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 85,\n columnNumber: 9\n }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n userDataSubmitForm: true,\n children: /*#__PURE__*/_jsxDEV(\"form\", {\n children: [/*#__PURE__*/_jsxDEV(\"label\", {\n children: [\"First name:\", /*#__PURE__*/_jsxDEV(\"input\", {\n id: \"firstname\",\n type: \"text\",\n value: firstname,\n onChange: handlefirstnameChange\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 90,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 88,\n columnNumber: 13\n }, this), /*#__PURE__*/_jsxDEV(\"label\", {\n children: [\"Last Name:\", /*#__PURE__*/_jsxDEV(\"input\", {\n id: \"lastname\",\n type: \"text\",\n value: lastname,\n onChange: handlelastnameChange\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 97,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 95,\n columnNumber: 13\n }, this), /*#__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: 104,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 102,\n columnNumber: 13\n }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"buttonContainer\",\n children: [/*#__PURE__*/_jsxDEV(\"button\", {\n className: \"noButton\",\n onClick: e => removeModal(),\n children: \"Cancel\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 110,\n columnNumber: 15\n }, this), /*#__PURE__*/_jsxDEV(\"button\", {\n className: \"yesButton\",\n onClick: handleUpdateUserDataFormSubmit,\n children: \"Update\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 113,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 109,\n columnNumber: 13\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 87,\n columnNumber: 11\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 86,\n columnNumber: 9\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 84,\n columnNumber: 7\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 83,\n columnNumber: 5\n }, this);\n};\n\n_s(UpdateUserDataModal, \"AxzdzHC979Yq9E6/6HJDjeCl4CA=\", false, function () {\n return [useOktaAuth];\n});\n\n_c = UpdateUserDataModal;\nexport default UpdateUserDataModal;\n\nvar _c;\n\n$RefreshReg$(_c, \"UpdateUserDataModal\");","map":{"version":3,"sources":["C:/Users/Bruger/Desktop/Web-projects/pipit/client/src/components/updateUserData/updateUserDataModal/UpdateUserDataModal.js"],"names":["React","useState","useEffect","useOktaAuth","config","UpdateUserDataModal","removeModal","authState","oktaAuth","userInfo","setUserInfo","accessToken","getAccessToken","isAuthenticated","getUser","then","info","setFirstname","given_name","setLastname","family_name","setUsername","email","firstname","lastname","username","handlefirstnameChange","e","target","value","handlelastnameChange","handleUsernameChange","userInputData","JSON","stringify","updateUserDataRequestOptions","method","headers","Authorization","body","handleUpdateUserDataFormSubmit","preventDefault","fetch","serviceAPI","updateUserDataURL","res","ok","window","alert","Promise","reject"],"mappings":";;;AAAA,OAAOA,KAAP,IAAgBC,QAAhB,EAA0BC,SAA1B,QAA2C,OAA3C;AACA,OAAO,2BAAP;AACA,SAASC,WAAT,QAA4B,kBAA5B;AACA,OAAOC,MAAP,MAAmB,iBAAnB;;;AAEA,MAAMC,mBAAmB,GAAG,CAAC;AAAEC,EAAAA;AAAF,CAAD,KAAqB;AAAA;;AAC/C,QAAM;AAAEC,IAAAA,SAAF;AAAaC,IAAAA;AAAb,MAA0BL,WAAW,EAA3C;AACA,QAAM,CAACM,QAAD,EAAWC,WAAX,IAA0BT,QAAQ,CAAC,IAAD,CAAxC;AACA,QAAMU,WAAW,GAAGH,QAAQ,CAACI,cAAT,EAApB;AAEAV,EAAAA,SAAS,CAAC,MAAM;AACd,QAAI,CAACK,SAAS,CAACM,eAAf,EAAgC;AAC9B;AACAH,MAAAA,WAAW,CAAC,IAAD,CAAX;AACD,KAHD,MAGO;AACLF,MAAAA,QAAQ,CAACM,OAAT,GAAmBC,IAAnB,CAAwBC,IAAI,IAAI;AAC9BN,QAAAA,WAAW,CAACM,IAAD,CAAX;AACD,OAFD;AAGD;AACF,GATQ,EASN,CAACT,SAAD,EAAYC,QAAZ,CATM,CAAT,CAL+C,CAc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A;AAAA,kBAfF,eAsBE;AAAK,YAAA,SAAS,EAAC,iBAAf;AAAA,oCACE;AAAQ,cAAA,SAAS,EAAC,UAAlB;AAA6B,cAAA,OAAO,EAAEJ,CAAC,IAAIrB,WAAW,EAAtD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBADF,eAIE;AAAQ,cAAA,SAAS,EAAC,WAAlB;AAA8B,cAAA,OAAO,EAAEkC,8BAAvC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAJF;AAAA;AAAA;AAAA;AAAA;AAAA,kBAtBF;AAAA;AAAA;AAAA;AAAA;AAAA;AADF;AAAA;AAAA;AAAA;AAAA,cAFF;AAAA;AAAA;AAAA;AAAA;AAAA;AADF;AAAA;AAAA;AAAA;AAAA,UADF;AAwCD,CApHD;;GAAMnC,mB;UAC4BF,W;;;KAD5BE,mB;AAsHN,eAAeA,mBAAf","sourcesContent":["import React, { useState, useEffect } from 'react'\r\nimport \"./UpdateUserDataModal.css\"\r\nimport { useOktaAuth } from '@okta/okta-react';\r\nimport config from '../../../config';\r\n\r\nconst UpdateUserDataModal = ({ removeModal }) => {\r\n const { authState, oktaAuth } = useOktaAuth();\r\n const [userInfo, setUserInfo] = useState(null);\r\n const accessToken = oktaAuth.getAccessToken();\r\n\r\n useEffect(() => {\r\n if (!authState.isAuthenticated) {\r\n // When user isn't authenticated, forget any user info\r\n setUserInfo(null);\r\n } else {\r\n oktaAuth.getUser().then(info => {\r\n setUserInfo(info);\r\n });\r\n }\r\n }, [authState, oktaAuth]); // Update if authState changes\r\n\r\n useEffect(() => {\r\n userInfo && (\r\n setFirstname(userInfo.given_name)\r\n )\r\n\r\n userInfo && (\r\n setLastname(userInfo.family_name)\r\n )\r\n\r\n userInfo && (\r\n setUsername(userInfo.email)\r\n )\r\n }, [userInfo])\r\n\r\n const [firstname, setFirstname] = useState('')\r\n const [lastname, setLastname] = useState('')\r\n const [username, setUsername] = useState('');\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 userInputData = JSON.stringify({\r\n firstname: `${firstname}`,\r\n lastname: `${lastname}`,\r\n email: `${username}`\r\n })\r\n\r\n const updateUserDataRequestOptions = {\r\n method: 'PUT',\r\n headers: {\r\n Authorization: `Bearer ${accessToken}`,\r\n },\r\n body: userInputData\r\n };\r\n\r\n const handleUpdateUserDataFormSubmit = (e) => {\r\n e.preventDefault();\r\n\r\n fetch(config.serviceAPI.updateUserDataURL, updateUserDataRequestOptions)\r\n .then((res) => {\r\n if (!res.ok) {\r\n window.alert(\"Error\")\r\n Promise.reject(\"\")\r\n return\r\n }\r\n if (res.ok) {\r\n removeModal()\r\n }\r\n })\r\n }\r\n\r\n return (\r\n <div className=\"modal-content\">\r\n <div className=\"updateUserDataModal\">\r\n <h2>Update information</h2>\r\n <div userDataSubmitForm>\r\n <form>\r\n <label>\r\n First name:\r\n <input\r\n id=\"firstname\" type=\"text\"\r\n value={firstname}\r\n onChange={handlefirstnameChange} />\r\n </label>\r\n <label>\r\n Last Name:\r\n <input\r\n id=\"lastname\" type=\"text\"\r\n value={lastname}\r\n onChange={handlelastnameChange} />\r\n </label>\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 <div className=\"buttonContainer\">\r\n <button className=\"noButton\" onClick={e => removeModal()}>\r\n Cancel\r\n </button>\r\n <button className=\"yesButton\" onClick={handleUpdateUserDataFormSubmit}>\r\n Update\r\n </button>\r\n </div>\r\n </form>\r\n </div>\r\n </div>\r\n </div>\r\n )\r\n}\r\n\r\nexport default UpdateUserDataModal\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\\\\updateUserData\\\\updateUserDataModal\\\\UpdateUserDataModal.js\",\n _s = $RefreshSig$();\n\nimport React, { useState, useEffect } from 'react';\nimport \"./UpdateUserDataModal.css\";\nimport { useOktaAuth } from '@okta/okta-react';\nimport config from '../../../config';\nimport { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\n\nconst UpdateUserDataModal = ({\n removeModal\n}) => {\n _s();\n\n const {\n authState,\n oktaAuth\n } = useOktaAuth();\n const [userInfo, setUserInfo] = useState(null);\n const accessToken = oktaAuth.getAccessToken();\n\n const stopProp = e => {\n e.preventDefault();\n e.stopPropagation();\n };\n\n useEffect(() => {\n if (!authState.isAuthenticated) {\n // When user isn't authenticated, forget any user info\n setUserInfo(null);\n } else {\n oktaAuth.getUser().then(info => {\n setUserInfo(info);\n });\n }\n }, [authState, oktaAuth]); // Update if authState changes\n\n useEffect(() => {\n userInfo && setFirstname(userInfo.given_name);\n userInfo && setLastname(userInfo.family_name);\n userInfo && setUsername(userInfo.email);\n }, [userInfo]);\n const [firstname, setFirstname] = useState('');\n const [lastname, setLastname] = useState('');\n const [username, setUsername] = useState('');\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 userInputData = JSON.stringify({\n firstname: `${firstname}`,\n lastname: `${lastname}`,\n email: `${username}`\n });\n const updateUserDataRequestOptions = {\n method: 'PUT',\n headers: {\n Authorization: `Bearer ${accessToken}`\n },\n body: userInputData\n };\n\n const handleUpdateUserDataFormSubmit = e => {\n e.preventDefault();\n fetch(config.serviceAPI.updateUserDataURL, updateUserDataRequestOptions).then(res => {\n if (!res.ok) {\n window.alert(\"Error\");\n Promise.reject(\"\");\n return;\n }\n\n if (res.ok) {\n removeModal();\n }\n });\n };\n\n return /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"modal-content\",\n children: /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"updateUserDataModal\",\n children: [/*#__PURE__*/_jsxDEV(\"h2\", {\n children: \"Update information\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 90,\n columnNumber: 9\n }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n userDataSubmitForm: true,\n children: /*#__PURE__*/_jsxDEV(\"form\", {\n children: [/*#__PURE__*/_jsxDEV(\"label\", {\n children: [\"First name:\", /*#__PURE__*/_jsxDEV(\"input\", {\n id: \"firstname\",\n type: \"text\",\n value: firstname,\n onChange: handlefirstnameChange\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 95,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 93,\n columnNumber: 13\n }, this), /*#__PURE__*/_jsxDEV(\"label\", {\n children: [\"Last Name:\", /*#__PURE__*/_jsxDEV(\"input\", {\n id: \"lastname\",\n type: \"text\",\n value: lastname,\n onChange: handlelastnameChange\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 102,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 100,\n columnNumber: 13\n }, this), /*#__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: 109,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 107,\n columnNumber: 13\n }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"buttonContainer\",\n children: [/*#__PURE__*/_jsxDEV(\"button\", {\n className: \"noButton\",\n onClick: e => stopProp,\n children: \"Cancel\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 115,\n columnNumber: 15\n }, this), /*#__PURE__*/_jsxDEV(\"button\", {\n className: \"yesButton\",\n onClick: handleUpdateUserDataFormSubmit,\n children: \"Update\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 118,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 114,\n columnNumber: 13\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 92,\n columnNumber: 11\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 91,\n columnNumber: 9\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 89,\n columnNumber: 7\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 88,\n columnNumber: 5\n }, this);\n};\n\n_s(UpdateUserDataModal, \"AxzdzHC979Yq9E6/6HJDjeCl4CA=\", false, function () {\n return [useOktaAuth];\n});\n\n_c = UpdateUserDataModal;\nexport default UpdateUserDataModal;\n\nvar _c;\n\n$RefreshReg$(_c, \"UpdateUserDataModal\");","map":{"version":3,"sources":["C:/Users/Bruger/Desktop/Web-projects/pipit/client/src/components/updateUserData/updateUserDataModal/UpdateUserDataModal.js"],"names":["React","useState","useEffect","useOktaAuth","config","UpdateUserDataModal","removeModal","authState","oktaAuth","userInfo","setUserInfo","accessToken","getAccessToken","stopProp","e","preventDefault","stopPropagation","isAuthenticated","getUser","then","info","setFirstname","given_name","setLastname","family_name","setUsername","email","firstname","lastname","username","handlefirstnameChange","target","value","handlelastnameChange","handleUsernameChange","userInputData","JSON","stringify","updateUserDataRequestOptions","method","headers","Authorization","body","handleUpdateUserDataFormSubmit","fetch","serviceAPI","updateUserDataURL","res","ok","window","alert","Promise","reject"],"mappings":";;;AAAA,OAAOA,KAAP,IAAgBC,QAAhB,EAA0BC,SAA1B,QAA2C,OAA3C;AACA,OAAO,2BAAP;AACA,SAASC,WAAT,QAA4B,kBAA5B;AACA,OAAOC,MAAP,MAAmB,iBAAnB;;;AAEA,MAAMC,mBAAmB,GAAG,CAAC;AAAEC,EAAAA;AAAF,CAAD,KAAqB;AAAA;;AAC/C,Q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"./UpdateUserDataModal.css\"\r\nimport { useOktaAuth } from '@okta/okta-react';\r\nimport config from '../../../config';\r\n\r\nconst UpdateUserDataModal = ({ removeModal }) => {\r\n const { authState, oktaAuth } = useOktaAuth();\r\n const [userInfo, setUserInfo] = useState(null);\r\n const accessToken = oktaAuth.getAccessToken();\r\n\r\n const stopProp = e => {\r\n e.preventDefault()\r\n e.stopPropagation()\r\n }\r\n\r\n useEffect(() => {\r\n if (!authState.isAuthenticated) {\r\n // When user isn't authenticated, forget any user info\r\n setUserInfo(null);\r\n } else {\r\n oktaAuth.getUser().then(info => {\r\n setUserInfo(info);\r\n });\r\n }\r\n }, [authState, oktaAuth]); // Update if authState changes\r\n\r\n useEffect(() => {\r\n userInfo && (\r\n setFirstname(userInfo.given_name)\r\n )\r\n\r\n userInfo && (\r\n setLastname(userInfo.family_name)\r\n )\r\n\r\n userInfo && (\r\n setUsername(userInfo.email)\r\n )\r\n }, [userInfo])\r\n\r\n const [firstname, setFirstname] = useState('')\r\n const [lastname, setLastname] = useState('')\r\n const [username, setUsername] = useState('');\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 userInputData = JSON.stringify({\r\n firstname: `${firstname}`,\r\n lastname: `${lastname}`,\r\n email: `${username}`\r\n })\r\n\r\n const updateUserDataRequestOptions = {\r\n method: 'PUT',\r\n headers: {\r\n Authorization: `Bearer ${accessToken}`,\r\n },\r\n body: userInputData\r\n };\r\n\r\n const handleUpdateUserDataFormSubmit = (e) => {\r\n e.preventDefault();\r\n\r\n fetch(config.serviceAPI.updateUserDataURL, updateUserDataRequestOptions)\r\n .then((res) => {\r\n if (!res.ok) {\r\n window.alert(\"Error\")\r\n Promise.reject(\"\")\r\n return\r\n }\r\n if (res.ok) {\r\n removeModal()\r\n }\r\n })\r\n }\r\n\r\n return (\r\n <div className=\"modal-content\">\r\n <div className=\"updateUserDataModal\">\r\n <h2>Update information</h2>\r\n <div userDataSubmitForm>\r\n <form>\r\n <label>\r\n First name:\r\n <input\r\n id=\"firstname\" type=\"text\"\r\n value={firstname}\r\n onChange={handlefirstnameChange} />\r\n </label>\r\n <label>\r\n Last Name:\r\n <input\r\n id=\"lastname\" type=\"text\"\r\n value={lastname}\r\n onChange={handlelastnameChange} />\r\n </label>\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 <div className=\"buttonContainer\">\r\n <button className=\"noButton\" onClick={e => stopProp}>\r\n Cancel\r\n </button>\r\n <button className=\"yesButton\" onClick={handleUpdateUserDataFormSubmit}>\r\n Update\r\n </button>\r\n </div>\r\n </form>\r\n </div>\r\n </div>\r\n </div>\r\n )\r\n}\r\n\r\nexport default UpdateUserDataModal\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\\\\updateUserData\\\\updateUserDataModal\\\\UpdateUserDataModal.js\",\n _s = $RefreshSig$();\n\nimport React, { useState, useEffect } from 'react';\nimport \"./UpdateUserDataModal.css\";\nimport { useOktaAuth } from '@okta/okta-react';\nimport config from '../../../config';\nimport { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\n\nconst UpdateUserDataModal = ({\n removeModal\n}) => {\n _s();\n\n const {\n authState,\n oktaAuth\n } = useOktaAuth();\n const [userInfo, setUserInfo] = useState(null);\n const accessToken = oktaAuth.getAccessToken();\n\n const stopProp = e => {\n e.stopPropagation();\n };\n\n useEffect(() => {\n if (!authState.isAuthenticated) {\n // When user isn't authenticated, forget any user info\n setUserInfo(null);\n } else {\n oktaAuth.getUser().then(info => {\n setUserInfo(info);\n });\n }\n }, [authState, oktaAuth]); // Update if authState changes\n\n useEffect(() => {\n userInfo && setFirstname(userInfo.given_name);\n userInfo && setLastname(userInfo.family_name);\n userInfo && setUsername(userInfo.email);\n }, [userInfo]);\n const [firstname, setFirstname] = useState('');\n const [lastname, setLastname] = useState('');\n const [username, setUsername] = useState('');\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 userInputData = JSON.stringify({\n firstname: `${firstname}`,\n lastname: `${lastname}`,\n email: `${username}`\n });\n const updateUserDataRequestOptions = {\n method: 'PUT',\n headers: {\n Authorization: `Bearer ${accessToken}`\n },\n body: userInputData\n };\n\n const handleUpdateUserDataFormSubmit = e => {\n e.preventDefault();\n fetch(config.serviceAPI.updateUserDataURL, updateUserDataRequestOptions).then(res => {\n if (!res.ok) {\n window.alert(\"Error\");\n Promise.reject(\"\");\n return;\n }\n\n if (res.ok) {\n removeModal();\n }\n });\n };\n\n return /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"modal-content\",\n children: /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"updateUserDataModal\",\n children: [/*#__PURE__*/_jsxDEV(\"h2\", {\n children: \"Update information\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 89,\n columnNumber: 9\n }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n userDataSubmitForm: true,\n children: /*#__PURE__*/_jsxDEV(\"form\", {\n children: [/*#__PURE__*/_jsxDEV(\"label\", {\n children: [\"First name:\", /*#__PURE__*/_jsxDEV(\"input\", {\n id: \"firstname\",\n type: \"text\",\n value: firstname,\n onChange: handlefirstnameChange\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 94,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 92,\n columnNumber: 13\n }, this), /*#__PURE__*/_jsxDEV(\"label\", {\n children: [\"Last Name:\", /*#__PURE__*/_jsxDEV(\"input\", {\n id: \"lastname\",\n type: \"text\",\n value: lastname,\n onChange: handlelastnameChange\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 101,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 99,\n columnNumber: 13\n }, this), /*#__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: 108,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 106,\n columnNumber: 13\n }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"buttonContainer\",\n children: [/*#__PURE__*/_jsxDEV(\"button\", {\n className: \"noButton\",\n onClick: e => removeModal(),\n children: \"Cancel\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 114,\n columnNumber: 15\n }, this), /*#__PURE__*/_jsxDEV(\"button\", {\n className: \"yesButton\",\n onClick: handleUpdateUserDataFormSubmit,\n children: \"Update\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 117,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 113,\n columnNumber: 13\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 91,\n columnNumber: 11\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 90,\n columnNumber: 9\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 88,\n columnNumber: 7\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 87,\n columnNumber: 5\n }, this);\n};\n\n_s(UpdateUserDataModal, \"AxzdzHC979Yq9E6/6HJDjeCl4CA=\", false, function () {\n return [useOktaAuth];\n});\n\n_c = UpdateUserDataModal;\nexport default UpdateUserDataModal;\n\nvar _c;\n\n$RefreshReg$(_c, \"UpdateUserDataModal\");","map":{"version":3,"sources":["C:/Users/Bruger/Desktop/Web-projects/pipit/client/src/components/updateUserData/updateUserDataModal/UpdateUserDataModal.js"],"names":["React","useState","useEffect","useOktaAuth","config","UpdateUserDataModal","removeModal","authState","oktaAuth","userInfo","setUserInfo","accessToken","getAccessToken","stopProp","e","stopPropagation","isAuthenticated","getUser","then","info","setFirstname","given_name","setLastname","family_name","setUsername","email","firstname","lastname","username","handlefirstnameChange","target","value","handlelastnameChange","handleUsernameChange","userInputData","JSON","stringify","updateUserDataRequestOptions","method","headers","Authorization","body","handleUpdateUserDataFormSubmit","preventDefault","fetch","serviceAPI","updateUserDataURL","res","ok","window","alert","Promise","reject"],"mappings":";;;AAAA,OAAOA,KAAP,IAAgBC,QAAhB,EAA0BC,SAA1B,QAA2C,OAA3C;AACA,OAAO,2BAAP;AACA,SAASC,WAAT,QAA4B,kBAA5B;AACA,OAAOC,MAAP,MAAmB,iBAAnB;;;AAEA,MAAMC,mBAAmB,GAAG,CAAC;AAAEC,EAAAA;AAAF,CAAD,KAAqB;AAAA;;AAC/C,QAAM;AAAEC,IAAAA,SAAF;AAAaC,IAAAA;AAAb,MAA0BL,WAAW,EAA3C;AACA,QAAM,CAACM,QAAD,EAAWC,WAAX,IAA0BT,QAAQ,CAAC,IAAD,CAAxC;AACA,QAAMU,WAAW,GAAGH,QAAQ,CAACI,cAAT,EAApB;;AAEA,QAAMC,QAAQ,GAAGC,CAAC,IAAI;AACpBA,IAAAA,CAAC,CAACC,eAAF;AACD,GAFD;;AAIAb,EAAAA,SAAS,CAAC,MAAM;AACd,QAAI,CAACK,SAAS,CAACS,eAAf,EAAgC;AAC9B;AACAN,MAAAA,WAAW,CAAC,IAAD,CAAX;AACD,KAHD,MAGO;AACLF,MAAAA,QAAQ,CAACS,OAAT,GAAmBC,IAAnB,CAAwBC,IAAI,IAAI;AAC9BT,QAAAA,WAAW,CAACS,IAAD,CAAX;AACD,OAFD;AAGD;AACF,GATQ,EAS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AAEK;AAHZ;AAAA;AAAA;AAAA;AAAA,oBAFF;AAAA;AAAA;AAAA;AAAA;AAAA,kBAfF,eAsBE;AAAK,YAAA,SAAS,EAAC,iBAAf;AAAA,oCACE;AAAQ,cAAA,SAAS,EAAC,UAAlB;AAA6B,cAAA,OAAO,EAAEnB,CAAC,IAAIR,WAAW,EAAtD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBADF,eAIE;AAAQ,cAAA,SAAS,EAAC,WAAlB;AAA8B,cAAA,OAAO,EAAEoC,8BAAvC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAJF;AAAA;AAAA;AAAA;AAAA;AAAA,kBAtBF;AAAA;AAAA;AAAA;AAAA;AAAA;AADF;AAAA;AAAA;AAAA;AAAA,cAFF;AAAA;AAAA;AAAA;AAAA;AAAA;AADF;AAAA;AAAA;AAAA;AAAA,UADF;AAwCD,CAxHD;;GAAMrC,mB;UAC4BF,W;;;KAD5BE,mB;AA0HN,eAAeA,mBAAf","sourcesContent":["import React, { useState, useEffect } from 'react'\r\nimport \"./UpdateUserDataModal.css\"\r\nimport { useOktaAuth } from '@okta/okta-react';\r\nimport config from '../../../config';\r\n\r\nconst UpdateUserDataModal = ({ removeModal }) => {\r\n const { authState, oktaAuth } = useOktaAuth();\r\n const [userInfo, setUserInfo] = useState(null);\r\n const accessToken = oktaAuth.getAccessToken();\r\n\r\n const stopProp = e => {\r\n e.stopPropagation()\r\n }\r\n\r\n useEffect(() => {\r\n if (!authState.isAuthenticated) {\r\n // When user isn't authenticated, forget any user info\r\n setUserInfo(null);\r\n } else {\r\n oktaAuth.getUser().then(info => {\r\n setUserInfo(info);\r\n });\r\n }\r\n }, [authState, oktaAuth]); // Update if authState changes\r\n\r\n useEffect(() => {\r\n userInfo && (\r\n setFirstname(userInfo.given_name)\r\n )\r\n\r\n userInfo && (\r\n setLastname(userInfo.family_name)\r\n )\r\n\r\n userInfo && (\r\n setUsername(userInfo.email)\r\n )\r\n }, [userInfo])\r\n\r\n const [firstname, setFirstname] = useState('')\r\n const [lastname, setLastname] = useState('')\r\n const [username, setUsername] = useState('');\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 userInputData = JSON.stringify({\r\n firstname: `${firstname}`,\r\n lastname: `${lastname}`,\r\n email: `${username}`\r\n })\r\n\r\n const updateUserDataRequestOptions = {\r\n method: 'PUT',\r\n headers: {\r\n Authorization: `Bearer ${accessToken}`,\r\n },\r\n body: userInputData\r\n };\r\n\r\n const handleUpdateUserDataFormSubmit = (e) => {\r\n e.preventDefault();\r\n\r\n fetch(config.serviceAPI.updateUserDataURL, updateUserDataRequestOptions)\r\n .then((res) => {\r\n if (!res.ok) {\r\n window.alert(\"Error\")\r\n Promise.reject(\"\")\r\n return\r\n }\r\n if (res.ok) {\r\n removeModal()\r\n }\r\n })\r\n }\r\n\r\n return (\r\n <div className=\"modal-content\">\r\n <div className=\"updateUserDataModal\">\r\n <h2>Update information</h2>\r\n <div userDataSubmitForm>\r\n <form>\r\n <label>\r\n First name:\r\n <input\r\n id=\"firstname\" type=\"text\"\r\n value={firstname}\r\n onChange={handlefirstnameChange} />\r\n </label>\r\n <label>\r\n Last Name:\r\n <input\r\n id=\"lastname\" type=\"text\"\r\n value={lastname}\r\n onChange={handlelastnameChange} />\r\n </label>\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 <div className=\"buttonContainer\">\r\n <button className=\"noButton\" onClick={e => removeModal()}>\r\n Cancel\r\n </button>\r\n <button className=\"yesButton\" onClick={handleUpdateUserDataFormSubmit}>\r\n Update\r\n </button>\r\n </div>\r\n </form>\r\n </div>\r\n </div>\r\n </div>\r\n )\r\n}\r\n\r\nexport default UpdateUserDataModal\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\\\\updateUserData\\\\updateUserDataModal\\\\UpdateUserDataModal.js\",\n _s = $RefreshSig$();\n\nimport React, { useState, useEffect } from 'react';\nimport \"./UpdateUserDataModal.css\";\nimport { useOktaAuth } from '@okta/okta-react';\nimport config from '../../../config';\nimport { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\n\nconst UpdateUserDataModal = ({\n removeModal\n}) => {\n _s();\n\n const {\n authState,\n oktaAuth\n } = useOktaAuth();\n const [userInfo, setUserInfo] = useState(null);\n const accessToken = oktaAuth.getAccessToken();\n\n const stopProp = e => {\n e.preventDefault(); // e.stopPropagation()\n };\n\n useEffect(() => {\n if (!authState.isAuthenticated) {\n // When user isn't authenticated, forget any user info\n setUserInfo(null);\n } else {\n oktaAuth.getUser().then(info => {\n setUserInfo(info);\n });\n }\n }, [authState, oktaAuth]); // Update if authState changes\n\n useEffect(() => {\n userInfo && setFirstname(userInfo.given_name);\n userInfo && setLastname(userInfo.family_name);\n userInfo && setUsername(userInfo.email);\n }, [userInfo]);\n const [firstname, setFirstname] = useState('');\n const [lastname, setLastname] = useState('');\n const [username, setUsername] = useState('');\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 userInputData = JSON.stringify({\n firstname: `${firstname}`,\n lastname: `${lastname}`,\n email: `${username}`\n });\n const updateUserDataRequestOptions = {\n method: 'PUT',\n headers: {\n Authorization: `Bearer ${accessToken}`\n },\n body: userInputData\n };\n\n const handleUpdateUserDataFormSubmit = e => {\n e.preventDefault();\n fetch(config.serviceAPI.updateUserDataURL, updateUserDataRequestOptions).then(res => {\n if (!res.ok) {\n window.alert(\"Error\");\n Promise.reject(\"\");\n return;\n }\n\n if (res.ok) {\n removeModal();\n }\n });\n };\n\n return /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"modal-content\",\n children: /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"updateUserDataModal\",\n children: [/*#__PURE__*/_jsxDEV(\"h2\", {\n children: \"Update information\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 90,\n columnNumber: 9\n }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n userDataSubmitForm: true,\n children: /*#__PURE__*/_jsxDEV(\"form\", {\n children: [/*#__PURE__*/_jsxDEV(\"label\", {\n children: [\"First name:\", /*#__PURE__*/_jsxDEV(\"input\", {\n id: \"firstname\",\n type: \"text\",\n value: firstname,\n onChange: handlefirstnameChange\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 95,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 93,\n columnNumber: 13\n }, this), /*#__PURE__*/_jsxDEV(\"label\", {\n children: [\"Last Name:\", /*#__PURE__*/_jsxDEV(\"input\", {\n id: \"lastname\",\n type: \"text\",\n value: lastname,\n onChange: handlelastnameChange\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 102,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 100,\n columnNumber: 13\n }, this), /*#__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: 109,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 107,\n columnNumber: 13\n }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"buttonContainer\",\n children: [/*#__PURE__*/_jsxDEV(\"button\", {\n className: \"noButton\",\n onClick: e => stopProp,\n children: \"Cancel\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 115,\n columnNumber: 15\n }, this), /*#__PURE__*/_jsxDEV(\"button\", {\n className: \"yesButton\",\n onClick: handleUpdateUserDataFormSubmit,\n children: \"Update\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 118,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 114,\n columnNumber: 13\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 92,\n columnNumber: 11\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 91,\n columnNumber: 9\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 89,\n columnNumber: 7\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 88,\n columnNumber: 5\n }, this);\n};\n\n_s(UpdateUserDataModal, \"AxzdzHC979Yq9E6/6HJDjeCl4CA=\", false, function () {\n return [useOktaAuth];\n});\n\n_c = UpdateUserDataModal;\nexport default UpdateUserDataModal;\n\nvar _c;\n\n$RefreshReg$(_c, \"UpdateUserDataModal\");","map":{"version":3,"sources":["C:/Users/Bruger/Desktop/Web-projects/pipit/client/src/components/updateUserData/updateUserDataModal/UpdateUserDataModal.js"],"names":["React","useState","useEffect","useOktaAuth","config","UpdateUserDataModal","removeModal","authState","oktaAuth","userInfo","setUserInfo","accessToken","getAccessToken","stopProp","e","preventDefault","isAuthenticated","getUser","then","info","setFirstname","given_name","setLastname","family_name","setUsername","email","firstname","lastname","username","handlefirstnameChange","target","value","handlelastnameChange","handleUsernameChange","userInputData","JSON","stringify","updateUserDataRequestOptions","method","headers","Authorization","body","handleUpdateUserDataFormSubmit","fetch","serviceAPI","updateUserDataURL","res","ok","window","alert","Promise","reject"],"mappings":";;;AAAA,OAAOA,KAAP,IAAgBC,QAAhB,EAA0BC,SAA1B,QAA2C,OAA3C;AACA,OAAO,2BAAP;AACA,SAASC,WAAT,QAA4B,kBAA5B;AACA,OAAOC,MAAP,M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BF,W;;;KAD5BE,mB;AA2HN,eAAeA,mBAAf","sourcesContent":["import React, { useState, useEffect } from 'react'\r\nimport \"./UpdateUserDataModal.css\"\r\nimport { useOktaAuth } from '@okta/okta-react';\r\nimport config from '../../../config';\r\n\r\nconst UpdateUserDataModal = ({ removeModal }) => {\r\n const { authState, oktaAuth } = useOktaAuth();\r\n const [userInfo, setUserInfo] = useState(null);\r\n const accessToken = oktaAuth.getAccessToken();\r\n\r\n const stopProp = e => {\r\n e.preventDefault()\r\n // e.stopPropagation()\r\n }\r\n\r\n useEffect(() => {\r\n if (!authState.isAuthenticated) {\r\n // When user isn't authenticated, forget any user info\r\n setUserInfo(null);\r\n } else {\r\n oktaAuth.getUser().then(info => {\r\n setUserInfo(info);\r\n });\r\n }\r\n }, [authState, oktaAuth]); // Update if authState changes\r\n\r\n useEffect(() => {\r\n userInfo && (\r\n setFirstname(userInfo.given_name)\r\n )\r\n\r\n userInfo && (\r\n setLastname(userInfo.family_name)\r\n )\r\n\r\n userInfo && (\r\n setUsername(userInfo.email)\r\n )\r\n }, [userInfo])\r\n\r\n const [firstname, setFirstname] = useState('')\r\n const [lastname, setLastname] = useState('')\r\n const [username, setUsername] = useState('');\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 userInputData = JSON.stringify({\r\n firstname: `${firstname}`,\r\n lastname: `${lastname}`,\r\n email: `${username}`\r\n })\r\n\r\n const updateUserDataRequestOptions = {\r\n method: 'PUT',\r\n headers: {\r\n Authorization: `Bearer ${accessToken}`,\r\n },\r\n body: userInputData\r\n };\r\n\r\n const handleUpdateUserDataFormSubmit = (e) => {\r\n e.preventDefault();\r\n\r\n fetch(config.serviceAPI.updateUserDataURL, updateUserDataRequestOptions)\r\n .then((res) => {\r\n if (!res.ok) {\r\n window.alert(\"Error\")\r\n Promise.reject(\"\")\r\n return\r\n }\r\n if (res.ok) {\r\n removeModal()\r\n }\r\n })\r\n }\r\n\r\n return (\r\n <div className=\"modal-content\">\r\n <div className=\"updateUserDataModal\">\r\n <h2>Update information</h2>\r\n <div userDataSubmitForm>\r\n <form>\r\n <label>\r\n First name:\r\n <input\r\n id=\"firstname\" type=\"text\"\r\n value={firstname}\r\n onChange={handlefirstnameChange} />\r\n </label>\r\n <label>\r\n Last Name:\r\n <input\r\n id=\"lastname\" type=\"text\"\r\n value={lastname}\r\n onChange={handlelastnameChange} />\r\n </label>\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 <div className=\"buttonContainer\">\r\n <button className=\"noButton\" onClick={e => stopProp}>\r\n Cancel\r\n </button>\r\n <button className=\"yesButton\" onClick={handleUpdateUserDataFormSubmit}>\r\n Update\r\n </button>\r\n </div>\r\n </form>\r\n </div>\r\n </div>\r\n </div>\r\n )\r\n}\r\n\r\nexport default UpdateUserDataModal\r\n"]},"metadata":{},"sourceType":"module"}
\ No newline at end of file
......@@ -63,7 +63,7 @@ const ChangePassword = () => {
return
}
if (!(newPassword == confirmNewPassword)) {
if (!(newPassword === confirmNewPassword)) {
window.alert("Passwords do not match")
return
}
......
import React from 'react'
const MessageModal = ({ removeModal, headerMessage, bodyMessage }) => {
const stopProp = e => {
e.stopPropagation()
}
return (
<div className="modal-content">
......
......@@ -7,7 +7,7 @@ import Searchbar from './searchbar/Searchbar'
import NavbarDropdownMenu from './dropdownMenu/NavbarDropdownMenu'
const Navbar = () => {
const { authState, oktaAuth } = useOktaAuth();
const { authState } = useOktaAuth();
if (!authState || !authState.isAuthenticated) {
return null;
......
......@@ -8,10 +8,6 @@ const UpdateUserDataModal = ({ removeModal }) => {
const [userInfo, setUserInfo] = useState(null);
const accessToken = oktaAuth.getAccessToken();
const stopProp = e => {
e.stopPropagation()
}
useEffect(() => {
if (!authState.isAuthenticated) {
// When user isn't authenticated, forget any user info
......@@ -88,7 +84,7 @@ const UpdateUserDataModal = ({ removeModal }) => {
<div className="updateUserDataModal">
<h2>Update information</h2>
<div userDataSubmitForm>
<form onSubmit={handleUpdateUserDataFormSubmit}>
<form>
<label>
First name:
<input
......@@ -114,7 +110,7 @@ const UpdateUserDataModal = ({ removeModal }) => {
<button className="noButton" onClick={e => removeModal()}>
Cancel
</button>
<button className="yesButton" type="submit">
<button className="yesButton" onClick={handleUpdateUserDataFormSubmit}>
Update
</button>
</div>
......
package main
import (
"net/http"
"log"
"github.com/gorilla/mux"
"net/http"
"github.com/gorilla/handlers"
"github.com/gorilla/mux"
oktaUtils "github.com/okta/samples-golang/resource-server/utils"
......@@ -27,8 +28,6 @@ func main() {
router.HandleFunc("/api/update-user-data", service.Authenticate(service.UpdateUserData())).Methods("PUT")
router.HandleFunc("/api/change-password", service.Authenticate(service.ChangeUserPassword())).Methods("PUT")
// Setup cors
originsOK := handlers.AllowedOrigins([]string{"http://localhost:3000"})
headersOk := handlers.AllowedHeaders([]string{"Authorization"})
......
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