mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-25 09:55:15 +00:00
1 line
13 KiB
JSON
1 line
13 KiB
JSON
{"ast":null,"code":"var _jsxFileName = \"/app/src/Pages/Admin.js\",\n _s = $RefreshSig$();\n\nimport React, { useContext, useState, useEffect } from 'react';\nimport { useHistory } from 'react-router-dom';\nimport '../App.css';\nimport './Admin.css';\nimport { Button } from 'reactstrap';\nimport { Formik, Form, Field } from 'formik';\nimport ScaleLoader from 'react-spinners/ScaleLoader';\nimport AuthContext from '../Contexts/AuthContext';\nimport { Switch } from 'formik-material-ui';\nimport { getConfigs, postConfigs } from '../Api/index';\nimport { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\n\nconst Admin = () => {\n _s();\n\n const history = useHistory();\n const {\n user\n } = useContext(AuthContext);\n const [loading, setLoading] = useState(true);\n const [configs, setConfigs] = useState({});\n const [toggle, setToggle] = useState(false);\n useEffect(() => {\n getConfigs().then(data => {\n if (data.configs) {\n setConfigs(data.configs);\n setToggle(data.configs.REGISTRATION_ENABLED === \"1\");\n setLoading(false);\n }\n });\n }, []);\n\n const handleToggle = () => {\n setToggle(!toggle);\n };\n\n if (!user) {\n history.push(\"/login\");\n }\n\n if (user && !user.admin) {\n history.push(\"/Dashboard\");\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: 46,\n columnNumber: 9\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 45,\n columnNumber: 7\n }, this);\n }\n\n return /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"pageWrapper\",\n children: [/*#__PURE__*/_jsxDEV(\"h1\", {\n children: \"Admin Panel\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 53,\n columnNumber: 7\n }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"pageBody\",\n children: /*#__PURE__*/_jsxDEV(Formik, {\n initialValues: configs,\n onSubmit: values => postConfigs(values, toggle),\n children: /*#__PURE__*/_jsxDEV(Form, {\n children: [/*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 61,\n columnNumber: 17\n }, this), /*#__PURE__*/_jsxDEV(\"label\", {\n children: [/*#__PURE__*/_jsxDEV(Field, {\n type: \"checkbox\",\n name: \"REGISTRATION_ENABLED\",\n onChange: handleToggle,\n component: Switch,\n checked: toggle,\n value: toggle\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 63,\n columnNumber: 13\n }, this), \"Registration Enabled\"]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 62,\n columnNumber: 11\n }, this), /*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 72,\n columnNumber: 19\n }, this), /*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 72,\n columnNumber: 24\n }, this), /*#__PURE__*/_jsxDEV(\"label\", {\n children: [\"LastFM Api Key\", /*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 74,\n columnNumber: 27\n }, this), /*#__PURE__*/_jsxDEV(Field, {\n name: \"LASTFM_API_KEY\",\n type: \"text\",\n className: \"loginFields\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 75,\n columnNumber: 13\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 73,\n columnNumber: 11\n }, this), /*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 81,\n columnNumber: 11\n }, this), /*#__PURE__*/_jsxDEV(\"label\", {\n children: [\"Spotify App ID\", /*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 83,\n columnNumber: 27\n }, this), /*#__PURE__*/_jsxDEV(Field, {\n name: \"SPOTIFY_API_ID\",\n type: \"text\",\n className: \"loginFields\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 84,\n columnNumber: 13\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 82,\n columnNumber: 11\n }, this), /*#__PURE__*/_jsxDEV(\"label\", {\n children: [\"Spotify App Secret\", /*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 91,\n columnNumber: 31\n }, this), /*#__PURE__*/_jsxDEV(Field, {\n name: \"SPOTIFY_API_SECRET\",\n type: \"text\",\n className: \"loginFields\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 92,\n columnNumber: 13\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 90,\n columnNumber: 11\n }, this), /*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 98,\n columnNumber: 11\n }, this), /*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 98,\n columnNumber: 16\n }, this), /*#__PURE__*/_jsxDEV(Button, {\n color: \"primary\",\n type: \"submit\",\n className: \"loginButton\",\n disabled: loading,\n children: \"Update\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 99,\n columnNumber: 11\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 61,\n columnNumber: 11\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 57,\n columnNumber: 9\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 56,\n columnNumber: 7\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 52,\n columnNumber: 5\n }, this);\n};\n\n_s(Admin, \"UYfAHmb/cclN7YoAXkByPIE1g4w=\", false, function () {\n return [useHistory];\n});\n\n_c = Admin;\nexport default Admin;\n\nvar _c;\n\n$RefreshReg$(_c, \"Admin\");","map":{"version":3,"sources":["/app/src/Pages/Admin.js"],"names":["React","useContext","useState","useEffect","useHistory","Button","Formik","Form","Field","ScaleLoader","AuthContext","Switch","getConfigs","postConfigs","Admin","history","user","loading","setLoading","configs","setConfigs","toggle","setToggle","then","data","REGISTRATION_ENABLED","handleToggle","push","admin","values"],"mappings":";;;AAAA,OAAOA,KAAP,IAAgBC,UAAhB,EAA4BC,QAA5B,EAAsCC,SAAtC,QAAuD,OAAvD;AACA,SAASC,UAAT,QAA2B,kBAA3B;AACA,OAAO,YAAP;AACA,OAAO,aAAP;AACA,SAASC,MAAT,QAAuB,YAAvB;AACA,SAASC,MAAT,EAAiBC,IAAjB,EAAuBC,KAAvB,QAAoC,QAApC;AACA,OAAOC,WAAP,MAAwB,4BAAxB;AACA,OAAOC,WAAP,MAAwB,yBAAxB;AACA,SAASC,MAAT,QAAuB,oBAAvB;AACA,SAASC,UAAT,EAAqBC,WAArB,QAAwC,cAAxC;;;AAEA,MAAMC,KAAK,GAAG,MAAM;AAAA;;AAClB,QAAMC,OAAO,GAAGX,UAAU,EAA1B;AACA,QAAM;AAAEY,IAAAA;AAAF,MAAWf,UAAU,CAACS,WAAD,CAA3B;AAEA,QAAM,CAACO,OAAD,EAAUC,UAAV,IAAwBhB,QAAQ,CAAC,IAAD,CAAtC;AACA,QAAM,CAACiB,OAAD,EAAUC,UAAV,IAAwBlB,QAAQ,CAAC,EAAD,CAAtC;AACA,QAAM,CAACmB,MAAD,EAASC,SAAT,IAAsBpB,QAAQ,CAAC,KAAD,CAApC;AAEAC,EAAAA,SAAS,CAAC,MAAM;AACdS,IAAAA,UAAU,GACPW,IADH,CACQC,IAAI,IAAI;AACZ,UAAIA,IAAI,CAACL,OAAT,EAAkB;AAChBC,QAAAA,UAAU,CAACI,IAAI,CAACL,OAAN,CAAV;AACAG,QAAAA,SAAS,CAACE,IAAI,CAACL,OAAL,CAAaM,oBAAb,KAAsC,GAAvC,CA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ory } from 'react-router-dom';\nimport '../App.css';\nimport './Admin.css';\nimport { Button } from 'reactstrap';\nimport { Formik, Form, Field } from 'formik';\nimport ScaleLoader from 'react-spinners/ScaleLoader';\nimport AuthContext from '../Contexts/AuthContext';\nimport { Switch } from 'formik-material-ui';\nimport { getConfigs, postConfigs } from '../Api/index'\n\nconst Admin = () => {\n const history = useHistory();\n const { user } = useContext(AuthContext);\n\n const [loading, setLoading] = useState(true);\n const [configs, setConfigs] = useState({})\n const [toggle, setToggle] = useState(false);\n\n useEffect(() => {\n getConfigs()\n .then(data => {\n if (data.configs) {\n setConfigs(data.configs);\n setToggle(data.configs.REGISTRATION_ENABLED === \"1\")\n setLoading(false);\n }\n })\n }, [])\n\n const handleToggle = () => {\n setToggle(!toggle);\n };\n\n if (!user) {\n history.push(\"/login\")\n }\n\n if (user && !user.admin) {\n history.push(\"/Dashboard\")\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 Admin Panel\n </h1>\n <div className=\"pageBody\">\n <Formik\n initialValues={configs}\n onSubmit={(values) => postConfigs(values, toggle)}\n >\n <Form><br/>\n <label>\n <Field\n type=\"checkbox\"\n name=\"REGISTRATION_ENABLED\"\n onChange={handleToggle}\n component={Switch}\n checked={toggle}\n value={toggle}\n />\n Registration Enabled\n </label><br/><br/>\n <label>\n LastFM Api Key<br/>\n <Field\n name=\"LASTFM_API_KEY\"\n type=\"text\"\n className=\"loginFields\"\n />\n </label>\n <br/>\n <label>\n Spotify App ID<br/>\n <Field\n name=\"SPOTIFY_API_ID\"\n type=\"text\"\n className=\"loginFields\"\n />\n </label>\n <label>\n Spotify App Secret<br/>\n <Field\n name=\"SPOTIFY_API_SECRET\"\n type=\"text\"\n className=\"loginFields\"\n />\n </label>\n <br/><br/>\n <Button\n color=\"primary\"\n type=\"submit\"\n className=\"loginButton\"\n disabled={loading}\n >Update</Button>\n </Form>\n </Formik>\n </div>\n </div>\n );\n}\n\nexport default Admin;\n"]},"metadata":{},"sourceType":"module"} |