GoScrobble/web/node_modules/.cache/babel-loader/da09d8879da2fd739fc6f93140e3e23d.json

1 line
13 KiB
JSON
Raw Normal View History

2022-04-25 02:47:15 +00:00
{"ast":null,"code":"var _jsxFileName = \"/app/src/Pages/Profile.js\",\n _s = $RefreshSig$();\n\nimport React, { useState, useEffect } from 'react';\nimport '../App.css';\nimport './Profile.css';\nimport ScaleLoader from 'react-spinners/ScaleLoader';\nimport { getProfile, getTopTracks, getTopArtists } from '../Api/index';\nimport ScrobbleTable from '../Components/ScrobbleTable';\nimport TopTable from '../Components/TopTable';\nimport { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\nconst profileDateRanges = {\n 'All time': false,\n 'Last year': '365',\n 'Last month': '30',\n 'Last week': '7'\n};\nconst defaultDateRange = 'Last month';\nlet activeStyle = {\n color: '#FFFFFF'\n};\n\nconst Profile = route => {\n _s();\n\n const [loading, setLoading] = useState(true);\n const [tableLoading, setTableLoading] = useState(false);\n const [active, setActive] = useState(defaultDateRange);\n const [profile, setProfile] = useState({});\n const [topTracks, setTopTracks] = useState({});\n const [topArtists, setTopArtists] = useState({});\n let username = false;\n\n if (route && route.match && route.match.params && route.match.params.uuid) {\n username = route.match.params.uuid;\n } else {\n username = false;\n }\n\n useEffect(() => {\n if (!username) {\n return false;\n }\n\n getProfile(username).then(data => {\n setProfile(data); // Fetch top tracks\n\n getTopTracks(data.uuid, profileDateRanges[defaultDateRange]).then(data => {\n setTopTracks(data.tracks);\n }); // Fetch top artists\n\n getTopArtists(data.uuid, profileDateRanges[defaultDateRange]).then(data => {\n setTopArtists(data.artists);\n });\n setLoading(false);\n });\n }, [username]);\n\n const reloadScrobblesForDate = (username, days, name) => {\n setActive(name);\n setTableLoading(true);\n getProfile(username).then(data => {\n setProfile(data); // Fetch top tracks\n\n getTopTracks(data.uuid, days).then(data => {\n setTopTracks(data.tracks);\n }); // Fetch top artists\n\n getTopArtists(data.uuid, days).then(data => {\n setTopArtists(data.artists);\n });\n setTableLoading(false);\n });\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: 86,\n columnNumber: 9\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 85,\n columnNumber: 7\n }, this);\n }\n\n if (!username || !profile.username) {\n return /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"pageWrapper\",\n children: \"Unable to fetch user\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 93,\n columnNumber: 7\n }, this);\n }\n\n return /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"pageWrapper\",\n children: [/*#__PURE__*/_jsxDEV(\"h1\", {\n children: [profile.username, \"'s Profile\"]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 101,\n columnNumber: 7\n }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"pageBody\",\n children: [/*#__PURE__*/_jsxDEV(\"div\", {\n className: \"profileDateRange\",\n children: Object.entries(profileDateRanges).map((t, k) => /*#__PURE__*/_jsxDEV(\"span\", {\n children: /*#__PURE__*/_jsxDEV(\"span\", {\n onClick: () => reloadScrobblesForDate(username, t[1], t[0]),\n style: active === t[0] ? activeStyle : {},\n className: \"profileDateRangeText\",\n children: t[0]\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 108,\n columnNumber: 15\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 107,\n columnNumber: 60\n }, this))\n }, void 0, false, {\n fileName: _jsxFileName,\