GoScrobble/web/node_modules/.cache/babel-loader/bd07d377ae88b3e9205fef5c623008f9.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/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: