GoScrobble/web/node_modules/.cache/babel-loader/2a706e632c19179619e55caf03dbca3e.json

1 line
10 KiB
JSON
Raw Normal View History

2022-04-25 02:47:15 +00:00
{"ast":null,"code":"var _jsxFileName = \"/app/src/Pages/ArtistEdit.js\",\n _s = $RefreshSig$();\n\nimport React, { useContext, useState, useEffect } from 'react';\nimport '../App.css';\nimport './ArtistEdit.css';\nimport { useHistory } from 'react-router-dom';\nimport ScaleLoader from 'react-spinners/ScaleLoader';\nimport { getArtist, uploadImage } from '../Api/index';\nimport { Link } from 'react-router-dom';\nimport AuthContext from '../Contexts/AuthContext';\nimport FileUploader from '../Components/FileUploader';\nimport { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\n\nconst ArtistEdit = route => {\n _s();\n\n const history = useHistory();\n const {\n user\n } = useContext(AuthContext);\n const [loading, setLoading] = useState(true);\n const [artist, setArtist] = useState({});\n const [selectedFile, setSelectedFile] = useState(null);\n\n const submitForm = e => {\n e.preventDefault();\n const formData = new FormData();\n formData.append(\"name\", \"file\");\n formData.append(\"file\", selectedFile);\n uploadImage(formData, \"artist\", artist.uuid, history);\n };\n\n let artistUUID = false;\n\n if (route && route.match && route.match.params && route.match.params.uuid) {\n artistUUID = route.match.params.uuid;\n } else {\n artistUUID = false;\n }\n\n useEffect(() => {\n if (!artistUUID) {\n return false;\n }\n\n getArtist(artistUUID).then(data => {\n setArtist(data);\n setLoading(false);\n });\n }, [artistUUID]);\n\n if (!user) {\n history.push(\"/login\");\n }\n\n if (user && !user.mod) {\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: 60,\n columnNumber: 9\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 59,\n columnNumber: 7\n }, this);\n }\n\n if (!artistUUID || !artist) {\n return /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"pageWrapper\",\n children: \"Unable to fetch user\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 67,\n columnNumber: 7\n }, this);\n }\n\n return /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"pageWrapper\",\n children: [/*#__PURE__*/_jsxDEV(\"h1\", {\n style: {\n margin: 0\n },\n children: [artist.name, \" \", /*#__PURE__*/_jsxDEV(Link, {\n to: \"/artist/\" + artistUUID,\n children: \"unedit\"\n }, \"editbuttonomg\", false, {\n fileName: _jsxFileName,\n lineNumber: 76,\n columnNumber: 22\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 75,\n columnNumber: 7\n }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"pageBody\",\n style: {\n width: `900px`,\n textAlign: `center`\n },\n children: [/*#__PURE__*/_jsxDEV(\"img\", {\n src: process.env.REACT_APP_API_URL + \"/img/\" + artist.uuid + \"_full.jpg\",\n alt: artist.name,\n style: {\n maxWidth: `300px`,\n maxHeight: `300px`\n }\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 82,\n columnNumber: 9\n }, this), /*#__PURE__*/_jsxDEV(\"form\", {\n children: [/*#__PURE__*/_jsxDEV(FileUploader, {\n onFileSelect: file => setSelectedFile(file)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 85,\n columnNumber: 11\n }, this), /*#__PURE__*/_jsxDEV(\"button\", {\n onClick: submitForm,\n children: \"Submit\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 88,\n columnNumber: 11\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 84,\n columnNumber: 9\n }, this)]\n }, void 0, tru