mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-23 00:45:16 +00:00
1 line
10 KiB
JSON
1 line
10 KiB
JSON
|
{"ast":null,"code":"var _jsxFileName = \"/app/src/Pages/AlbumEdit.js\",\n _s = $RefreshSig$();\n\nimport React, { useContext, useState, useEffect } from 'react';\nimport '../App.css';\nimport './AlbumEdit.css';\nimport { useHistory } from 'react-router-dom';\nimport ScaleLoader from 'react-spinners/ScaleLoader';\nimport { getAlbum, 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 AlbumEdit = route => {\n _s();\n\n const history = useHistory();\n const {\n user\n } = useContext(AuthContext);\n const [loading, setLoading] = useState(true);\n const [album, setAlbum] = 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, \"album\", album.uuid, history);\n };\n\n let albumUUID = false;\n\n if (route && route.match && route.match.params && route.match.params.uuid) {\n albumUUID = route.match.params.uuid;\n } else {\n albumUUID = false;\n }\n\n useEffect(() => {\n if (!albumUUID) {\n return false;\n }\n\n getAlbum(albumUUID).then(data => {\n setAlbum(data);\n setLoading(false);\n });\n }, [albumUUID]);\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 (!albumUUID || !album) {\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: [album.name, \" \", /*#__PURE__*/_jsxDEV(Link, {\n to: \"/album/\" + albumUUID,\n children: \"unedit\"\n }, \"editbuttonomg\", false, {\n fileName: _jsxFileName,\n lineNumber: 76,\n columnNumber: 21\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/\" + album.uuid + \"_full.jpg\",\n alt: album.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, true, {\n fileName: _
|