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

added mux routing + set up CORS + set up request authentication middleware functionality

parent 927cd7bf
This diff is collapsed.
{"ast":null,"code":"'use strict';\n\nvar isAbsoluteURL = require('../helpers/isAbsoluteURL');\n\nvar combineURLs = require('../helpers/combineURLs');\n/**\n * Creates a new URL by combining the baseURL with the requestedURL,\n * only when the requestedURL is not already an absolute URL.\n * If the requestURL is absolute, this function returns the requestedURL untouched.\n *\n * @param {string} baseURL The base URL\n * @param {string} requestedURL Absolute or relative URL to combine\n * @returns {string} The combined full path\n */\n\n\nmodule.exports = function buildFullPath(baseURL, requestedURL) {\n if (baseURL && !isAbsoluteURL(requestedURL)) {\n return combineURLs(baseURL, requestedURL);\n }\n\n return requestedURL;\n};","map":{"version":3,"sources":["C:/Users/Bruger/Desktop/Web-projects/pipit/client/node_modules/axios/lib/core/buildFullPath.js"],"names":["isAbsoluteURL","require","combineURLs","module","exports","buildFullPath","baseURL","requestedURL"],"mappings":"AAAA;;AAEA,IAAIA,aAAa,GAAGC,OAAO,CAAC,0BAAD,CAA3B;;AACA,IAAIC,WAAW,GAAGD,OAAO,CAAC,wBAAD,CAAzB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACAE,MAAM,CAACC,OAAP,GAAiB,SAASC,aAAT,CAAuBC,OAAvB,EAAgCC,YAAhC,EAA8C;AAC7D,MAAID,OAAO,IAAI,CAACN,aAAa,CAACO,YAAD,CAA7B,EAA6C;AAC3C,WAAOL,WAAW,CAACI,OAAD,EAAUC,YAAV,CAAlB;AACD;;AACD,SAAOA,YAAP;AACD,CALD","sourcesContent":["'use strict';\n\nvar isAbsoluteURL = require('../helpers/isAbsoluteURL');\nvar combineURLs = require('../helpers/combineURLs');\n\n/**\n * Creates a new URL by combining the baseURL with the requestedURL,\n * only when the requestedURL is not already an absolute URL.\n * If the requestURL is absolute, this function returns the requestedURL untouched.\n *\n * @param {string} baseURL The base URL\n * @param {string} requestedURL Absolute or relative URL to combine\n * @returns {string} The combined full path\n */\nmodule.exports = function buildFullPath(baseURL, requestedURL) {\n if (baseURL && !isAbsoluteURL(requestedURL)) {\n return combineURLs(baseURL, requestedURL);\n }\n return requestedURL;\n};\n"]},"metadata":{},"sourceType":"script"}
\ No newline at end of file
{"ast":null,"code":"'use strict';\n\nvar utils = require('./../utils');\n\nvar buildURL = require('../helpers/buildURL');\n\nvar InterceptorManager = require('./InterceptorManager');\n\nvar dispatchRequest = require('./dispatchRequest');\n\nvar mergeConfig = require('./mergeConfig');\n/**\n * Create a new instance of Axios\n *\n * @param {Object} instanceConfig The default config for the instance\n */\n\n\nfunction Axios(instanceConfig) {\n this.defaults = instanceConfig;\n this.interceptors = {\n request: new InterceptorManager(),\n response: new InterceptorManager()\n };\n}\n/**\n * Dispatch a request\n *\n * @param {Object} config The config specific for this request (merged with this.defaults)\n */\n\n\nAxios.prototype.request = function request(config) {\n /*eslint no-param-reassign:0*/\n // Allow for axios('example/url'[, config]) a la fetch API\n if (typeof config === 'string') {\n config = arguments[1] || {};\n config.url = arguments[0];\n } else {\n config = config || {};\n }\n\n config = mergeConfig(this.defaults, config); // Set config.method\n\n if (config.method) {\n config.method = config.method.toLowerCase();\n } else if (this.defaults.method) {\n config.method = this.defaults.method.toLowerCase();\n } else {\n config.method = 'get';\n } // Hook up interceptors middleware\n\n\n var chain = [dispatchRequest, undefined];\n var promise = Promise.resolve(config);\n this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {\n chain.unshift(interceptor.fulfilled, interceptor.rejected);\n });\n this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {\n chain.push(interceptor.fulfilled, interceptor.rejected);\n });\n\n while (chain.length) {\n promise = promise.then(chain.shift(), chain.shift());\n }\n\n return promise;\n};\n\nAxios.prototype.getUri = function getUri(config) {\n config = mergeConfig(this.defaults, config);\n return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\\?/, '');\n}; // Provide aliases for supported request methods\n\n\nutils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {\n /*eslint func-names:0*/\n Axios.prototype[method] = function (url, config) {\n return this.request(mergeConfig(config || {}, {\n method: method,\n url: url,\n data: (config || {}).data\n }));\n };\n});\nutils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {\n /*eslint func-names:0*/\n Axios.prototype[method] = function (url, data, config) {\n return this.request(mergeConfig(config || {}, {\n method: method,\n url: url,\n data: data\n }));\n };\n});\nmodule.exports = Axios;","map":{"version":3,"sources":["C:/Users/Bruger/Desktop/Web-projects/pipit/client/node_modules/axios/lib/core/Axios.js"],"names":["utils","require","buildURL","InterceptorManager","dispatchRequest","mergeConfig","Axios","instanceConfig","defaults","interceptors","request","response","prototype","config","arguments","url","method","toLowerCase","chain","undefined","promise","Promise","resolve","forEach","unshiftRequestInterceptors","interceptor","unshift","fulfilled","rejected","pushResponseInterceptors","push","length","then","shift","getUri","params","paramsSerializer","replace","forEachMethodNoData","data","forEachMethodWithData","module","exports"],"mappings":"AAAA;;AAEA,IAAIA,KAAK,GAAGC,OAAO,CAAC,YAAD,CAAnB;;AACA,IAAIC,QAAQ,GAAGD,OAAO,CAAC,qBAAD,CAAtB;;AACA,IAAIE,kBAAkB,GAAGF,OAAO,CAAC,sBAAD,CAAhC;;AACA,IAAIG,eAAe,GAAGH,OAAO,CAAC,mBAAD,CAA7B;;AACA,IAAII,WAAW,GAAGJ,OAAO,CAAC,eAAD,CAAzB;AAEA;AACA;AACA;AACA;AACA;;;AACA,SAASK,KAAT,CAAeC,cAAf,EAA+B;AAC7B,OAAKC,QAAL,GAAgBD,cAAhB;AACA,OAAKE,YAAL,GAAoB;AAClBC,IAAAA,OAAO,EAAE,IAAIP,kBAAJ,EADS;AAElBQ,IAAAA,QAAQ,EAAE,IAAIR,kBAAJ;AAFQ,GAApB;AAID;AAED;AACA;AACA;AACA;AACA;;;AACAG,KAAK,CAACM,SAAN,CAAgBF,OAAhB,GAA0B,SAASA,OAAT,C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B1B,MAApB,EAA4B;AACpD,WAAO,KAAKH,OAAL,CAAaL,WAAW,CAACQ,MAAM,IAAI,EAAX,EAAe;AAC5CG,MAAAA,MAAM,EAAEA,MADoC;AAE5CD,MAAAA,GAAG,EAAEA,GAFuC;AAG5CwB,MAAAA,IAAI,EAAEA;AAHsC,KAAf,CAAxB,CAAP;AAKD,GAND;AAOD,CATD;AAWAE,MAAM,CAACC,OAAP,GAAiBpC,KAAjB","sourcesContent":["'use strict';\n\nvar utils = require('./../utils');\nvar buildURL = require('../helpers/buildURL');\nvar InterceptorManager = require('./InterceptorManager');\nvar dispatchRequest = require('./dispatchRequest');\nvar mergeConfig = require('./mergeConfig');\n\n/**\n * Create a new instance of Axios\n *\n * @param {Object} instanceConfig The default config for the instance\n */\nfunction Axios(instanceConfig) {\n this.defaults = instanceConfig;\n this.interceptors = {\n request: new InterceptorManager(),\n response: new InterceptorManager()\n };\n}\n\n/**\n * Dispatch a request\n *\n * @param {Object} config The config specific for this request (merged with this.defaults)\n */\nAxios.prototype.request = function request(config) {\n /*eslint no-param-reassign:0*/\n // Allow for axios('example/url'[, config]) a la fetch API\n if (typeof config === 'string') {\n config = arguments[1] || {};\n config.url = arguments[0];\n } else {\n config = config || {};\n }\n\n config = mergeConfig(this.defaults, config);\n\n // Set config.method\n if (config.method) {\n config.method = config.method.toLowerCase();\n } else if (this.defaults.method) {\n config.method = this.defaults.method.toLowerCase();\n } else {\n config.method = 'get';\n }\n\n // Hook up interceptors middleware\n var chain = [dispatchRequest, undefined];\n var promise = Promise.resolve(config);\n\n this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {\n chain.unshift(interceptor.fulfilled, interceptor.rejected);\n });\n\n this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {\n chain.push(interceptor.fulfilled, interceptor.rejected);\n });\n\n while (chain.length) {\n promise = promise.then(chain.shift(), chain.shift());\n }\n\n return promise;\n};\n\nAxios.prototype.getUri = function getUri(config) {\n config = mergeConfig(this.defaults, config);\n return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\\?/, '');\n};\n\n// Provide aliases for supported request methods\nutils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {\n /*eslint func-names:0*/\n Axios.prototype[method] = function(url, config) {\n return this.request(mergeConfig(config || {}, {\n method: method,\n url: url,\n data: (config || {}).data\n }));\n };\n});\n\nutils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {\n /*eslint func-names:0*/\n Axios.prototype[method] = function(url, data, config) {\n return this.request(mergeConfig(config || {}, {\n method: method,\n url: url,\n data: data\n }));\n };\n});\n\nmodule.exports = Axios;\n"]},"metadata":{},"sourceType":"script"}
\ No newline at end of file
{"ast":null,"code":"'use strict';\n\nvar utils = require('./../utils');\n\nmodule.exports = utils.isStandardBrowserEnv() ? // Standard browser envs have full support of the APIs needed to test\n// whether the request URL is of the same origin as current location.\nfunction standardBrowserEnv() {\n var msie = /(msie|trident)/i.test(navigator.userAgent);\n var urlParsingNode = document.createElement('a');\n var originURL;\n /**\n * Parse a URL to discover it's components\n *\n * @param {String} url The URL to be parsed\n * @returns {Object}\n */\n\n function resolveURL(url) {\n var href = url;\n\n if (msie) {\n // IE needs attribute set twice to normalize properties\n urlParsingNode.setAttribute('href', href);\n href = urlParsingNode.href;\n }\n\n urlParsingNode.setAttribute('href', href); // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils\n\n return {\n href: urlParsingNode.href,\n protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',\n host: urlParsingNode.host,\n search: urlParsingNode.search ? urlParsingNode.search.replace(/^\\?/, '') : '',\n hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',\n hostname: urlParsingNode.hostname,\n port: urlParsingNode.port,\n pathname: urlParsingNode.pathname.charAt(0) === '/' ? urlParsingNode.pathname : '/' + urlParsingNode.pathname\n };\n }\n\n originURL = resolveURL(window.location.href);\n /**\n * Determine if a URL shares the same origin as the current location\n *\n * @param {String} requestURL The URL to test\n * @returns {boolean} True if URL shares the same origin, otherwise false\n */\n\n return function isURLSameOrigin(requestURL) {\n var parsed = utils.isString(requestURL) ? resolveURL(requestURL) : requestURL;\n return parsed.protocol === originURL.protocol && parsed.host === originURL.host;\n };\n}() : // Non standard browser envs (web workers, react-native) lack needed support.\nfunction nonStandardBrowserEnv() {\n return function isURLSameOrigin() {\n return true;\n };\n}();","map":{"version":3,"sources":["C:/Users/Bruger/Desktop/Web-projects/pipit/client/node_modules/axios/lib/helpers/isURLSameOrigin.js"],"names":["utils","require","module","exports","isStandardBrowserEnv","standardBrowserEnv","msie","test","navigator","userAgent","urlParsingNode","document","createElement","originURL","resolveURL","url","href","setAttribute","protocol","replace","host","search","hash","hostname","port","pathname","charAt","window","location","isURLSameOrigin","requestURL","parsed","isString","nonStandardBrowserEnv"],"mappings":"AAAA;;AAEA,IAAIA,KAAK,GAAGC,OAAO,CAAC,YAAD,CAAnB;;AAEAC,MAAM,CAACC,OAAP,GACEH,KAAK,CAACI,oBAAN,KAEA;AACA;AACG,SAASC,kBAAT,GAA8B;AAC7B,MAAIC,IAAI,GAAG,kBAAkBC,IAAlB,CAAuBC,SAAS,CAACC,SAAjC,CAAX;AACA,MAAIC,cAAc,GAAGC,QAAQ,CAACC,aAAT,CAAuB,GAAvB,CAArB;AACA,MAAIC,SAAJ;AAEA;AACN;AACA;AACA;AACA;AACA;;AACM,WAASC,UAAT,CAAoBC,GAApB,EAAyB;AACvB,QAAIC,IAAI,GAAGD,GAAX;;AAEA,QAAIT,IAAJ,EAAU;AACV;AACEI,MAAAA,cAAc,CAACO,YAAf,CAA4B,MAA5B,EAAoCD,IAApC;AACAA,MAAAA,IAAI,GAAGN,cAAc,CAACM,IAAtB;AACD;;AAEDN,IAAAA,cAAc,CAACO,YAAf,CAA4B,MAA5B,EAAoCD,IAApC,EATuB,CAWvB;;AACA,WAAO;AACLA,MAAAA,IAAI,EAAEN,cAAc,CAACM,IADhB;AAELE,MAAAA,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","sourcesContent":["'use strict';\n\nvar utils = require('./../utils');\n\nmodule.exports = (\n utils.isStandardBrowserEnv() ?\n\n // Standard browser envs have full support of the APIs needed to test\n // whether the request URL is of the same origin as current location.\n (function standardBrowserEnv() {\n var msie = /(msie|trident)/i.test(navigator.userAgent);\n var urlParsingNode = document.createElement('a');\n var originURL;\n\n /**\n * Parse a URL to discover it's components\n *\n * @param {String} url The URL to be parsed\n * @returns {Object}\n */\n function resolveURL(url) {\n var href = url;\n\n if (msie) {\n // IE needs attribute set twice to normalize properties\n urlParsingNode.setAttribute('href', href);\n href = urlParsingNode.href;\n }\n\n urlParsingNode.setAttribute('href', href);\n\n // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils\n return {\n href: urlParsingNode.href,\n protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',\n host: urlParsingNode.host,\n search: urlParsingNode.search ? urlParsingNode.search.replace(/^\\?/, '') : '',\n hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',\n hostname: urlParsingNode.hostname,\n port: urlParsingNode.port,\n pathname: (urlParsingNode.pathname.charAt(0) === '/') ?\n urlParsingNode.pathname :\n '/' + urlParsingNode.pathname\n };\n }\n\n originURL = resolveURL(window.location.href);\n\n /**\n * Determine if a URL shares the same origin as the current location\n *\n * @param {String} requestURL The URL to test\n * @returns {boolean} True if URL shares the same origin, otherwise false\n */\n return function isURLSameOrigin(requestURL) {\n var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;\n return (parsed.protocol === originURL.protocol &&\n parsed.host === originURL.host);\n };\n })() :\n\n // Non standard browser envs (web workers, react-native) lack needed support.\n (function nonStandardBrowserEnv() {\n return function isURLSameOrigin() {\n return true;\n };\n })()\n);\n"]},"metadata":{},"sourceType":"script"}
\ No newline at end of file
{"ast":null,"code":"var _s = $RefreshSig$();\n\nimport { useState, useEffect } from 'react';\nimport { useOktaAuth } from '@okta/okta-react';\nimport axios from 'axios';\nimport config from \"../config\";\n\nconst useMessages = () => {\n _s();\n\n const {\n authState,\n oktaAuth\n } = useOktaAuth();\n const [messages, setMessages] = useState(null);\n const [messageFetchFailed, setMessageFetchFailed] = useState(false); // fetch messages\n\n useEffect(() => {\n if (authState && authState.isAuthenticated) {\n const accessToken = oktaAuth.getAccessToken(); // fetch(config.serviceAPI.messagesUrl, {\n // headers: {\n // Authorization: `Bearer ${accessToken}`,\n // },\n // })\n\n const instance = axios.create({\n baseURL: config.serviceAPI.messagesUrl,\n headers: {\n 'Authorization': `Bearer ${accessToken}`\n }\n });\n instance.get().then(response => {\n if (!response.ok) {\n return Promise.reject();\n }\n\n return response.json();\n }).then(data => {\n let index = 0;\n const formattedMessages = data.messages.map(message => {\n const date = new Date(message.date);\n const day = date.toLocaleDateString();\n const time = date.toLocaleTimeString();\n index += 1;\n return {\n date: `${day} ${time}`,\n sender: message.sender,\n text: message.text,\n id: `message-${index}`\n };\n });\n setMessages(formattedMessages);\n setMessageFetchFailed(false);\n }).catch(err => {\n setMessageFetchFailed(true);\n /* eslint-disable no-console */\n\n console.error(err);\n });\n }\n }, [authState]);\n return messages;\n};\n\n_s(useMessages, \"U3xiPl25FsmufxeRxpFVBz8Cguw=\", false, function () {\n return [useOktaAuth];\n});\n\nexport default useMessages;","map":{"version":3,"sources":["C:/Users/Bruger/Desktop/Web-projects/pipit/client/src/util/useMessages.jsx"],"names":["useState","useEffect","useOktaAuth","axios","config","useMessages","authState","oktaAuth","messages","setMessages","messageFetchFailed","setMessageFetchFailed","isAuthenticated","accessToken","getAccessToken","instance","create","baseURL","serviceAPI","messagesUrl","headers","get","then","response","ok","Promise","reject","json","data","index","formattedMessages","map","message","date","Date","day","toLocaleDateString","time","toLocaleTimeString","sender","text","id","catch","err","console","error"],"mappings":";;AAAA,SAASA,QAAT,EAAmBC,SAAnB,QAAoC,OAApC;AACA,SAASC,WAAT,QAA4B,kBAA5B;AACA,OAAOC,KAAP,MAAkB,OAAlB;AAEA,OAAOC,MAA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IAAI,EAAG,GAAEE,GAAI,IAAGE,IAAK,EADhB;AAELE,YAAAA,MAAM,EAAEP,OAAO,CAACO,MAFX;AAGLC,YAAAA,IAAI,EAAER,OAAO,CAACQ,IAHT;AAILC,YAAAA,EAAE,EAAG,WAAUZ,KAAM;AAJhB,WAAP;AAMD,SAXyB,CAA1B;AAYApB,QAAAA,WAAW,CAACqB,iBAAD,CAAX;AACAnB,QAAAA,qBAAqB,CAAC,KAAD,CAArB;AACD,OAvBH,EAwBG+B,KAxBH,CAwBUC,GAAD,IAAS;AACdhC,QAAAA,qBAAqB,CAAC,IAAD,CAArB;AACA;;AACAiC,QAAAA,OAAO,CAACC,KAAR,CAAcF,GAAd;AACD,OA5BH;AA6BD;AACF,GA7CQ,EA6CN,CAACrC,SAAD,CA7CM,CAAT;AA+CA,SAAOE,QAAP;AACD,CAtDD;;GAAMH,W;UAC4BH,W;;;AAuDlC,eAAeG,WAAf","sourcesContent":["import { useState, useEffect } from 'react';\r\nimport { useOktaAuth } from '@okta/okta-react';\r\nimport axios from 'axios'\r\n\r\nimport config from \"../config\"\r\n\r\nconst useMessages = () => {\r\n const { authState, oktaAuth } = useOktaAuth();\r\n const [messages, setMessages] = useState(null);\r\n const [messageFetchFailed, setMessageFetchFailed] = useState(false);\r\n\r\n // fetch messages\r\n useEffect(() => {\r\n if (authState && authState.isAuthenticated) {\r\n const accessToken = oktaAuth.getAccessToken();\r\n // fetch(config.serviceAPI.messagesUrl, {\r\n // headers: {\r\n // Authorization: `Bearer ${accessToken}`,\r\n // },\r\n // })\r\n const instance = axios.create({\r\n baseURL: config.serviceAPI.messagesUrl,\r\n headers: {\r\n 'Authorization': `Bearer ${accessToken}`\r\n }\r\n })\r\n\r\n instance.get()\r\n .then((response) => {\r\n if (!response.ok) {\r\n return Promise.reject();\r\n }\r\n return response.json();\r\n })\r\n .then((data) => {\r\n let index = 0;\r\n const formattedMessages = data.messages.map((message) => {\r\n const date = new Date(message.date);\r\n const day = date.toLocaleDateString();\r\n const time = date.toLocaleTimeString();\r\n index += 1;\r\n return {\r\n date: `${day} ${time}`,\r\n sender: message.sender,\r\n text: message.text,\r\n id: `message-${index}`,\r\n };\r\n });\r\n setMessages(formattedMessages);\r\n setMessageFetchFailed(false);\r\n })\r\n .catch((err) => {\r\n setMessageFetchFailed(true);\r\n /* eslint-disable no-console */\r\n console.error(err);\r\n });\r\n }\r\n }, [authState]);\r\n\r\n return messages\r\n}\r\n\r\nexport default useMessages"]},"metadata":{},"sourceType":"module"}
\ No newline at end of file
{"ast":null,"code":"'use strict';\n\nvar utils = require('./utils');\n\nvar bind = require('./helpers/bind');\n\nvar Axios = require('./core/Axios');\n\nvar mergeConfig = require('./core/mergeConfig');\n\nvar defaults = require('./defaults');\n/**\n * Create an instance of Axios\n *\n * @param {Object} defaultConfig The default config for the instance\n * @return {Axios} A new instance of Axios\n */\n\n\nfunction createInstance(defaultConfig) {\n var context = new Axios(defaultConfig);\n var instance = bind(Axios.prototype.request, context); // Copy axios.prototype to instance\n\n utils.extend(instance, Axios.prototype, context); // Copy context to instance\n\n utils.extend(instance, context);\n return instance;\n} // Create the default instance to be exported\n\n\nvar axios = createInstance(defaults); // Expose Axios class to allow class inheritance\n\naxios.Axios = Axios; // Factory for creating new instances\n\naxios.create = function create(instanceConfig) {\n return createInstance(mergeConfig(axios.defaults, instanceConfig));\n}; // Expose Cancel & CancelToken\n\n\naxios.Cancel = require('./cancel/Cancel');\naxios.CancelToken = require('./cancel/CancelToken');\naxios.isCancel = require('./cancel/isCancel'); // Expose all/spread\n\naxios.all = function all(promises) {\n return Promise.all(promises);\n};\n\naxios.spread = require('./helpers/spread'); // Expose isAxiosError\n\naxios.isAxiosError = require('./helpers/isAxiosError');\nmodule.exports = axios; // Allow use of default import syntax in TypeScript\n\nmodule.exports.default = axios;","map":{"version":3,"sources":["C:/Users/Bruger/Desktop/Web-projects/pipit/client/node_modules/axios/lib/axios.js"],"names":["utils","require","bind","Axios","mergeConfig","defaults","createInstance","defaultConfig","context","instance","prototype","request","extend","axios","create","instanceConfig","Cancel","CancelToken","isCancel","all","promises","Promise","spread","isAxiosError","module","exports","default"],"mappings":"AAAA;;AAEA,IAAIA,KAAK,GAAGC,OAAO,CAAC,SAAD,CAAnB;;AACA,IAAIC,IAAI,GAAGD,OAAO,CAAC,gBAAD,CAAlB;;AACA,IAAIE,KAAK,GAAGF,OAAO,CAAC,cAAD,CAAnB;;AACA,IAAIG,WAAW,GAAGH,OAAO,CAAC,oBAAD,CAAzB;;AACA,IAAII,QAAQ,GAAGJ,OAAO,CAAC,YAAD,CAAtB;AAEA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASK,cAAT,CAAwBC,aAAxB,EAAuC;AACrC,MAAIC,OAAO,GAAG,IAAIL,KAAJ,CAAUI,aAAV,CAAd;AACA,MAAIE,QAAQ,GAAGP,IAAI,CAACC,KAAK,CAACO,SAAN,CAAgBC,OAAjB,EAA0BH,OAA1B,CAAnB,CAFqC,CAIrC;;AACAR,EAAAA,KAAK,CAACY,MAAN,CAAaH,QAAb,EAAuBN,KAAK,CAACO,SAA7B,EAAwCF,OAAxC,EALqC,CAOrC;;AACAR,EAAAA,KAAK,CAACY,MAAN,CAAaH,QAAb,EAAuBD,OAAvB;AAEA,SAAOC,QAAP;AACD,C,CAED;;;AACA,IAAII,KAAK,GAAGP,cAAc,CAACD,QAAD,CAA1B,C,CAEA;;AACAQ,KAAK,CAACV,KAAN,GAAcA,KAAd,C,CAEA;;AACAU,KAAK,CAACC,MAAN,GAAe,SAASA,MAAT,CAAgBC,cAAhB,EAAgC;AAC7C,SAAOT,cAAc,CAACF,WAAW,CAACS,KAAK,CAACR,QAAP,EAAiBU,cAAjB,CAAZ,CAArB;AACD,CAFD,C,CAIA;;;AACAF,KAAK,CAACG,MAAN,GAAef,OAAO,CAAC,iBAAD,CAAtB;AACAY,KAAK,CAACI,WAAN,GAAoBhB,OAAO,CAAC,sBAAD,CAA3B;AACAY,KAAK,CAACK,QAAN,GAAiBjB,OAAO,CAAC,mBAAD,CAAxB,C,CAEA;;AACAY,KAAK,CAACM,GAAN,GAAY,SAASA,GAAT,CAAaC,QAAb,EAAuB;AACjC,SAAOC,OAAO,CAACF,GAAR,CAAYC,QAAZ,CAAP;AACD,CAFD;;AAGAP,KAAK,CAACS,MAAN,GAAerB,OAAO,CAAC,kBAAD,CAAtB,C,CAEA;;AACAY,KAAK,CAACU,YAAN,GAAqBtB,OAAO,CAAC,wBAAD,CAA5B;AAEAuB,MAAM,CAACC,OAAP,GAAiBZ,KAAjB,C,CAEA;;AACAW,MAAM,CAACC,OAAP,CAAeC,OAAf,GAAyBb,KAAzB","sourcesContent":["'use strict';\n\nvar utils = require('./utils');\nvar bind = require('./helpers/bind');\nvar Axios = require('./core/Axios');\nvar mergeConfig = require('./core/mergeConfig');\nvar defaults = require('./defaults');\n\n/**\n * Create an instance of Axios\n *\n * @param {Object} defaultConfig The default config for the instance\n * @return {Axios} A new instance of Axios\n */\nfunction createInstance(defaultConfig) {\n var context = new Axios(defaultConfig);\n var instance = bind(Axios.prototype.request, context);\n\n // Copy axios.prototype to instance\n utils.extend(instance, Axios.prototype, context);\n\n // Copy context to instance\n utils.extend(instance, context);\n\n return instance;\n}\n\n// Create the default instance to be exported\nvar axios = createInstance(defaults);\n\n// Expose Axios class to allow class inheritance\naxios.Axios = Axios;\n\n// Factory for creating new instances\naxios.create = function create(instanceConfig) {\n return createInstance(mergeConfig(axios.defaults, instanceConfig));\n};\n\n// Expose Cancel & CancelToken\naxios.Cancel = require('./cancel/Cancel');\naxios.CancelToken = require('./cancel/CancelToken');\naxios.isCancel = require('./cancel/isCancel');\n\n// Expose all/spread\naxios.all = function all(promises) {\n return Promise.all(promises);\n};\naxios.spread = require('./helpers/spread');\n\n// Expose isAxiosError\naxios.isAxiosError = require('./helpers/isAxiosError');\n\nmodule.exports = axios;\n\n// Allow use of default import syntax in TypeScript\nmodule.exports.default = axios;\n"]},"metadata":{},"sourceType":"script"}
\ No newline at end of file
{"ast":null,"code":"'use strict';\n\nvar Cancel = require('./Cancel');\n/**\n * A `CancelToken` is an object that can be used to request cancellation of an operation.\n *\n * @class\n * @param {Function} executor The executor function.\n */\n\n\nfunction CancelToken(executor) {\n if (typeof executor !== 'function') {\n throw new TypeError('executor must be a function.');\n }\n\n var resolvePromise;\n this.promise = new Promise(function promiseExecutor(resolve) {\n resolvePromise = resolve;\n });\n var token = this;\n executor(function cancel(message) {\n if (token.reason) {\n // Cancellation has already been requested\n return;\n }\n\n token.reason = new Cancel(message);\n resolvePromise(token.reason);\n });\n}\n/**\n * Throws a `Cancel` if cancellation has been requested.\n */\n\n\nCancelToken.prototype.throwIfRequested = function throwIfRequested() {\n if (this.reason) {\n throw this.reason;\n }\n};\n/**\n * Returns an object that contains a new `CancelToken` and a function that, when called,\n * cancels the `CancelToken`.\n */\n\n\nCancelToken.source = function source() {\n var cancel;\n var token = new CancelToken(function executor(c) {\n cancel = c;\n });\n return {\n token: token,\n cancel: cancel\n };\n};\n\nmodule.exports = CancelToken;","map":{"version":3,"sources":["C:/Users/Bruger/Desktop/Web-projects/pipit/client/node_modules/axios/lib/cancel/CancelToken.js"],"names":["Cancel","require","CancelToken","executor","TypeError","resolvePromise","promise","Promise","promiseExecutor","resolve","token","cancel","message","reason","prototype","throwIfRequested","source","c","module","exports"],"mappings":"AAAA;;AAEA,IAAIA,MAAM,GAAGC,OAAO,CAAC,UAAD,CAApB;AAEA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASC,WAAT,CAAqBC,QAArB,EAA+B;AAC7B,MAAI,OAAOA,QAAP,KAAoB,UAAxB,EAAoC;AAClC,UAAM,IAAIC,SAAJ,CAAc,8BAAd,CAAN;AACD;;AAED,MAAIC,cAAJ;AACA,OAAKC,OAAL,GAAe,IAAIC,OAAJ,CAAY,SAASC,eAAT,CAAyBC,OAAzB,EAAkC;AAC3DJ,IAAAA,cAAc,GAAGI,OAAjB;AACD,GAFc,CAAf;AAIA,MAAIC,KAAK,GAAG,IAAZ;AACAP,EAAAA,QAAQ,CAAC,SAASQ,MAAT,CAAgBC,OAAhB,EAAyB;AAChC,QAAIF,KAAK,CAACG,MAAV,EAAkB;AAChB;AACA;AACD;;AAEDH,IAAAA,KAAK,CAACG,MAAN,GAAe,IAAIb,MAAJ,CAAWY,OAAX,CAAf;AACAP,IAAAA,cAAc,CAACK,KAAK,CAACG,MAAP,CAAd;AACD,GARO,CAAR;AASD;AAED;AACA;AACA;;;AACAX,WAAW,CAACY,SAAZ,CAAsBC,gBAAtB,GAAyC,SAASA,gBAAT,GAA4B;AACnE,MAAI,KAAKF,MAAT,EAAiB;AACf,UAAM,KAAKA,MAAX;AACD;AACF,CAJD;AAMA;AACA;AACA;AACA;;;AACAX,WAAW,CAACc,MAAZ,GAAqB,SAASA,MAAT,GAAkB;AACrC,MAAIL,MAAJ;AACA,MAAID,KAAK,GAAG,IAAIR,WAAJ,CAAgB,SAASC,QAAT,CAAkBc,CAAlB,EAAqB;AAC/CN,IAAAA,MAAM,GAAGM,CAAT;AACD,GAFW,CAAZ;AAGA,SAAO;AACLP,IAAAA,KAAK,EAAEA,KADF;AAELC,IAAAA,MAAM,EAAEA;AAFH,GAAP;AAID,CATD;;AAWAO,MAAM,CAACC,OAAP,GAAiBjB,WAAjB","sourcesContent":["'use strict';\n\nvar Cancel = require('./Cancel');\n\n/**\n * A `CancelToken` is an object that can be used to request cancellation of an operation.\n *\n * @class\n * @param {Function} executor The executor function.\n */\nfunction CancelToken(executor) {\n if (typeof executor !== 'function') {\n throw new TypeError('executor must be a function.');\n }\n\n var resolvePromise;\n this.promise = new Promise(function promiseExecutor(resolve) {\n resolvePromise = resolve;\n });\n\n var token = this;\n executor(function cancel(message) {\n if (token.reason) {\n // Cancellation has already been requested\n return;\n }\n\n token.reason = new Cancel(message);\n resolvePromise(token.reason);\n });\n}\n\n/**\n * Throws a `Cancel` if cancellation has been requested.\n */\nCancelToken.prototype.throwIfRequested = function throwIfRequested() {\n if (this.reason) {\n throw this.reason;\n }\n};\n\n/**\n * Returns an object that contains a new `CancelToken` and a function that, when called,\n * cancels the `CancelToken`.\n */\nCancelToken.source = function source() {\n var cancel;\n var token = new CancelToken(function executor(c) {\n cancel = c;\n });\n return {\n token: token,\n cancel: cancel\n };\n};\n\nmodule.exports = CancelToken;\n"]},"metadata":{},"sourceType":"script"}
\ No newline at end of file
{"ast":null,"code":"'use strict';\n\nvar createError = require('./createError');\n/**\n * Resolve or reject a Promise based on response status.\n *\n * @param {Function} resolve A function that resolves the promise.\n * @param {Function} reject A function that rejects the promise.\n * @param {object} response The response.\n */\n\n\nmodule.exports = function settle(resolve, reject, response) {\n var validateStatus = response.config.validateStatus;\n\n if (!response.status || !validateStatus || validateStatus(response.status)) {\n resolve(response);\n } else {\n reject(createError('Request failed with status code ' + response.status, response.config, null, response.request, response));\n }\n};","map":{"version":3,"sources":["C:/Users/Bruger/Desktop/Web-projects/pipit/client/node_modules/axios/lib/core/settle.js"],"names":["createError","require","module","exports","settle","resolve","reject","response","validateStatus","config","status","request"],"mappings":"AAAA;;AAEA,IAAIA,WAAW,GAAGC,OAAO,CAAC,eAAD,CAAzB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACAC,MAAM,CAACC,OAAP,GAAiB,SAASC,MAAT,CAAgBC,OAAhB,EAAyBC,MAAzB,EAAiCC,QAAjC,EAA2C;AAC1D,MAAIC,cAAc,GAAGD,QAAQ,CAACE,MAAT,CAAgBD,cAArC;;AACA,MAAI,CAACD,QAAQ,CAACG,MAAV,IAAoB,CAACF,cAArB,IAAuCA,cAAc,CAACD,QAAQ,CAACG,MAAV,CAAzD,EAA4E;AAC1EL,IAAAA,OAAO,CAACE,QAAD,CAAP;AACD,GAFD,MAEO;AACLD,IAAAA,MAAM,CAACN,WAAW,CAChB,qCAAqCO,QAAQ,CAACG,MAD9B,EAEhBH,QAAQ,CAACE,MAFO,EAGhB,IAHgB,EAIhBF,QAAQ,CAACI,OAJO,EAKhBJ,QALgB,CAAZ,CAAN;AAOD;AACF,CAbD","sourcesContent":["'use strict';\n\nvar createError = require('./createError');\n\n/**\n * Resolve or reject a Promise based on response status.\n *\n * @param {Function} resolve A function that resolves the promise.\n * @param {Function} reject A function that rejects the promise.\n * @param {object} response The response.\n */\nmodule.exports = function settle(resolve, reject, response) {\n var validateStatus = response.config.validateStatus;\n if (!response.status || !validateStatus || validateStatus(response.status)) {\n resolve(response);\n } else {\n reject(createError(\n 'Request failed with status code ' + response.status,\n response.config,\n null,\n response.request,\n response\n ));\n }\n};\n"]},"metadata":{},"sourceType":"script"}
\ No newline at end of file
{"ast":null,"code":"module.exports = require('./lib/axios');","map":{"version":3,"sources":["C:/Users/Bruger/Desktop/Web-projects/pipit/client/node_modules/axios/index.js"],"names":["module","exports","require"],"mappings":"AAAAA,MAAM,CAACC,OAAP,GAAiBC,OAAO,CAAC,aAAD,CAAxB","sourcesContent":["module.exports = require('./lib/axios');"]},"metadata":{},"sourceType":"script"}
\ No newline at end of file
{"ast":null,"code":"'use strict';\n\nvar utils = require('./../utils'); // Headers whose duplicates are ignored by node\n// c.f. https://nodejs.org/api/http.html#http_message_headers\n\n\nvar ignoreDuplicateOf = ['age', 'authorization', 'content-length', 'content-type', 'etag', 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since', 'last-modified', 'location', 'max-forwards', 'proxy-authorization', 'referer', 'retry-after', 'user-agent'];\n/**\n * Parse headers into an object\n *\n * ```\n * Date: Wed, 27 Aug 2014 08:58:49 GMT\n * Content-Type: application/json\n * Connection: keep-alive\n * Transfer-Encoding: chunked\n * ```\n *\n * @param {String} headers Headers needing to be parsed\n * @returns {Object} Headers parsed into an object\n */\n\nmodule.exports = function parseHeaders(headers) {\n var parsed = {};\n var key;\n var val;\n var i;\n\n if (!headers) {\n return parsed;\n }\n\n utils.forEach(headers.split('\\n'), function parser(line) {\n i = line.indexOf(':');\n key = utils.trim(line.substr(0, i)).toLowerCase();\n val = utils.trim(line.substr(i + 1));\n\n if (key) {\n if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {\n return;\n }\n\n if (key === 'set-cookie') {\n parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);\n } else {\n parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;\n }\n }\n });\n return parsed;\n};","map":{"version":3,"sources":["C:/Users/Bruger/Desktop/Web-projects/pipit/client/node_modules/axios/lib/helpers/parseHeaders.js"],"names":["utils","require","ignoreDuplicateOf","module","exports","parseHeaders","headers","parsed","key","val","i","forEach","split","parser","line","indexOf","trim","substr","toLowerCase","concat"],"mappings":"AAAA;;AAEA,IAAIA,KAAK,GAAGC,OAAO,CAAC,YAAD,CAAnB,C,CAEA;AACA;;;AACA,IAAIC,iBAAiB,GAAG,CACtB,KADsB,EACf,eADe,EACE,gBADF,EACoB,cADpB,EACoC,MADpC,EAEtB,SAFsB,EAEX,MAFW,EAEH,MAFG,EAEK,mBAFL,EAE0B,qBAF1B,EAGtB,eAHsB,EAGL,UAHK,EAGO,cAHP,EAGuB,qBAHvB,EAItB,SAJsB,EAIX,aAJW,EAII,YAJJ,CAAxB;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACAC,MAAM,CAACC,OAAP,GAAiB,SAASC,YAAT,CAAsBC,OAAtB,EAA+B;AAC9C,MAAIC,MAAM,GAAG,EAAb;AACA,MAAIC,GAAJ;AACA,MAAIC,GAAJ;AACA,MAAIC,CAAJ;;AAEA,MAAI,CAACJ,OAAL,EAAc;AAAE,WAAOC,MAAP;AAAgB;;AAEhCP,EAAAA,KAAK,CAACW,OAAN,CAAcL,OAAO,CAACM,KAAR,CAAc,IAAd,CAAd,EAAmC,SAASC,MAAT,CAAgBC,IAAhB,EAAsB;AACvDJ,IAAAA,CAAC,GAAGI,IAAI,CAACC,OAAL,CAAa,GAAb,CAAJ;AACAP,IAAAA,GAAG,GAAGR,KAAK,CAACgB,IAAN,CAAWF,IAAI,CAACG,MAAL,CAAY,CAAZ,EAAeP,CAAf,CAAX,EAA8BQ,WAA9B,EAAN;AACAT,IAAAA,GAAG,GAAGT,KAAK,CAACgB,IAAN,CAAWF,IAAI,CAACG,MAAL,CAAYP,CAAC,GAAG,CAAhB,CAAX,CAAN;;AAEA,QAAIF,GAAJ,EAAS;AACP,UAAID,MAAM,CAACC,GAAD,CAAN,IAAeN,iBAAiB,CAACa,OAAlB,CAA0BP,GAA1B,KAAkC,CAArD,EAAwD;AACtD;AACD;;AACD,UAAIA,GAAG,KAAK,YAAZ,EAA0B;AACxBD,QAAAA,MAAM,CAACC,GAAD,CAAN,GAAc,CAACD,MAAM,CAACC,GAAD,CAAN,GAAcD,MAAM,CAACC,GAAD,CAApB,GAA4B,EAA7B,EAAiCW,MAAjC,CAAwC,CAACV,GAAD,CAAxC,CAAd;AACD,OAFD,MAEO;AACLF,QAAAA,MAAM,CAACC,GAAD,CAAN,GAAcD,MAAM,CAACC,GAAD,CAAN,GAAcD,MAAM,CAACC,GAAD,CAAN,GAAc,IAAd,GAAqBC,GAAnC,GAAyCA,GAAvD;AACD;AACF;AACF,GAfD;AAiBA,SAAOF,MAAP;AACD,CA1BD","sourcesContent":["'use strict';\n\nvar utils = require('./../utils');\n\n// Headers whose duplicates are ignored by node\n// c.f. https://nodejs.org/api/http.html#http_message_headers\nvar ignoreDuplicateOf = [\n 'age', 'authorization', 'content-length', 'content-type', 'etag',\n 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',\n 'last-modified', 'location', 'max-forwards', 'proxy-authorization',\n 'referer', 'retry-after', 'user-agent'\n];\n\n/**\n * Parse headers into an object\n *\n * ```\n * Date: Wed, 27 Aug 2014 08:58:49 GMT\n * Content-Type: application/json\n * Connection: keep-alive\n * Transfer-Encoding: chunked\n * ```\n *\n * @param {String} headers Headers needing to be parsed\n * @returns {Object} Headers parsed into an object\n */\nmodule.exports = function parseHeaders(headers) {\n var parsed = {};\n var key;\n var val;\n var i;\n\n if (!headers) { return parsed; }\n\n utils.forEach(headers.split('\\n'), function parser(line) {\n i = line.indexOf(':');\n key = utils.trim(line.substr(0, i)).toLowerCase();\n val = utils.trim(line.substr(i + 1));\n\n if (key) {\n if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {\n return;\n }\n if (key === 'set-cookie') {\n parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);\n } else {\n parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;\n }\n }\n });\n\n return parsed;\n};\n"]},"metadata":{},"sourceType":"script"}
\ No newline at end of file
{"ast":null,"code":"var _s = $RefreshSig$();\n\nimport { useState, useEffect } from 'react';\nimport { useOktaAuth } from '@okta/okta-react';\nimport axios from 'axios';\nimport config from \"../config\";\n\nconst useMessages = () => {\n _s();\n\n const {\n authState,\n oktaAuth\n } = useOktaAuth();\n const [messages, setMessages] = useState(null);\n const [messageFetchFailed, setMessageFetchFailed] = useState(false); // fetch messages\n\n useEffect(() => {\n if (authState && authState.isAuthenticated) {\n const accessToken = oktaAuth.getAccessToken(); // fetch(config.serviceAPI.messagesUrl, {\n // headers: {\n // Authorization: `Bearer ${accessToken}`,\n // },\n // })\n\n axios.get(config.serviceAPI.messagesUrl, {\n headers: {\n Authorization: `Bearer ${accessToken}`\n }\n }).then(response => {\n if (!response.ok) {\n return Promise.reject();\n }\n\n return response.json();\n }).then(data => {\n let index = 0;\n const formattedMessages = data.messages.map(message => {\n const date = new Date(message.date);\n const day = date.toLocaleDateString();\n const time = date.toLocaleTimeString();\n index += 1;\n return {\n date: `${day} ${time}`,\n sender: message.sender,\n text: message.text,\n id: `message-${index}`\n };\n });\n setMessages(formattedMessages);\n setMessageFetchFailed(false);\n }).catch(err => {\n setMessageFetchFailed(true);\n /* eslint-disable no-console */\n\n console.error(err);\n });\n }\n }, [authState]);\n return messages;\n};\n\n_s(useMessages, \"U3xiPl25FsmufxeRxpFVBz8Cguw=\", false, function () {\n return [useOktaAuth];\n});\n\nexport default useMessages;","map":{"version":3,"sources":["C:/Users/Bruger/Desktop/Web-projects/pipit/client/src/util/useMessages.jsx"],"names":["useState","useEffect","useOktaAuth","axios","config","useMessages","authState","oktaAuth","messages","setMessages","messageFetchFailed","setMessageFetchFailed","isAuthenticated","accessToken","getAccessToken","get","serviceAPI","messagesUrl","headers","Authorization","then","response","ok","Promise","reject","json","data","index","formattedMessages","map","message","date","Date","day","toLocaleDateString","time","toLocaleTimeString","sender","text","id","catch","err","console","error"],"mappings":";;AAAA,SAASA,QAAT,EAAmBC,SAAnB,QAAoC,OAApC;AACA,SAASC,WAAT,QAA4B,kBAA5B;AACA,OAAOC,KAAP,MAAkB,OAAlB;AAEA,OAAOC,MAAP,MAAmB,WAAnB;;AAEA,MAAMC,WAAW,GAAG,MAAM;AAAA;;AACxB,QAAM;AAAEC,IAAAA,SAAF;AAAaC,IAAAA;AAAb,MAA0BL,WAAW,EAA3C;AACA,QAAM,CAACM,QAAD,EAAWC,WAAX,IAA0BT,QAAQ,CAAC,IAAD,CAAxC;AACA,QAAM,CAACU,kBAAD,EAAqBC,qBAArB,IAA8CX,QAAQ,CAAC,KAAD,CAA5D,CAHwB,CAKxB;;AACAC,EAAAA,SAAS,CAAC,MAAM;AACd,QAAIK,SAAS,IAAIA,SAAS,CAACM,eAA3B,EAA4C;AAC1C,YAAMC,WAAW,GAAGN,QAAQ,CAACO,cAAT,EAApB,CAD0C,CAE1C;AACA;AACA;AACA;AACA;;AACAX,MAAAA,KAAK,CAACY,GAAN,CAAUX,MAAM,CAACY,UAAP,CAAkBC,WAA5B,EAAyC;AACvCC,QAAAA,OAAO,EAAE;AACPC,UAAAA,aAAa,EAAG,UAASN,WAAY;AAD9B;AAD8B,OAAzC,EAKGO,IALH,CAKSC,QAAD,IAAc;AAClB,YAAI,CAACA,QAAQ,CAACC,EAAd,EAAkB;AAChB,iBAAOC,OAAO,CAACC,MAAR,EAAP;AACD;;AACD,eAAOH,QAAQ,CAACI,IAAT,EAAP;AACD,OAVH,EAWGL,IAXH,CAWSM,IAAD,IAAU;AACd,YAAIC,KAAK,GAAG,CAAZ;AACA,cAAMC,iBAAiB,GAAGF,IAAI,CAAClB,QAAL,CAAcqB,GAAd,CAAmBC,OAAD,IAAa;AACvD,gBAAMC,IAAI,GAAG,IAAIC,IAAJ,CAASF,OAAO,CAACC,IAAjB,CAAb;AACA,gBAAME,GAAG,GAAGF,IAAI,CAACG,kBAAL,EAAZ;AACA,gBAAMC,IAAI,GAAGJ,IAAI,CAACK,kBAAL,EAAb;AACAT,UAAAA,KAAK,IAAI,CAAT;AACA,iBAAO;AACLI,YAAAA,IAAI,EAAG,GAAEE,GAAI,IAAGE,IAAK,EADhB;AAELE,YAAAA,MAAM,EAAEP,OAAO,CAACO,MAFX;AAGLC,YAAAA,IAAI,EAAER,OAAO,CAACQ,IAHT;AAILC,YAAAA,EAAE,EAAG,WAAUZ,KAAM;AAJhB,WAAP;AAMD,SAXyB,CAA1B;AAYAlB,QAAAA,WAAW,CAACmB,iBAAD,CAAX;AACAjB,QAAAA,qBAAqB,CAAC,KAAD,CAArB;AACD,OA3BH,EA4BG6B,KA5BH,CA4BUC,GAAD,IAAS;AACd9B,QAAAA,qBAAqB,CAAC,IAAD,CAArB;AACA;;AACA+B,QAAAA,OAAO,CAACC,KAAR,CAAcF,GAAd;AACD,OAhCH;AAiCD;AACF,GA1CQ,EA0CN,CAACnC,SAAD,CA1CM,CAAT;AA4CA,SAAOE,QAAP;AACD,CAnDD;;GAAMH,W;UAC4BH,W;;;AAoDlC,eAAeG,WAAf","sourcesContent":["import { useState, useEffect } from 'react';\r\nimport { useOktaAuth } from '@okta/okta-react';\r\nimport axios from 'axios'\r\n\r\nimport config from \"../config\"\r\n\r\nconst useMessages = () => {\r\n const { authState, oktaAuth } = useOktaAuth();\r\n const [messages, setMessages] = useState(null);\r\n const [messageFetchFailed, setMessageFetchFailed] = useState(false);\r\n\r\n // fetch messages\r\n useEffect(() => {\r\n if (authState && authState.isAuthenticated) {\r\n const accessToken = oktaAuth.getAccessToken();\r\n // fetch(config.serviceAPI.messagesUrl, {\r\n // headers: {\r\n // Authorization: `Bearer ${accessToken}`,\r\n // },\r\n // })\r\n axios.get(config.serviceAPI.messagesUrl, {\r\n headers: {\r\n Authorization: `Bearer ${accessToken}`,\r\n },\r\n })\r\n .then((response) => {\r\n if (!response.ok) {\r\n return Promise.reject();\r\n }\r\n return response.json();\r\n })\r\n .then((data) => {\r\n let index = 0;\r\n const formattedMessages = data.messages.map((message) => {\r\n const date = new Date(message.date);\r\n const day = date.toLocaleDateString();\r\n const time = date.toLocaleTimeString();\r\n index += 1;\r\n return {\r\n date: `${day} ${time}`,\r\n sender: message.sender,\r\n text: message.text,\r\n id: `message-${index}`,\r\n };\r\n });\r\n setMessages(formattedMessages);\r\n setMessageFetchFailed(false);\r\n })\r\n .catch((err) => {\r\n setMessageFetchFailed(true);\r\n /* eslint-disable no-console */\r\n console.error(err);\r\n });\r\n }\r\n }, [authState]);\r\n\r\n return messages\r\n}\r\n\r\nexport default useMessages"]},"metadata":{},"sourceType":"module"}
\ No newline at end of file
{"ast":null,"code":"'use strict';\n\nvar utils = require('./../utils');\n\nfunction InterceptorManager() {\n this.handlers = [];\n}\n/**\n * Add a new interceptor to the stack\n *\n * @param {Function} fulfilled The function to handle `then` for a `Promise`\n * @param {Function} rejected The function to handle `reject` for a `Promise`\n *\n * @return {Number} An ID used to remove interceptor later\n */\n\n\nInterceptorManager.prototype.use = function use(fulfilled, rejected) {\n this.handlers.push({\n fulfilled: fulfilled,\n rejected: rejected\n });\n return this.handlers.length - 1;\n};\n/**\n * Remove an interceptor from the stack\n *\n * @param {Number} id The ID that was returned by `use`\n */\n\n\nInterceptorManager.prototype.eject = function eject(id) {\n if (this.handlers[id]) {\n this.handlers[id] = null;\n }\n};\n/**\n * Iterate over all the registered interceptors\n *\n * This method is particularly useful for skipping over any\n * interceptors that may have become `null` calling `eject`.\n *\n * @param {Function} fn The function to call for each interceptor\n */\n\n\nInterceptorManager.prototype.forEach = function forEach(fn) {\n utils.forEach(this.handlers, function forEachHandler(h) {\n if (h !== null) {\n fn(h);\n }\n });\n};\n\nmodule.exports = InterceptorManager;","map":{"version":3,"sources":["C:/Users/Bruger/Desktop/Web-projects/pipit/client/node_modules/axios/lib/core/InterceptorManager.js"],"names":["utils","require","InterceptorManager","handlers","prototype","use","fulfilled","rejected","push","length","eject","id","forEach","fn","forEachHandler","h","module","exports"],"mappings":"AAAA;;AAEA,IAAIA,KAAK,GAAGC,OAAO,CAAC,YAAD,CAAnB;;AAEA,SAASC,kBAAT,GAA8B;AAC5B,OAAKC,QAAL,GAAgB,EAAhB;AACD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACAD,kBAAkB,CAACE,SAAnB,CAA6BC,GAA7B,GAAmC,SAASA,GAAT,CAAaC,SAAb,EAAwBC,QAAxB,EAAkC;AACnE,OAAKJ,QAAL,CAAcK,IAAd,CAAmB;AACjBF,IAAAA,SAAS,EAAEA,SADM;AAEjBC,IAAAA,QAAQ,EAAEA;AAFO,GAAnB;AAIA,SAAO,KAAKJ,QAAL,CAAcM,MAAd,GAAuB,CAA9B;AACD,CAND;AAQA;AACA;AACA;AACA;AACA;;;AACAP,kBAAkB,CAACE,SAAnB,CAA6BM,KAA7B,GAAqC,SAASA,KAAT,CAAeC,EAAf,EAAmB;AACtD,MAAI,KAAKR,QAAL,CAAcQ,EAAd,CAAJ,EAAuB;AACrB,SAAKR,QAAL,CAAcQ,EAAd,IAAoB,IAApB;AACD;AACF,CAJD;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACAT,kBAAkB,CAACE,SAAnB,CAA6BQ,OAA7B,GAAuC,SAASA,OAAT,CAAiBC,EAAjB,EAAqB;AAC1Db,EAAAA,KAAK,CAACY,OAAN,CAAc,KAAKT,QAAnB,EAA6B,SAASW,cAAT,CAAwBC,CAAxB,EAA2B;AACtD,QAAIA,CAAC,KAAK,IAAV,EAAgB;AACdF,MAAAA,EAAE,CAACE,CAAD,CAAF;AACD;AACF,GAJD;AAKD,CAND;;AAQAC,MAAM,CAACC,OAAP,GAAiBf,kBAAjB","sourcesContent":["'use strict';\n\nvar utils = require('./../utils');\n\nfunction InterceptorManager() {\n this.handlers = [];\n}\n\n/**\n * Add a new interceptor to the stack\n *\n * @param {Function} fulfilled The function to handle `then` for a `Promise`\n * @param {Function} rejected The function to handle `reject` for a `Promise`\n *\n * @return {Number} An ID used to remove interceptor later\n */\nInterceptorManager.prototype.use = function use(fulfilled, rejected) {\n this.handlers.push({\n fulfilled: fulfilled,\n rejected: rejected\n });\n return this.handlers.length - 1;\n};\n\n/**\n * Remove an interceptor from the stack\n *\n * @param {Number} id The ID that was returned by `use`\n */\nInterceptorManager.prototype.eject = function eject(id) {\n if (this.handlers[id]) {\n this.handlers[id] = null;\n }\n};\n\n/**\n * Iterate over all the registered interceptors\n *\n * This method is particularly useful for skipping over any\n * interceptors that may have become `null` calling `eject`.\n *\n * @param {Function} fn The function to call for each interceptor\n */\nInterceptorManager.prototype.forEach = function forEach(fn) {\n utils.forEach(this.handlers, function forEachHandler(h) {\n if (h !== null) {\n fn(h);\n }\n });\n};\n\nmodule.exports = InterceptorManager;\n"]},"metadata":{},"sourceType":"script"}
\ No newline at end of file
{"ast":null,"code":"var _s = $RefreshSig$();\n\nimport { useState, useEffect } from 'react';\nimport { useOktaAuth } from '@okta/okta-react';\nimport axios from 'axios';\nimport config from \"../config\";\n\nconst useMessages = () => {\n _s();\n\n const {\n authState,\n oktaAuth\n } = useOktaAuth();\n const [messages, setMessages] = useState(null);\n const [messageFetchFailed, setMessageFetchFailed] = useState(false); // fetch messages\n\n useEffect(() => {\n if (authState && authState.isAuthenticated) {\n const accessToken = oktaAuth.getAccessToken();\n fetch(config.serviceAPI.messagesUrl, {\n headers: {\n Authorization: `Bearer ${accessToken}`\n }\n }) // axios.get(config.serviceAPI.messagesUrl, {\n // headers: {\n // Authorization: `Bearer ${accessToken}`\n // }\n // })\n .then(response => {\n if (!response.ok) {\n return Promise.reject();\n }\n\n return response.json();\n }).then(data => {\n let index = 0;\n const formattedMessages = data.messages.map(message => {\n const date = new Date(message.date);\n const day = date.toLocaleDateString();\n const time = date.toLocaleTimeString();\n index += 1;\n return {\n date: `${day} ${time}`,\n sender: message.sender,\n text: message.text,\n id: `message-${index}`\n };\n });\n setMessages(formattedMessages);\n setMessageFetchFailed(false);\n }).catch(err => {\n setMessageFetchFailed(true);\n /* eslint-disable no-console */\n\n console.error(err);\n });\n }\n }, [authState]);\n return messages;\n};\n\n_s(useMessages, \"U3xiPl25FsmufxeRxpFVBz8Cguw=\", false, function () {\n return [useOktaAuth];\n});\n\nexport default useMessages;","map":{"version":3,"sources":["C:/Users/Bruger/Desktop/Web-projects/pipit/client/src/util/useMessages.jsx"],"names":["useState","useEffect","useOktaAuth","axios","config","useMessages","authState","oktaAuth","messages","setMessages","messageFetchFailed","setMessageFetchFailed","isAuthenticated","accessToken","getAccessToken","fetch","serviceAPI","messagesUrl","headers","Authorization","then","response","ok","Promise","reject","json","data","index","formattedMessages","map","message","date","Date","day","toLocaleDateString","time","toLocaleTimeString","sender","text","id","catch","err","console","error"],"mappings":";;AAAA,SAASA,QAAT,EAAmBC,SAAnB,QAAoC,OAApC;AACA,SAASC,WAAT,QAA4B,kBAA5B;AACA,OAAOC,KAAP,MAAkB,OAAlB;AAEA,OAAOC,MAAP,MAAmB,WAAnB;;AAEA,MAAMC,WAAW,GAAG,MAAM;AAAA;;AACxB,QAAM;AAAEC,IAAAA,SAAF;AAAaC,IAAAA;AAAb,MAA0BL,WAAW,EAA3C;AACA,QAAM,CAACM,QAAD,EAAWC,WAAX,IAA0BT,QAAQ,CAAC,IAAD,CAAxC;AACA,QAAM,CAACU,kBAAD,EAAqBC,qBAArB,IAA8CX,QAAQ,CAAC,KAAD,CAA5D,CAHwB,CAKxB;;AACAC,EAAAA,SAAS,CAAC,MAAM;AACd,QAAIK,SAAS,IAAIA,SAAS,CAACM,eAA3B,EAA4C;AAC1C,YAAMC,WAAW,GAAGN,QAAQ,CAACO,cAAT,EAApB;AACAC,MAAAA,KAAK,C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QAAP;AACD,CAnDD;;GAAMH,W;UAC4BH,W;;;AAoDlC,eAAeG,WAAf","sourcesContent":["import { useState, useEffect } from 'react';\r\nimport { useOktaAuth } from '@okta/okta-react';\r\nimport axios from 'axios'\r\n\r\nimport config from \"../config\"\r\n\r\nconst useMessages = () => {\r\n const { authState, oktaAuth } = useOktaAuth();\r\n const [messages, setMessages] = useState(null);\r\n const [messageFetchFailed, setMessageFetchFailed] = useState(false);\r\n\r\n // fetch messages\r\n useEffect(() => {\r\n if (authState && authState.isAuthenticated) {\r\n const accessToken = oktaAuth.getAccessToken();\r\n fetch(config.serviceAPI.messagesUrl, {\r\n headers: {\r\n Authorization: `Bearer ${accessToken}`,\r\n },\r\n })\r\n // axios.get(config.serviceAPI.messagesUrl, {\r\n // headers: {\r\n // Authorization: `Bearer ${accessToken}`\r\n // }\r\n // })\r\n .then((response) => {\r\n if (!response.ok) {\r\n return Promise.reject();\r\n }\r\n return response.json();\r\n })\r\n .then((data) => {\r\n let index = 0;\r\n const formattedMessages = data.messages.map((message) => {\r\n const date = new Date(message.date);\r\n const day = date.toLocaleDateString();\r\n const time = date.toLocaleTimeString();\r\n index += 1;\r\n return {\r\n date: `${day} ${time}`,\r\n sender: message.sender,\r\n text: message.text,\r\n id: `message-${index}`,\r\n };\r\n });\r\n setMessages(formattedMessages);\r\n setMessageFetchFailed(false);\r\n })\r\n .catch((err) => {\r\n setMessageFetchFailed(true);\r\n /* eslint-disable no-console */\r\n console.error(err);\r\n });\r\n }\r\n }, [authState]);\r\n\r\n return messages\r\n}\r\n\r\nexport default useMessages"]},"metadata":{},"sourceType":"module"}
\ No newline at end of file
{"ast":null,"code":"var _s = $RefreshSig$();\n\nimport { useState, useEffect } from 'react';\nimport { useOktaAuth } from '@okta/okta-react';\nimport axios from 'axios';\nimport config from \"../config\";\n\nconst useMessages = () => {\n _s();\n\n const {\n authState,\n oktaAuth\n } = useOktaAuth();\n const [messages, setMessages] = useState(null);\n const [messageFetchFailed, setMessageFetchFailed] = useState(false); // fetch messages\n\n useEffect(() => {\n if (authState && authState.isAuthenticated) {\n const accessToken = oktaAuth.getAccessToken(); // fetch(config.serviceAPI.messagesUrl, {\n // headers: {\n // Authorization: `Bearer ${accessToken}`,\n // },\n // })\n\n axios({\n method: 'GET',\n url: 'config.serviceAPI.messagesUrl',\n headers: {\n Authorization: `Bearer ${accessToken}`\n }\n }).then(response => {\n if (!response.ok) {\n return Promise.reject();\n }\n\n return response.json();\n }).then(data => {\n let index = 0;\n const formattedMessages = data.messages.map(message => {\n const date = new Date(message.date);\n const day = date.toLocaleDateString();\n const time = date.toLocaleTimeString();\n index += 1;\n return {\n date: `${day} ${time}`,\n sender: message.sender,\n text: message.text,\n id: `message-${index}`\n };\n });\n setMessages(formattedMessages);\n setMessageFetchFailed(false);\n }).catch(err => {\n setMessageFetchFailed(true);\n /* eslint-disable no-console */\n\n console.error(err);\n });\n }\n }, [authState]);\n return messages;\n};\n\n_s(useMessages, \"U3xiPl25FsmufxeRxpFVBz8Cguw=\", false, function () {\n return [useOktaAuth];\n});\n\nexport default useMessages;","map":{"version":3,"sources":["C:/Users/Bruger/Desktop/Web-projects/pipit/client/src/util/useMessages.jsx"],"names":["useState","useEffect","useOktaAuth","axios","config","useMessages","authState","oktaAuth","messages","setMessages","messageFetchFailed","setMessageFetchFailed","isAuthenticated","accessToken","getAccessToken","method","url","headers","Authorization","then","response","ok","Promise","reject","json","data","index","formattedMessages","map","message","date","Date","day","toLocaleDateString","time","toLocaleTimeString","sender","text","id","catch","err","console","error"],"mappings":";;AAAA,SAASA,QAAT,EAAmBC,SAAnB,QAAoC,OAApC;AACA,SAASC,WAAT,QAA4B,kBAA5B;AACA,OAAOC,KAAP,MAAkB,OAAlB;AAEA,OAAOC,MAAP,MAAmB,WAAnB;;AAEA,MAAMC,WAAW,GAAG,MAAM;AAAA;;AACxB,QAAM;AAAEC,IAAAA,SAAF;AAAaC,IAAAA;AAAb,MAA0BL,WAAW,EAA3C;AACA,QAAM,CAACM,Q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MD,SAXyB,CAA1B;AAYAjB,QAAAA,WAAW,CAACkB,iBAAD,CAAX;AACAhB,QAAAA,qBAAqB,CAAC,KAAD,CAArB;AACD,OA7BH,EA8BG4B,KA9BH,CA8BUC,GAAD,IAAS;AACd7B,QAAAA,qBAAqB,CAAC,IAAD,CAArB;AACA;;AACA8B,QAAAA,OAAO,CAACC,KAAR,CAAcF,GAAd;AACD,OAlCH;AAmCD;AACF,GA5CQ,EA4CN,CAAClC,SAAD,CA5CM,CAAT;AA8CA,SAAOE,QAAP;AACD,CArDD;;GAAMH,W;UAC4BH,W;;;AAsDlC,eAAeG,WAAf","sourcesContent":["import { useState, useEffect } from 'react';\r\nimport { useOktaAuth } from '@okta/okta-react';\r\nimport axios from 'axios'\r\n\r\nimport config from \"../config\"\r\n\r\nconst useMessages = () => {\r\n const { authState, oktaAuth } = useOktaAuth();\r\n const [messages, setMessages] = useState(null);\r\n const [messageFetchFailed, setMessageFetchFailed] = useState(false);\r\n\r\n // fetch messages\r\n useEffect(() => {\r\n if (authState && authState.isAuthenticated) {\r\n const accessToken = oktaAuth.getAccessToken();\r\n // fetch(config.serviceAPI.messagesUrl, {\r\n // headers: {\r\n // Authorization: `Bearer ${accessToken}`,\r\n // },\r\n // })\r\n axios({\r\n method: 'GET',\r\n url: 'config.serviceAPI.messagesUrl',\r\n headers: {\r\n Authorization: `Bearer ${accessToken}`\r\n }\r\n })\r\n .then((response) => {\r\n if (!response.ok) {\r\n return Promise.reject();\r\n }\r\n return response.json();\r\n })\r\n .then((data) => {\r\n let index = 0;\r\n const formattedMessages = data.messages.map((message) => {\r\n const date = new Date(message.date);\r\n const day = date.toLocaleDateString();\r\n const time = date.toLocaleTimeString();\r\n index += 1;\r\n return {\r\n date: `${day} ${time}`,\r\n sender: message.sender,\r\n text: message.text,\r\n id: `message-${index}`,\r\n };\r\n });\r\n setMessages(formattedMessages);\r\n setMessageFetchFailed(false);\r\n })\r\n .catch((err) => {\r\n setMessageFetchFailed(true);\r\n /* eslint-disable no-console */\r\n console.error(err);\r\n });\r\n }\r\n }, [authState]);\r\n\r\n return messages\r\n}\r\n\r\nexport default useMessages"]},"metadata":{},"sourceType":"module"}
\ No newline at end of file
{"ast":null,"code":"var _s = $RefreshSig$();\n\nimport { useState, useEffect } from 'react';\nimport { useOktaAuth } from '@okta/okta-react';\nimport axios from 'axios';\nimport config from \"../config\";\n\nconst useMessages = () => {\n _s();\n\n const {\n authState,\n oktaAuth\n } = useOktaAuth();\n const [messages, setMessages] = useState(null);\n const [messageFetchFailed, setMessageFetchFailed] = useState(false); // fetch messages\n\n useEffect(() => {\n if (authState && authState.isAuthenticated) {\n const accessToken = oktaAuth.getAccessToken(); // fetch(config.serviceAPI.messagesUrl, {\n // headers: {\n // Authorization: `Bearer ${accessToken}`,\n // },\n // })\n\n axios({\n method: 'GET',\n url: config.serviceAPI.messagesUrl,\n headers: {\n Authorization: `Bearer ${accessToken}`\n }\n }).then(response => {\n if (!response.ok) {\n return Promise.reject();\n }\n\n return response.json();\n }).then(data => {\n let index = 0;\n const formattedMessages = data.messages.map(message => {\n const date = new Date(message.date);\n const day = date.toLocaleDateString();\n const time = date.toLocaleTimeString();\n index += 1;\n return {\n date: `${day} ${time}`,\n sender: message.sender,\n text: message.text,\n id: `message-${index}`\n };\n });\n setMessages(formattedMessages);\n setMessageFetchFailed(false);\n }).catch(err => {\n setMessageFetchFailed(true);\n /* eslint-disable no-console */\n\n console.error(err);\n });\n }\n }, [authState]);\n return messages;\n};\n\n_s(useMessages, \"U3xiPl25FsmufxeRxpFVBz8Cguw=\", false, function () {\n return [useOktaAuth];\n});\n\nexport default useMessages;","map":{"version":3,"sources":["C:/Users/Bruger/Desktop/Web-projects/pipit/client/src/util/useMessages.jsx"],"names":["useState","useEffect","useOktaAuth","axios","config","useMessages","authState","oktaAuth","messages","setMessages","messageFetchFailed","setMessageFetchFailed","isAuthenticated","accessToken","getAccessToken","method","url","serviceAPI","messagesUrl","headers","Authorization","then","response","ok","Promise","reject","json","data","index","formattedMessages","map","message","date","Date","day","toLocaleDateString","time","toLocaleTimeString","sender","text","id","catch","err","console","error"],"mappings":";;AAAA,SAASA,QAAT,EAAmBC,SAAnB,QAAoC,OAApC;AACA,SAASC,WAAT,QAA4B,kBAA5B;AACA,OAAOC,KAAP,MAAkB,OAAlB;AAEA,OAAOC,MAAP,MAAmB,WAAnB;;AAEA,MAAMC,WAAW,GAAG,MAAM;AAAA;;AACxB,QAAM;AAAEC,IAAAA,SAAF;AAAaC,IAAAA;AAAb,MAA0BL,WAAW,EAA3C;AACA,QAAM,CAACM,QAAD,EAAWC,WAAX,IAA0BT,QAAQ,CAAC,IAAD,CAAxC;AACA,QAAM,CAACU,kBAAD,EAAqBC,qBAArB,IAA8CX,QAAQ,CAAC,KAAD,CAA5D,CAHwB,CAKxB;;AACAC,EAAAA,SAAS,CAAC,MAAM;AACd,QAAIK,SAAS,IAAIA,SAAS,CAACM,eAA3B,EAA4C;AAC1C,YAAMC,WAAW,GAAGN,QAAQ,CAACO,cAAT,EAApB,CAD0C,CAE1C;AACA;AACA;AACA;AACA;;AACAX,MAAAA,KAAK,CAAC;AACJY,QAAAA,MAAM,EAAE,KADJ;AAEJC,QAAAA,GAAG,EAAEZ,MAAM,CAACa,UAAP,CAAkBC,WAFnB;AAGJC,QAAAA,OAAO,EAAE;AACPC,UAAAA,aAAa,EAAG,UAASP,WAAY;AAD9B;AAHL,OAAD,CAAL,CAOGQ,IAPH,CAOSC,QAAD,IAAc;AAClB,YAAI,CAACA,QAAQ,CAACC,EAAd,EAAkB;AAChB,iBAAOC,OAAO,CAACC,MAAR,EAAP;AACD;;AACD,eAAOH,QAAQ,CAACI,IAAT,EAAP;AACD,OAZH,EAaGL,IAbH,CAaSM,IAAD,IAAU;AACd,YAAIC,KAAK,GAAG,CAAZ;AACA,cAAMC,iBAAiB,GAAGF,IAAI,CAACnB,QAAL,CAAcsB,GAAd,CAAmBC,OAAD,IAAa;AACvD,gBAAMC,IAAI,GAAG,IAAIC,IAAJ,CAASF,OAAO,CAACC,IAAjB,CAAb;AACA,gBAAME,GAAG,GAAGF,IAAI,CAACG,kBAAL,EAAZ;AACA,gBAAMC,IAAI,GAAGJ,IAAI,CAACK,kBAAL,EAAb;AACAT,UAAAA,KAAK,IAAI,CAAT;AACA,iBAAO;AACLI,YAAAA,IAAI,EAAG,GAAEE,GAAI,IAAGE,IAAK,EADhB;AAELE,YAAAA,MAAM,EAAEP,OAAO,CAACO,MAFX;AAGLC,YAAAA,IAAI,EAAER,OAAO,CAACQ,IAHT;AAILC,YAAAA,EAAE,EAAG,WAAUZ,KAAM;AAJhB,WAAP;AAMD,SAXyB,CAA1B;AAYAnB,QAAAA,WAAW,CAACoB,iBAAD,CAAX;AACAlB,QAAAA,qBAAqB,CAAC,KAAD,CAArB;AACD,OA7BH,EA8BG8B,KA9BH,CA8BUC,GAAD,IAAS;AACd/B,QAAAA,qBAAqB,CAAC,IAAD,CAArB;AACA;;AACAgC,QAAAA,OAAO,CAACC,KAAR,CAAcF,GAAd;AACD,OAlCH;AAmCD;AACF,GA5CQ,EA4CN,CAACpC,SAAD,CA5CM,CAAT;AA8CA,SAAOE,QAAP;AACD,CArDD;;GAAMH,W;UAC4BH,W;;;AAsDlC,eAAeG,WAAf","sourcesContent":["import { useState, useEffect } from 'react';\r\nimport { useOktaAuth } from '@okta/okta-react';\r\nimport axios from 'axios'\r\n\r\nimport config from \"../config\"\r\n\r\nconst useMessages = () => {\r\n const { authState, oktaAuth } = useOktaAuth();\r\n const [messages, setMessages] = useState(null);\r\n const [messageFetchFailed, setMessageFetchFailed] = useState(false);\r\n\r\n // fetch messages\r\n useEffect(() => {\r\n if (authState && authState.isAuthenticated) {\r\n const accessToken = oktaAuth.getAccessToken();\r\n // fetch(config.serviceAPI.messagesUrl, {\r\n // headers: {\r\n // Authorization: `Bearer ${accessToken}`,\r\n // },\r\n // })\r\n axios({\r\n method: 'GET',\r\n url: config.serviceAPI.messagesUrl,\r\n headers: {\r\n Authorization: `Bearer ${accessToken}`\r\n }\r\n })\r\n .then((response) => {\r\n if (!response.ok) {\r\n return Promise.reject();\r\n }\r\n return response.json();\r\n })\r\n .then((data) => {\r\n let index = 0;\r\n const formattedMessages = data.messages.map((message) => {\r\n const date = new Date(message.date);\r\n const day = date.toLocaleDateString();\r\n const time = date.toLocaleTimeString();\r\n index += 1;\r\n return {\r\n date: `${day} ${time}`,\r\n sender: message.sender,\r\n text: message.text,\r\n id: `message-${index}`,\r\n };\r\n });\r\n setMessages(formattedMessages);\r\n setMessageFetchFailed(false);\r\n })\r\n .catch((err) => {\r\n setMessageFetchFailed(true);\r\n /* eslint-disable no-console */\r\n console.error(err);\r\n });\r\n }\r\n }, [authState]);\r\n\r\n return messages\r\n}\r\n\r\nexport default useMessages"]},"metadata":{},"sourceType":"module"}
\ No newline at end of file
{"ast":null,"code":"'use strict';\n/**\n * Update an Error with the specified config, error code, and response.\n *\n * @param {Error} error The error to update.\n * @param {Object} config The config.\n * @param {string} [code] The error code (for example, 'ECONNABORTED').\n * @param {Object} [request] The request.\n * @param {Object} [response] The response.\n * @returns {Error} The error.\n */\n\nmodule.exports = function enhanceError(error, config, code, request, response) {\n error.config = config;\n\n if (code) {\n error.code = code;\n }\n\n error.request = request;\n error.response = response;\n error.isAxiosError = true;\n\n error.toJSON = function toJSON() {\n return {\n // Standard\n message: this.message,\n name: this.name,\n // Microsoft\n description: this.description,\n number: this.number,\n // Mozilla\n fileName: this.fileName,\n lineNumber: this.lineNumber,\n columnNumber: this.columnNumber,\n stack: this.stack,\n // Axios\n config: this.config,\n code: this.code\n };\n };\n\n return error;\n};","map":{"version":3,"sources":["C:/Users/Bruger/Desktop/Web-projects/pipit/client/node_modules/axios/lib/core/enhanceError.js"],"names":["module","exports","enhanceError","error","config","code","request","response","isAxiosError","toJSON","message","name","description","number","fileName","lineNumber","columnNumber","stack"],"mappings":"AAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACAA,MAAM,CAACC,OAAP,GAAiB,SAASC,YAAT,CAAsBC,KAAtB,EAA6BC,MAA7B,EAAqCC,IAArC,EAA2CC,OAA3C,EAAoDC,QAApD,EAA8D;AAC7EJ,EAAAA,KAAK,CAACC,MAAN,GAAeA,MAAf;;AACA,MAAIC,IAAJ,EAAU;AACRF,IAAAA,KAAK,CAACE,IAAN,GAAaA,IAAb;AACD;;AAEDF,EAAAA,KAAK,CAACG,OAAN,GAAgBA,OAAhB;AACAH,EAAAA,KAAK,CAACI,QAAN,GAAiBA,QAAjB;AACAJ,EAAAA,KAAK,CAACK,YAAN,GAAqB,IAArB;;AAEAL,EAAAA,KAAK,CAACM,MAAN,GAAe,SAASA,MAAT,GAAkB;AAC/B,WAAO;AACL;AACAC,MAAAA,OAAO,EAAE,KAAKA,OAFT;AAGLC,MAAAA,IAAI,EAAE,KAAKA,IAHN;AAIL;AACAC,MAAAA,WAAW,EAAE,KAAKA,WALb;AAMLC,MAAAA,MAAM,EAAE,KAAKA,MANR;AAOL;AACAC,MAAAA,QAAQ,EAAE,KAAKA,QARV;AASLC,MAAAA,UAAU,EAAE,KAAKA,UATZ;AAULC,MAAAA,YAAY,EAAE,KAAKA,YAVd;AAWLC,MAAAA,KAAK,EAAE,KAAKA,KAXP;AAYL;AACAb,MAAAA,MAAM,EAAE,KAAKA,MAbR;AAcLC,MAAAA,IAAI,EAAE,KAAKA;AAdN,KAAP;AAgBD,GAjBD;;AAkBA,SAAOF,KAAP;AACD,CA7BD","sourcesContent":["'use strict';\n\n/**\n * Update an Error with the specified config, error code, and response.\n *\n * @param {Error} error The error to update.\n * @param {Object} config The config.\n * @param {string} [code] The error code (for example, 'ECONNABORTED').\n * @param {Object} [request] The request.\n * @param {Object} [response] The response.\n * @returns {Error} The error.\n */\nmodule.exports = function enhanceError(error, config, code, request, response) {\n error.config = config;\n if (code) {\n error.code = code;\n }\n\n error.request = request;\n error.response = response;\n error.isAxiosError = true;\n\n error.toJSON = function toJSON() {\n return {\n // Standard\n message: this.message,\n name: this.name,\n // Microsoft\n description: this.description,\n number: this.number,\n // Mozilla\n fileName: this.fileName,\n lineNumber: this.lineNumber,\n columnNumber: this.columnNumber,\n stack: this.stack,\n // Axios\n config: this.config,\n code: this.code\n };\n };\n return error;\n};\n"]},"metadata":{},"sourceType":"script"}
\ No newline at end of file
{"ast":null,"code":"var _s = $RefreshSig$();\n\nimport { useState, useEffect } from 'react';\nimport { useOktaAuth } from '@okta/okta-react';\nimport axios from 'axios';\nimport config from \"../config\";\n\nconst useMessages = () => {\n _s();\n\n const {\n authState,\n oktaAuth\n } = useOktaAuth();\n const [messages, setMessages] = useState(null);\n const [messageFetchFailed, setMessageFetchFailed] = useState(false); // fetch messages\n\n useEffect(() => {\n if (authState && authState.isAuthenticated) {\n const accessToken = oktaAuth.getAccessToken(); // fetch(config.serviceAPI.messagesUrl, {\n // headers: {\n // Authorization: `Bearer ${accessToken}`,\n // },\n // })\n\n axios.get(\"/api/messages\", {\n headers: {\n Authorization: `Bearer ${accessToken}`\n }\n }).then(response => {\n if (!response.ok) {\n return Promise.reject();\n }\n\n return response.json();\n }).then(data => {\n let index = 0;\n const formattedMessages = data.messages.map(message => {\n const date = new Date(message.date);\n const day = date.toLocaleDateString();\n const time = date.toLocaleTimeString();\n index += 1;\n return {\n date: `${day} ${time}`,\n sender: message.sender,\n text: message.text,\n id: `message-${index}`\n };\n });\n setMessages(formattedMessages);\n setMessageFetchFailed(false);\n }).catch(err => {\n setMessageFetchFailed(true);\n /* eslint-disable no-console */\n\n console.error(err);\n });\n }\n }, [authState]);\n return messages;\n};\n\n_s(useMessages, \"U3xiPl25FsmufxeRxpFVBz8Cguw=\", false, function () {\n return [useOktaAuth];\n});\n\nexport default useMessages;","map":{"version":3,"sources":["C:/Users/Bruger/Desktop/Web-projects/pipit/client/src/util/useMessages.jsx"],"names":["useState","useEffect","useOktaAuth","axios","config","useMessages","authState","oktaAuth","messages","setMessages","messageFetchFailed","setMessageFetchFailed","isAuthenticated","accessToken","getAccessToken","get","headers","Authorization","then","response","ok","Promise","reject","json","data","index","formattedMessages","map","message","date","Date","day","toLocaleDateString","time","toLocaleTimeString","sender","text","id","catch","err","console","error"],"mappings":";;AAAA,SAASA,QAAT,EAAmBC,SAAnB,QAAoC,OAApC;AACA,SAASC,WAAT,QAA4B,kBAA5B;AACA,OAAOC,KAAP,MAAkB,OAAlB;AAEA,OAAOC,MAAP,MAAmB,WAAnB;;AAEA,MAAMC,WAAW,GAAG,MAAM;AAAA;;AACxB,QAAM;AAAEC,IAAAA,SAAF;AAAaC,IAAAA;AAAb,MAA0BL,WAAW,EAA3C;AACA,QAAM,CAACM,QAAD,EAAWC,WAAX,IAA0BT,QAAQ,CAAC,IAAD,CAAxC;AACA,QAAM,CAACU,kBAAD,EAAqBC,qBAArB,IAA8CX,QAAQ,CAAC,KAAD,CAA5D,CAHwB,CAKxB;;AACAC,EAAAA,SAAS,CAAC,MAAM;AACd,QAAIK,SAAS,IAAIA,SAAS,CAACM,eAA3B,EAA4C;AAC1C,YAAMC,WAAW,GAAGN,QAAQ,CAACO,cAAT,EAApB,CAD0C,CAE1C;AACA;AACA;AACA;AACA;;AACAX,MAAAA,KAAK,CAACY,GAAN,CAAU,eAAV,EAA2B;AACzBC,QAAAA,OAAO,EAAE;AACPC,UAAAA,aAAa,EAAG,UAASJ,WAAY;AAD9B;AADgB,OAA3B,EAKGK,IALH,CAKSC,QAAD,IAAc;AAClB,YAAI,CAACA,QAAQ,CAACC,EAAd,EAAkB;AAChB,iBAAOC,OAAO,CAACC,MAAR,EAAP;AACD;;AACD,eAAOH,QAAQ,CAACI,IAAT,EAAP;AACD,OAVH,EAWGL,IAXH,CAWSM,IAAD,IAAU;AACd,YAAIC,KAAK,GAAG,CAAZ;AACA,cAAMC,iBAAiB,GAAGF,IAAI,CAAChB,QAAL,CAAcmB,GAAd,CAAmBC,OAAD,IAAa;AACvD,gBAAMC,IAAI,GAAG,IAAIC,IAAJ,CAASF,OAAO,CAACC,IAAjB,CAAb;AACA,gBAAME,GAAG,GAAGF,IAAI,CAACG,kBAAL,EAAZ;AACA,gBAAMC,IAAI,GAAGJ,IAAI,CAACK,kBAAL,EAAb;AACAT,UAAAA,KAAK,IAAI,CAAT;AACA,iBAAO;AACLI,YAAAA,IAAI,EAAG,GAAEE,GAAI,IAAGE,IAAK,EADhB;AAELE,YAAAA,MAAM,EAAEP,OAAO,CAACO,MAFX;AAGLC,YAAAA,IAAI,EAAER,OAAO,CAACQ,IAHT;AAILC,YAAAA,EAAE,EAAG,WAAUZ,KAAM;AAJhB,WAAP;AAMD,SAXyB,CAA1B;AAYAhB,QAAAA,WAAW,CAACiB,iBAAD,CAAX;AACAf,QAAAA,qBAAqB,CAAC,KAAD,CAArB;AACD,OA3BH,EA4BG2B,KA5BH,CA4BUC,GAAD,IAAS;AACd5B,QAAAA,qBAAqB,CAAC,IAAD,CAArB;AACA;;AACA6B,QAAAA,OAAO,CAACC,KAAR,CAAcF,GAAd;AACD,OAhCH;AAiCD;AACF,GA1CQ,EA0CN,CAACjC,SAAD,CA1CM,CAAT;AA4CA,SAAOE,QAAP;AACD,CAnDD;;GAAMH,W;UAC4BH,W;;;AAoDlC,eAAeG,WAAf","sourcesContent":["import { useState, useEffect } from 'react';\r\nimport { useOktaAuth } from '@okta/okta-react';\r\nimport axios from 'axios'\r\n\r\nimport config from \"../config\"\r\n\r\nconst useMessages = () => {\r\n const { authState, oktaAuth } = useOktaAuth();\r\n const [messages, setMessages] = useState(null);\r\n const [messageFetchFailed, setMessageFetchFailed] = useState(false);\r\n\r\n // fetch messages\r\n useEffect(() => {\r\n if (authState && authState.isAuthenticated) {\r\n const accessToken = oktaAuth.getAccessToken();\r\n // fetch(config.serviceAPI.messagesUrl, {\r\n // headers: {\r\n // Authorization: `Bearer ${accessToken}`,\r\n // },\r\n // })\r\n axios.get(\"/api/messages\", {\r\n headers: {\r\n Authorization: `Bearer ${accessToken}`,\r\n },\r\n })\r\n .then((response) => {\r\n if (!response.ok) {\r\n return Promise.reject();\r\n }\r\n return response.json();\r\n })\r\n .then((data) => {\r\n let index = 0;\r\n const formattedMessages = data.messages.map((message) => {\r\n const date = new Date(message.date);\r\n const day = date.toLocaleDateString();\r\n const time = date.toLocaleTimeString();\r\n index += 1;\r\n return {\r\n date: `${day} ${time}`,\r\n sender: message.sender,\r\n text: message.text,\r\n id: `message-${index}`,\r\n };\r\n });\r\n setMessages(formattedMessages);\r\n setMessageFetchFailed(false);\r\n })\r\n .catch((err) => {\r\n setMessageFetchFailed(true);\r\n /* eslint-disable no-console */\r\n console.error(err);\r\n });\r\n }\r\n }, [authState]);\r\n\r\n return messages\r\n}\r\n\r\nexport default useMessages"]},"metadata":{},"sourceType":"module"}
\ No newline at end of file
{"ast":null,"code":"'use strict';\n\nvar enhanceError = require('./enhanceError');\n/**\n * Create an Error with the specified message, config, error code, request and response.\n *\n * @param {string} message The error message.\n * @param {Object} config The config.\n * @param {string} [code] The error code (for example, 'ECONNABORTED').\n * @param {Object} [request] The request.\n * @param {Object} [response] The response.\n * @returns {Error} The created error.\n */\n\n\nmodule.exports = function createError(message, config, code, request, response) {\n var error = new Error(message);\n return enhanceError(error, config, code, request, response);\n};","map":{"version":3,"sources":["C:/Users/Bruger/Desktop/Web-projects/pipit/client/node_modules/axios/lib/core/createError.js"],"names":["enhanceError","require","module","exports","createError","message","config","code","request","response","error","Error"],"mappings":"AAAA;;AAEA,IAAIA,YAAY,GAAGC,OAAO,CAAC,gBAAD,CAA1B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACAC,MAAM,CAACC,OAAP,GAAiB,SAASC,WAAT,CAAqBC,OAArB,EAA8BC,MAA9B,EAAsCC,IAAtC,EAA4CC,OAA5C,EAAqDC,QAArD,EAA+D;AAC9E,MAAIC,KAAK,GAAG,IAAIC,KAAJ,CAAUN,OAAV,CAAZ;AACA,SAAOL,YAAY,CAACU,KAAD,EAAQJ,MAAR,EAAgBC,IAAhB,EAAsBC,OAAtB,EAA+BC,QAA/B,CAAnB;AACD,CAHD","sourcesContent":["'use strict';\n\nvar enhanceError = require('./enhanceError');\n\n/**\n * Create an Error with the specified message, config, error code, request and response.\n *\n * @param {string} message The error message.\n * @param {Object} config The config.\n * @param {string} [code] The error code (for example, 'ECONNABORTED').\n * @param {Object} [request] The request.\n * @param {Object} [response] The response.\n * @returns {Error} The created error.\n */\nmodule.exports = function createError(message, config, code, request, response) {\n var error = new Error(message);\n return enhanceError(error, config, code, request, response);\n};\n"]},"metadata":{},"sourceType":"script"}
\ No newline at end of file
{"ast":null,"code":"var _s = $RefreshSig$();\n\nimport { useState, useEffect } from 'react';\nimport { useOktaAuth } from '@okta/okta-react';\nimport axios from 'axios';\nimport config from \"../config\";\n\nconst useMessages = () => {\n _s();\n\n const {\n authState,\n oktaAuth\n } = useOktaAuth();\n const [messages, setMessages] = useState(null);\n const [messageFetchFailed, setMessageFetchFailed] = useState(false); // fetch messages\n\n useEffect(() => {\n if (authState && authState.isAuthenticated) {\n const accessToken = oktaAuth.getAccessToken(); // fetch(/api/messages, {\n // headers: {\n // Authorization: `Bearer ${accessToken}`,\n // },\n // })\n\n axios.get(\"/api/messages\", {\n headers: {\n Authorization: `Bearer ${accessToken}`\n }\n }).then(response => {\n if (!response.ok) {\n return Promise.reject();\n }\n\n return response.json();\n }).then(data => {\n let index = 0;\n const formattedMessages = data.messages.map(message => {\n const date = new Date(message.date);\n const day = date.toLocaleDateString();\n const time = date.toLocaleTimeString();\n index += 1;\n return {\n date: `${day} ${time}`,\n sender: message.sender,\n text: message.text,\n id: `message-${index}`\n };\n });\n setMessages(formattedMessages);\n setMessageFetchFailed(false);\n }).catch(err => {\n setMessageFetchFailed(true);\n /* eslint-disable no-console */\n\n console.error(err);\n });\n }\n }, [authState]);\n return messages;\n};\n\n_s(useMessages, \"U3xiPl25FsmufxeRxpFVBz8Cguw=\", false, function () {\n return [useOktaAuth];\n});\n\nexport default useMessages;","map":{"version":3,"sources":["C:/Users/Bruger/Desktop/Web-projects/pipit/client/src/util/useMessages.jsx"],"names":["useState","useEffect","useOktaAuth","axios","config","useMessages","authState","oktaAuth","messages","setMessages","messageFetchFailed","setMessageFetchFailed","isAuthenticated","accessToken","getAccessToken","get","headers","Authorization","then","response","ok","Promise","reject","json","data","index","formattedMessages","map","message","date","Date","day","toLocaleDateString","time","toLocaleTimeString","sender","text","id","catch","err","console","error"],"mappings":";;AAAA,SAASA,QAAT,EAAmBC,SAAnB,QAAoC,OAApC;AACA,SAASC,WAAT,QAA4B,kBAA5B;AACA,OAAOC,KAAP,MAAkB,OAAlB;AAEA,OAAOC,MAAP,MAAmB,WAAnB;;AAEA,MAAMC,WAAW,GAAG,MAAM;AAAA;;AACxB,QAAM;AAAEC,IAAAA,SAAF;AAAaC,IAAAA;AAAb,MAA0BL,WAAW,EAA3C;AACA,QAAM,CAACM,QAAD,EAAWC,WAAX,IAA0BT,QAAQ,CAAC,IAAD,CAAxC;AACA,QAAM,CAACU,kBAAD,EAAqBC,qBAArB,IAA8CX,QAAQ,CAAC,KAAD,CAA5D,CAHwB,CAKxB;;AACAC,EAAAA,SAAS,CAAC,MAAM;AACd,QAAIK,SAAS,IAAIA,SAAS,CAACM,eAA3B,EAA4C;AAC1C,YAAMC,WAAW,GAAGN,QAAQ,CAACO,cAAT,EAApB,CAD0C,CAE1C;AACA;AACA;AACA;AACA;;AACAX,MAAAA,KAAK,CAACY,GAAN,CAAU,eAAV,EAA2B;AACzBC,QAAAA,OAAO,EAAE;AACPC,UAAAA,aAAa,EAAG,UAASJ,WAAY;AAD9B;AADgB,OAA3B,EAKGK,IALH,CAKSC,QAAD,IAAc;AAClB,YAAI,CAACA,QAAQ,CAACC,EAAd,EAAkB;AAChB,iBAAOC,OAAO,CAACC,MAAR,EAAP;AACD;;AACD,eAAOH,QAAQ,CAACI,IAAT,EAAP;AACD,OAVH,EAWGL,IAXH,CAWSM,IAAD,IAAU;AACd,YAAIC,KAAK,GAAG,CAAZ;AACA,cAAMC,iBAAiB,GAAGF,IAAI,CAAChB,QAAL,CAAcmB,GAAd,CAAmBC,OAAD,IAAa;AACvD,gBAAMC,IAAI,GAAG,IAAIC,IAAJ,CAASF,OAAO,CAACC,IAAjB,CAAb;AACA,gBAAME,GAAG,GAAGF,IAAI,CAACG,kBAAL,EAAZ;AACA,gBAAMC,IAAI,GAAGJ,IAAI,CAACK,kBAAL,EAAb;AACAT,UAAAA,KAAK,IAAI,CAAT;AACA,iBAAO;AACLI,YAAAA,IAAI,EAAG,GAAEE,GAAI,IAAGE,IAAK,EADhB;AAELE,YAAAA,MAAM,EAAEP,OAAO,CAACO,MAFX;AAGLC,YAAAA,IAAI,EAAER,OAAO,CAACQ,IAHT;AAILC,YAAAA,EAAE,EAAG,WAAUZ,KAAM;AAJhB,WAAP;AAMD,SAXyB,CAA1B;AAYAhB,QAAAA,WAAW,CAACiB,iBAAD,CAAX;AACAf,QAAAA,qBAAqB,CAAC,KAAD,CAArB;AACD,OA3BH,EA4BG2B,KA5BH,CA4BUC,GAAD,IAAS;AACd5B,QAAAA,qBAAqB,CAAC,IAAD,CAArB;AACA;;AACA6B,QAAAA,OAAO,CAACC,KAAR,CAAcF,GAAd;AACD,OAhCH;AAiCD;AACF,GA1CQ,EA0CN,CAACjC,SAAD,CA1CM,CAAT;AA4CA,SAAOE,QAAP;AACD,CAnDD;;GAAMH,W;UAC4BH,W;;;AAoDlC,eAAeG,WAAf","sourcesContent":["import { useState, useEffect } from 'react';\r\nimport { useOktaAuth } from '@okta/okta-react';\r\nimport axios from 'axios'\r\n\r\nimport config from \"../config\"\r\n\r\nconst useMessages = () => {\r\n const { authState, oktaAuth } = useOktaAuth();\r\n const [messages, setMessages] = useState(null);\r\n const [messageFetchFailed, setMessageFetchFailed] = useState(false);\r\n\r\n // fetch messages\r\n useEffect(() => {\r\n if (authState && authState.isAuthenticated) {\r\n const accessToken = oktaAuth.getAccessToken();\r\n // fetch(/api/messages, {\r\n // headers: {\r\n // Authorization: `Bearer ${accessToken}`,\r\n // },\r\n // })\r\n axios.get(\"/api/messages\", {\r\n headers: {\r\n Authorization: `Bearer ${accessToken}`,\r\n },\r\n })\r\n .then((response) => {\r\n if (!response.ok) {\r\n return Promise.reject();\r\n }\r\n return response.json();\r\n })\r\n .then((data) => {\r\n let index = 0;\r\n const formattedMessages = data.messages.map((message) => {\r\n const date = new Date(message.date);\r\n const day = date.toLocaleDateString();\r\n const time = date.toLocaleTimeString();\r\n index += 1;\r\n return {\r\n date: `${day} ${time}`,\r\n sender: message.sender,\r\n text: message.text,\r\n id: `message-${index}`,\r\n };\r\n });\r\n setMessages(formattedMessages);\r\n setMessageFetchFailed(false);\r\n })\r\n .catch((err) => {\r\n setMessageFetchFailed(true);\r\n /* eslint-disable no-console */\r\n console.error(err);\r\n });\r\n }\r\n }, [authState]);\r\n\r\n return messages\r\n}\r\n\r\nexport default useMessages"]},"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