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/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, 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(ArtistEdit, \"aLQC137bD7h9xM+2iISNTH/rENI=\", false, function () {\n return [useHistory];\n});\n\n_c = ArtistEdit;\nexport default ArtistEdit;\n\nvar _c;\n\n$RefreshReg$(_c, \"ArtistEdit\");","map":{"version":3,"sources":["/app/src/Pages/ArtistEdit.js"],"names":["React","useContext","useState","useEffect","useHistory","ScaleLoader","getArtist","uploadImage","Link","AuthContext","FileUploader","ArtistEdit","route","history","user","loading","setLoading","artist","setArtist","selectedFile","setSelectedFile","submitForm","e","preventDefault","formData","FormData","append","uuid","artistUUID","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,kBAAP;AACA,SAASC,UAAT,QAA2B,kBAA3B;AACA,OAAOC,WAAP,MAAwB,4BAAxB;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,cAAvC;AACA,SAASC,IAAT,QAAqB,kBAArB;AACA,OAAOC,WAAP,MAAwB,yBAAxB;AACA,OAAOC,YAAP,MAAyB,4BAAzB;;;AAEA,MAAMC,UAAU,GAAIC,KAAD,IAAW;AAAA;;AAC5B,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,MAAD,EAASC,SAAT,IAAsBhB,QAAQ,CAAC,EAAD,CAApC;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,CAAgB,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'../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';\n\nconst ArtistEdit = (route) => {\n const history = useHistory();\n const { user } = useContext(AuthContext);\n\n const [loading, setLoading] = useState(true);\n const [artist, setArtist] = 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, \"artist\", artist.uuid, history)\n };\n\n let artistUUID = false;\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)\n .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 (\n <div className=\"pageWrapper\">\n <ScaleLoader color=\"#6AD7E5\" />\n </div>\n )\n }\n\n if (!artistUUID || !artist) {\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 {artist.name} {<Link\n key=\"editbuttonomg\"\n to={\"/artist/\" + artistUUID}\n >unedit</Link>}\n </h1>\n <div className=\"pageBody\" style={{width: `900px`, textAlign: `center`}}>\n <img src={process.env.REACT_APP_API_URL + \"/img/\" + artist.uuid + \"_full.jpg\"} alt={artist.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 ArtistEdit;"]},"metadata":{},"sourceType":"module"} |