mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-22 16:35:14 +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: _jsxFileName,\n lineNumber: 81,\n columnNumber: 7\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 74,\n columnNumber: 5\n }, this);\n};\n\n_s(AlbumEdit, \"byHKKuPoQ5zS5AuwUILpFWZAE8E=\", false, function () {\n return [useHistory];\n});\n\n_c = AlbumEdit;\nexport default AlbumEdit;\n\nvar _c;\n\n$RefreshReg$(_c, \"AlbumEdit\");","map":{"version":3,"sources":["/app/src/Pages/AlbumEdit.js"],"names":["React","useContext","useState","useEffect","useHistory","ScaleLoader","getAlbum","uploadImage","Link","AuthContext","FileUploader","AlbumEdit","route","history","user","loading","setLoading","album","setAlbum","selectedFile","setSelectedFile","submitForm","e","preventDefault","formData","FormData","append","uuid","albumUUID","match","params","then","data","push","mod","margin","name","width","textAlign","process","env","REACT_APP_API_URL","maxWidth","maxHeight","file"],"mappings":";;;AAAA,OAAOA,KAAP,IAAgBC,UAAhB,EAA4BC,QAA5B,EAAsCC,SAAtC,QAAuD,OAAvD;AACA,OAAO,YAAP;AACA,OAAO,iBAAP;AACA,SAASC,UAAT,QAA2B,kBAA3B;AACA,OAAOC,WAAP,MAAwB,4BAAxB;AACA,SAASC,QAAT,EAAmBC,WAAnB,QAAsC,cAAtC;AACA,SAASC,IAAT,QAAqB,kBAArB;AACA,OAAOC,WAAP,MAAwB,yBAAxB;AACA,OAAOC,YAAP,MAAyB,4BAAzB;;;AAEA,MAAMC,SAAS,GAAIC,KAAD,IAAW;AAAA;;AAC3B,QAAMC,OAAO,GAAGT,UAAU,EAA1B;AACA,QAAM;AAAEU,IAAAA;AAAF,MAAWb,UAAU,CAACQ,WAAD,CAA3B;AAEA,QAAM,CAACM,OAAD,EAAUC,UAAV,IAAwBd,QAAQ,CAAC,IAAD,CAAtC;AACA,QAAM,CAACe,KAAD,EAAQC,QAAR,IAAoBhB,QAAQ,CAAC,EAAD,CAAlC;AAEA,QAAM,CAACiB,YAAD,EAAeC,eAAf,IAAkClB,QAAQ,CAAC,IAAD,CAAhD;;AAEA,QAAMmB,UAAU,GAAIC,CAAD,IAAO;AACxBA,IAAAA,CAAC,CAACC,cAAF;AAEA,UAAMC,QAAQ,GAAG,IAAIC,QAAJ,EAAjB;AACAD,IAAAA,QAAQ,CAACE,MAAT,CAA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'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';\n\nconst AlbumEdit = (route) => {\n const history = useHistory();\n const { user } = useContext(AuthContext);\n\n const [loading, setLoading] = useState(true);\n const [album, setAlbum] = useState({});\n\n const [selectedFile, setSelectedFile] = useState(null);\n\n const submitForm = (e) => {\n e.preventDefault();\n\n const formData = new FormData();\n formData.append(\"name\", \"file\");\n formData.append(\"file\", selectedFile);\n \n uploadImage(formData, \"album\", album.uuid, history)\n };\n\n let albumUUID = false;\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)\n .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 (\n <div className=\"pageWrapper\">\n <ScaleLoader color=\"#6AD7E5\" />\n </div>\n )\n }\n\n if (!albumUUID || !album) {\n return (\n <div className=\"pageWrapper\">\n Unable to fetch user\n </div>\n )\n }\n\n return (\n <div className=\"pageWrapper\">\n <h1 style={{margin: 0}}>\n {album.name} {<Link\n key=\"editbuttonomg\"\n to={\"/album/\" + albumUUID}\n >unedit</Link>}\n </h1>\n <div className=\"pageBody\" style={{width: `900px`, textAlign: `center`}}>\n <img src={process.env.REACT_APP_API_URL + \"/img/\" + album.uuid + \"_full.jpg\"} alt={album.name} style={{maxWidth: `300px`, maxHeight: `300px`}}/>\n\n <form>\n <FileUploader\n onFileSelect={(file) => setSelectedFile(file)}\n />\n <button onClick={submitForm}>Submit</button>\n </form>\n\n </div>\n </div>\n )\n}\n\nexport default AlbumEdit;"]},"metadata":{},"sourceType":"module"} |