GoScrobble/web/node_modules/.cache/babel-loader/496e0bdf70e361bf4a605e6722f462d0.json

1 line
33 KiB
JSON

{"ast":null,"code":"var _jsxFileName = \"/app/src/Pages/User.js\",\n _s = $RefreshSig$();\n\nimport React, { useContext, useState, useEffect } from 'react';\nimport '../App.css';\nimport './User.css';\nimport { useHistory } from \"react-router\";\nimport AuthContext from '../Contexts/AuthContext';\nimport ScaleLoader from 'react-spinners/ScaleLoader';\nimport { Button } from 'reactstrap';\nimport { Formik, Form, Field } from 'formik';\nimport { confirmAlert } from 'react-confirm-alert';\nimport 'react-confirm-alert/src/react-confirm-alert.css';\nimport { getUser, patchUser, spotifyConnectionRequest, spotifyDisonnectionRequest, navidromeDisonnectionRequest, navidromeConnectionRequest } from '../Api/index';\nimport TimezoneSelect from 'react-timezone-select';\nimport { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\n\nconst User = () => {\n _s();\n\n const history = useHistory();\n const {\n user,\n Logout\n } = useContext(AuthContext);\n const [loading, setLoading] = useState(true);\n const [userdata, setUserdata] = useState({});\n\n const updateTimezone = vals => {\n setUserdata({ ...userdata,\n timezone: vals\n });\n patchUser({\n timezone: vals.value\n });\n };\n\n const resetTokenPopup = () => {\n confirmAlert({\n title: 'Reset token',\n message: 'Resetting your token will require you to update your Jellyfin server / custom scroblers with the new token. Continue?',\n buttons: [{\n label: 'Reset',\n onClick: () => resetToken()\n }, {\n label: 'No'\n }]\n });\n };\n\n const deleteAccountPopup = () => {\n confirmAlert({\n title: 'Delete Account',\n message: 'This will disable your account and queue it for deletion. Are you sure?',\n buttons: [{\n label: 'Yes',\n onClick: () => deleteAccount()\n }, {\n label: 'No'\n }]\n });\n };\n\n const connectNavidromePopup = () => {\n confirmAlert({\n title: 'Connect Navidrome',\n buttons: [{\n label: 'Close'\n }],\n childrenElement: () => /*#__PURE__*/_jsxDEV(Formik, {\n initialValues: {\n url: '',\n username: '',\n password: ''\n },\n onSubmit: values => navidromeConnectionRequest(values),\n children: /*#__PURE__*/_jsxDEV(Form, {\n children: [/*#__PURE__*/_jsxDEV(\"label\", {\n children: [\"Server URL\", /*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 78,\n columnNumber: 23\n }, this), /*#__PURE__*/_jsxDEV(Field, {\n name: \"url\",\n type: \"text\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 79,\n columnNumber: 13\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 77,\n columnNumber: 11\n }, this), /*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 84,\n columnNumber: 11\n }, this), /*#__PURE__*/_jsxDEV(\"label\", {\n children: [\"Username\", /*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 86,\n columnNumber: 21\n }, this), /*#__PURE__*/_jsxDEV(Field, {\n name: \"username\",\n type: \"text\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 87,\n columnNumber: 13\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 85,\n columnNumber: 11\n }, this), /*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 92,\n columnNumber: 11\n }, this), /*#__PURE__*/_jsxDEV(\"label\", {\n children: [\"Password\", /*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 94,\n columnNumber: 21\n }, this), /*#__PURE__*/_jsxDEV(Field, {\n name: \"password\",\n type: \"password\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 95,\n columnNumber: 13\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 93,\n columnNumber: 11\n }, this), /*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 100,\n columnNumber: 11\n }, this), /*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 100,\n columnNumber: 16\n }, this), /*#__PURE__*/_jsxDEV(Button, {\n color: \"primary\",\n type: \"submit\",\n className: \"loginButton\",\n children: \"Connect\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 101,\n columnNumber: 11\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 76,\n columnNumber: 11\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 72,\n columnNumber: 31\n }, this)\n });\n };\n\n const disconnectNavidromePopup = () => {\n confirmAlert({\n title: 'Disconnect Navidrome',\n message: 'Are you sure you want to disconnect your Navidrome connection?',\n buttons: [{\n label: 'Disconnect',\n onClick: () => navidromeDisonnectionRequest()\n }, {\n label: 'No'\n }]\n });\n };\n\n const disconnectSpotifyPopup = () => {\n confirmAlert({\n title: 'Disconnect Spotify',\n message: 'Are you sure you want to disconnect your Spotify account?',\n buttons: [{\n label: 'Disconnect',\n onClick: () => spotifyDisonnectionRequest()\n }, {\n label: 'No'\n }]\n });\n };\n\n const connectJellyfinPopup = () => {\n confirmAlert({\n title: 'Connect Jellyfin',\n message: 'Install the webhook plugin. Add a webhook to ' + process.env.REACT_APP_API_URL + '/api/v1/ingress/jellyfin?key=' + userdata.token + '\\nSet it to only send \"Playback Start\" and \"Songs/Albums\"',\n buttons: [{\n label: 'Close'\n }]\n });\n };\n\n const connectOtherPopup = () => {\n confirmAlert({\n title: 'Connect Jellyfin',\n message: 'Endpoint: ' + process.env.REACT_APP_API_URL + '/api/v1/ingress/multiscrobbler?key=' + userdata.token + '\\nNeed to send JSON body with a string array for artists names, album:string, track:string, playDate:timestamp of scrobble, duration:tracklength in seconds',\n buttons: [{\n label: 'Close'\n }]\n });\n };\n\n const resetToken = () => {\n setLoading(true);\n patchUser({\n token: ''\n }).then(() => {\n getUser().then(data => {\n setUserdata(data);\n setLoading(false);\n });\n });\n };\n\n const deleteAccount = () => {\n setLoading(true);\n patchUser({\n active: 0\n }).then(() => {\n getUser().then(data => {\n setUserdata(data);\n Logout();\n });\n });\n };\n\n useEffect(() => {\n if (!user) {\n return;\n }\n\n getUser().then(data => {\n setUserdata(data);\n setLoading(false);\n });\n }, [user]);\n\n if (!user) {\n history.push(\"/login\");\n }\n\n if (loading) {\n return /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"pageWrapper\",\n children: /*#__PURE__*/_jsxDEV(ScaleLoader, {\n color: \"#6AD7E5\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 212,\n columnNumber: 9\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 211,\n columnNumber: 7\n }, this);\n }\n\n return /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"pageWrapper\",\n children: [/*#__PURE__*/_jsxDEV(\"h1\", {\n children: [\"Welcome \", userdata.username]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 219,\n columnNumber: 7\n }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n style: {\n display: `flex`,\n flexWrap: `wrap`,\n textAlign: `center`\n },\n children: [/*#__PURE__*/_jsxDEV(\"div\", {\n style: {\n width: `300px`,\n padding: `0 10px 10px 10px`,\n textAlign: `left`\n },\n children: [/*#__PURE__*/_jsxDEV(\"h3\", {\n style: {\n textAlign: `center`\n },\n children: \"Profile\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 224,\n columnNumber: 11\n }, this), \"Timezone\", /*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 225,\n columnNumber: 19\n }, this), /*#__PURE__*/_jsxDEV(TimezoneSelect, {\n className: \"userDropdown\",\n value: userdata.timezone,\n onChange: updateTimezone\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 226,\n columnNumber: 11\n }, this), /*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 230,\n columnNumber: 13\n }, this), \"Created At:\", /*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 231,\n columnNumber: 22\n }, this), userdata.created_at, /*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 231,\n columnNumber: 48\n }, this), \"Email:\", /*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 232,\n columnNumber: 17\n }, this), userdata.email, /*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 232,\n columnNumber: 38\n }, this), \"Verified: \", userdata.verified ? '✓' : '✖']\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 223,\n columnNumber: 9\n }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n style: {\n width: `300px`,\n padding: `0 10px 10px 10px`\n },\n children: [/*#__PURE__*/_jsxDEV(\"h3\", {\n children: \"Scrobblers\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 236,\n columnNumber: 11\n }, this), /*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 237,\n columnNumber: 11\n }, this), userdata.spotify_username ? /*#__PURE__*/_jsxDEV(\"div\", {\n children: /*#__PURE__*/_jsxDEV(Button, {\n color: \"secondary\",\n type: \"button\",\n className: \"userButton\",\n onClick: disconnectSpotifyPopup,\n children: [\"Disconnect Spotify (\", userdata.spotify_username, \")\"]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 240,\n columnNumber: 15\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 239,\n columnNumber: 13\n }, this) : /*#__PURE__*/_jsxDEV(\"div\", {\n children: /*#__PURE__*/_jsxDEV(Button, {\n color: \"primary\",\n type: \"button\",\n className: \"userButton\",\n onClick: spotifyConnectionRequest,\n children: \"Connect To Spotify\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 248,\n columnNumber: 15\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 247,\n columnNumber: 13\n }, this), /*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 256,\n columnNumber: 11\n }, this), userdata.navidrome_server ? /*#__PURE__*/_jsxDEV(Button, {\n color: \"secondary\",\n type: \"button\",\n className: \"userButton\",\n onClick: disconnectNavidromePopup,\n children: [\"Disconnect Navidrome (\", userdata.navidrome_server, \")\"]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 258,\n columnNumber: 15\n }, this) : /*#__PURE__*/_jsxDEV(Button, {\n color: \"primary\",\n type: \"button\",\n className: \"userButton\",\n onClick: connectNavidromePopup,\n children: \"Connect Navidrome\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 264,\n columnNumber: 15\n }, this), /*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 271,\n columnNumber: 11\n }, this), /*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 271,\n columnNumber: 16\n }, this), /*#__PURE__*/_jsxDEV(Button, {\n color: \"primary\",\n type: \"button\",\n className: \"userButton\",\n onClick: connectJellyfinPopup,\n children: \"Connect Jellyfin\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 272,\n columnNumber: 11\n }, this), /*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 278,\n columnNumber: 11\n }, this), /*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 278,\n columnNumber: 16\n }, this), /*#__PURE__*/_jsxDEV(Button, {\n color: \"primary\",\n type: \"button\",\n className: \"userButton\",\n onClick: connectOtherPopup,\n children: \"Other Scrobblers\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 279,\n columnNumber: 11\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 235,\n columnNumber: 9\n }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n style: {\n width: `300px`,\n padding: `0 10px 10px 10px`\n },\n children: [/*#__PURE__*/_jsxDEV(\"h3\", {\n children: \"Sad Settings\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 287,\n columnNumber: 11\n }, this), /*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 288,\n columnNumber: 11\n }, this), /*#__PURE__*/_jsxDEV(Button, {\n color: \"secondary\",\n type: \"button\",\n className: \"userButton\",\n onClick: deleteAccountPopup,\n children: \"Disable Account\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 289,\n columnNumber: 11\n }, this), /*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 295,\n columnNumber: 11\n }, this), /*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 295,\n columnNumber: 16\n }, this), /*#__PURE__*/_jsxDEV(Button, {\n color: \"secondary\",\n type: \"button\",\n className: \"userButton\",\n onClick: resetTokenPopup,\n children: \"Reset Scrobbler Token\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 296,\n columnNumber: 11\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 286,\n columnNumber: 9\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 222,\n columnNumber: 7\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 218,\n columnNumber: 5\n }, this);\n};\n\n_s(User, \"iSvL8y2oEVGzg3XWqdOOsxUVohY=\", false, function () {\n return [useHistory];\n});\n\n_c = User;\nexport default User;\n\nvar _c;\n\n$RefreshReg$(_c, \"User\");","map":{"version":3,"sources":["/app/src/Pages/User.js"],"names":["React","useContext","useState","useEffect","useHistory","AuthContext","ScaleLoader","Button","Formik","Form","Field","confirmAlert","getUser","patchUser","spotifyConnectionRequest","spotifyDisonnectionRequest","navidromeDisonnectionRequest","navidromeConnectionRequest","TimezoneSelect","User","history","user","Logout","loading","setLoading","userdata","setUserdata","updateTimezone","vals","timezone","value","resetTokenPopup","title","message","buttons","label","onClick","resetToken","deleteAccountPopup","deleteAccount","connectNavidromePopup","childrenElement","url","username","password","values","disconnectNavidromePopup","disconnectSpotifyPopup","connectJellyfinPopup","process","env","REACT_APP_API_URL","token","connectOtherPopup","then","data","active","push","display","flexWrap","textAlign","width","padding","created_at","email","verified","spotify_username","navidrome_server"],"mappings":";;;AAAA,OAAOA,KAAP,IAAgBC,UAAhB,EAA4BC,QAA5B,EAAsCC,SAAtC,QAAuD,OAAvD;AACA,OAAO,YAAP;AACA,OAAO,YAAP;AACA,SAASC,UAAT,QAA2B,cAA3B;AACA,OAAOC,WAAP,MAAwB,yBAAxB;AACA,OAAOC,WAAP,MAAwB,4BAAxB;AACA,SAASC,MAAT,QAAuB,YAAvB;AACA,SAASC,MAAT,EAAiBC,IAAjB,EAAuBC,KAAvB,QAAoC,QAApC;AACA,SAASC,YAAT,QAA6B,qBAA7B;AACA,OAAO,iDAAP;AACA,SACEC,OADF,EAEEC,SAFF,EAGEC,wBAHF,EAIEC,0BAJF,EAKEC,4BALF,EAMEC,0BANF,QAOO,cAPP;AAQA,OAAOC,cAAP,MAA2B,uBAA3B;;;AAEA,MAAMC,IAAI,GAAG,MAAM;AAAA;;AACjB,QAAMC,OAAO,GAAGhB,UAAU,EAA1B;AACA,QAAM;AAAEiB,IAAAA,IAAF;AAAQC,IAAAA;AAAR,MAAmBrB,UAAU,CAACI,WAAD,CAAnC;AACA,QAAM,CAACkB,OAAD,EAAUC,UAAV,IAAwBtB,QAAQ,CAAC,IAAD,CAAtC;AACA,QAAM,CAACuB,QAAD,EAAWC,WAAX,IAA0BxB,QAAQ,CAAC,EAAD,CAAxC;;AAEA,QAAMyB,cAAc,GAAIC,I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AAA,SAAS,EAAC,YAHZ;AAIE,UAAA,OAAO,EAAEK,iBAJX;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBA5CF;AAAA;AAAA;AAAA;AAAA;AAAA,cAbF,eAgEE;AAAK,QAAA,KAAK,EAAE;AAACQ,UAAAA,KAAK,EAAG,OAAT;AAAiBC,UAAAA,OAAO,EAAG;AAA3B,SAAZ;AAAA,gCACE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBADF,eAEE;AAAA;AAAA;AAAA;AAAA,gBAFF,eAGE,QAAC,MAAD;AACE,UAAA,KAAK,EAAC,WADR;AAEE,UAAA,IAAI,EAAC,QAFP;AAGE,UAAA,SAAS,EAAC,YAHZ;AAIE,UAAA,OAAO,EAAExB,kBAJX;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAHF,eASE;AAAA;AAAA;AAAA;AAAA,gBATF,eASO;AAAA;AAAA;AAAA;AAAA,gBATP,eAUE,QAAC,MAAD;AACE,UAAA,KAAK,EAAC,WADR;AAEE,UAAA,IAAI,EAAC,QAFP;AAGE,UAAA,SAAS,EAAC,YAHZ;AAIE,UAAA,OAAO,EAAEP,eAJX;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAVF;AAAA;AAAA;AAAA;AAAA;AAAA,cAhEF;AAAA;AAAA;AAAA;AAAA;AAAA,YAJF;AAAA;AAAA;AAAA;AAAA;AAAA,UADF;AAyFD,CA7RD;;GAAMZ,I;UACYf,U;;;KADZe,I;AA+RN,eAAeA,IAAf","sourcesContent":["import React, { useContext, useState, useEffect } from 'react';\nimport '../App.css';\nimport './User.css';\nimport { useHistory } from \"react-router\";\nimport AuthContext from '../Contexts/AuthContext';\nimport ScaleLoader from 'react-spinners/ScaleLoader';\nimport { Button } from 'reactstrap';\nimport { Formik, Form, Field } from 'formik';\nimport { confirmAlert } from 'react-confirm-alert';\nimport 'react-confirm-alert/src/react-confirm-alert.css';\nimport {\n getUser,\n patchUser,\n spotifyConnectionRequest,\n spotifyDisonnectionRequest,\n navidromeDisonnectionRequest,\n navidromeConnectionRequest,\n} from '../Api/index'\nimport TimezoneSelect from 'react-timezone-select'\n\nconst User = () => {\n const history = useHistory();\n const { user, Logout } = useContext(AuthContext);\n const [loading, setLoading] = useState(true);\n const [userdata, setUserdata] = useState({});\n\n const updateTimezone = (vals) => {\n setUserdata({...userdata, timezone: vals});\n patchUser({timezone: vals.value})\n }\n\n const resetTokenPopup = () => {\n confirmAlert({\n title: 'Reset token',\n message: 'Resetting your token will require you to update your Jellyfin server / custom scroblers with the new token. Continue?',\n buttons: [\n {\n label: 'Reset',\n onClick: () => resetToken()\n },\n {\n label: 'No',\n }\n ]\n });\n };\n\n const deleteAccountPopup = () => {\n confirmAlert({\n title: 'Delete Account',\n message: 'This will disable your account and queue it for deletion. Are you sure?',\n buttons: [\n {\n label: 'Yes',\n onClick: () => deleteAccount()\n },\n {\n label: 'No',\n }\n ]\n });\n };\n\n const connectNavidromePopup = () => {\n confirmAlert({\n title: 'Connect Navidrome',\n buttons: [\n {\n label: 'Close',\n }\n ],\n childrenElement: () => <Formik\n initialValues={{ url: '', username: '', password: '' }}\n onSubmit={values => navidromeConnectionRequest(values)}\n >\n <Form>\n <label>\n Server URL<br/>\n <Field\n name=\"url\"\n type=\"text\"\n />\n </label>\n <br/>\n <label>\n Username<br/>\n <Field\n name=\"username\"\n type=\"text\"\n />\n </label>\n <br/>\n <label>\n Password<br/>\n <Field\n name=\"password\"\n type=\"password\"\n />\n </label>\n <br/><br/>\n <Button\n color=\"primary\"\n type=\"submit\"\n className=\"loginButton\"\n >Connect</Button>\n </Form>\n </Formik>,\n });\n };\n\n const disconnectNavidromePopup = () => {\n confirmAlert({\n title: 'Disconnect Navidrome',\n message: 'Are you sure you want to disconnect your Navidrome connection?',\n buttons: [\n {\n label: 'Disconnect',\n onClick: () => navidromeDisonnectionRequest()\n },\n {\n label: 'No',\n }\n ]\n });\n };\n\n const disconnectSpotifyPopup = () => {\n confirmAlert({\n title: 'Disconnect Spotify',\n message: 'Are you sure you want to disconnect your Spotify account?',\n buttons: [\n {\n label: 'Disconnect',\n onClick: () => spotifyDisonnectionRequest()\n },\n {\n label: 'No',\n }\n ]\n });\n };\n\n const connectJellyfinPopup = () => {\n confirmAlert({\n title: 'Connect Jellyfin',\n message: 'Install the webhook plugin. Add a webhook to ' + process.env.REACT_APP_API_URL + '/api/v1/ingress/jellyfin?key='+userdata.token\n +'\\nSet it to only send \"Playback Start\" and \"Songs/Albums\"',\n buttons: [\n {\n label: 'Close',\n }\n ]\n });\n }\n\n const connectOtherPopup = () => {\n confirmAlert({\n title: 'Connect Jellyfin',\n message: 'Endpoint: ' + process.env.REACT_APP_API_URL + '/api/v1/ingress/multiscrobbler?key='+userdata.token\n +'\\nNeed to send JSON body with a string array for artists names, album:string, track:string, playDate:timestamp of scrobble, duration:tracklength in seconds',\n buttons: [\n {\n label: 'Close',\n }\n ]\n });\n }\n\n const resetToken = () => {\n setLoading(true);\n patchUser({ token: '' })\n .then(() => {\n getUser()\n .then(data => {\n setUserdata(data);\n setLoading(false);\n })\n })\n }\n\n const deleteAccount = () => {\n setLoading(true);\n patchUser({ active: 0 })\n .then(() => {\n getUser()\n .then(data => {\n setUserdata(data);\n Logout();\n })\n })\n }\n\n useEffect(() => {\n if (!user) {\n return\n }\n\n getUser()\n .then(data => {\n setUserdata(data);\n setLoading(false);\n })\n }, [user])\n\n if (!user) {\n history.push(\"/login\")\n }\n\n if (loading) {\n return (\n <div className=\"pageWrapper\">\n <ScaleLoader color=\"#6AD7E5\" />\n </div>\n )\n }\n\n return (\n <div className=\"pageWrapper\">\n <h1>\n Welcome {userdata.username}\n </h1>\n <div style={{display: `flex`, flexWrap: `wrap`, textAlign: `center`}}>\n <div style={{width: `300px`, padding: `0 10px 10px 10px`, textAlign: `left`}}>\n <h3 style={{textAlign: `center`}}>Profile</h3>\n Timezone<br/>\n <TimezoneSelect\n className=\"userDropdown\"\n value={userdata.timezone}\n onChange={updateTimezone}\n /><br/>\n Created At:<br/>{userdata.created_at}<br/>\n Email:<br/>{userdata.email}<br/>\n Verified: {userdata.verified ? '✓' : '✖'}\n </div>\n <div style={{width: `300px`, padding: `0 10px 10px 10px`}}>\n <h3>Scrobblers</h3>\n <br/>\n {userdata.spotify_username\n ? <div>\n <Button\n color=\"secondary\"\n type=\"button\"\n className=\"userButton\"\n onClick={disconnectSpotifyPopup}\n >Disconnect Spotify ({userdata.spotify_username})</Button>\n </div>\n : <div>\n <Button\n color=\"primary\"\n type=\"button\"\n className=\"userButton\"\n onClick={spotifyConnectionRequest}\n >Connect To Spotify</Button>\n </div>\n }\n <br/>\n {userdata.navidrome_server\n ? <Button\n color=\"secondary\"\n type=\"button\"\n className=\"userButton\"\n onClick={disconnectNavidromePopup}\n >Disconnect Navidrome ({userdata.navidrome_server})</Button>\n : <Button\n color=\"primary\"\n type=\"button\"\n className=\"userButton\"\n onClick={connectNavidromePopup}\n >Connect Navidrome</Button>\n }\n <br/><br/>\n <Button\n color=\"primary\"\n type=\"button\"\n className=\"userButton\"\n onClick={connectJellyfinPopup}\n >Connect Jellyfin</Button>\n <br/><br/>\n <Button\n color=\"primary\"\n type=\"button\"\n className=\"userButton\"\n onClick={connectOtherPopup}\n >Other Scrobblers</Button>\n </div>\n <div style={{width: `300px`, padding: `0 10px 10px 10px`}}>\n <h3>Sad Settings</h3>\n <br/>\n <Button\n color=\"secondary\"\n type=\"button\"\n className=\"userButton\"\n onClick={deleteAccountPopup}\n >Disable Account</Button>\n <br/><br/>\n <Button\n color=\"secondary\"\n type=\"button\"\n className=\"userButton\"\n onClick={resetTokenPopup}\n >Reset Scrobbler Token</Button>\n </div>\n </div>\n </div>\n );\n}\n\nexport default User;"]},"metadata":{},"sourceType":"module"}