1 line
9.5 KiB
JSON
1 line
9.5 KiB
JSON
{"ast":null,"code":"var _jsxFileName = \"/Users/shoofle/Projects/the-forest/src/PageView.jsx\",\n _s = $RefreshSig$();\nimport logo from './logo.svg';\nimport { queryClient, App } from './App.js';\nimport './App.css';\nimport { useQuery, useMutation } from '@tanstack/react-query';\nimport { useParams } from 'react-router-dom';\nimport { useRef } from 'react';\nimport { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\nconst url = \"http://127.0.0.1:8000\";\nfunction setCurrentPage(row) {\n console.log(\"\" + row[0] + \" \" + row[1] + \" \" + row[2]);\n}\nfunction PageView() {\n _s();\n const {\n pagenumber\n } = useParams();\n const {\n isPending,\n error,\n data\n } = useQuery({\n queryKey: ['page', pagenumber],\n queryFn: () => fetch(url, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json'\n },\n body: JSON.stringify({\n statements: [{\n q: 'select * from pages where id=@val',\n params: {\n 'val': pagenumber\n }\n }]\n })\n }).then(res => res.json()).then(data => data[0].results.rows[0])\n });\n const mutation = useMutation({\n mutationFn: () => {\n if (isPending || error) return;\n return fetch(url, {\n metthod: 'POST',\n headers: {\n 'Content-Type': 'application/json'\n },\n body: JSON.stringify({\n statements: [{\n q: 'replace into pages (id, title, description) values (?, ?, ?)',\n params: [] // TODO: gett the value of the contenteditable block\n }]\n })\n }).then(res => console.log(res.json()));\n },\n onSuccess: () => {\n // Invalidate and refetch\n queryClient.invalidateQueries({\n queryKey: ['page', pagenumber]\n });\n }\n });\n if (isPending) return \"Loading...\";\n if (error) return \"Uh oh!\";\n const [the_id, page_title, page_text] = data;\n return /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"App\",\n children: /*#__PURE__*/_jsxDEV(\"header\", {\n className: \"App-header\",\n children: [/*#__PURE__*/_jsxDEV(\"img\", {\n src: logo,\n className: \"App-logo\",\n alt: \"logo\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 62,\n columnNumber: 9\n }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"Page-title\",\n children: /*#__PURE__*/_jsxDEV(\"h3\", {\n children: [the_id, \". \", page_title]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 64,\n columnNumber: 11\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 63,\n columnNumber: 9\n }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"Page-contents\",\n children: /*#__PURE__*/_jsxDEV(\"pre\", {\n contentEditable: \"true\",\n children: page_text\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 67,\n columnNumber: 11\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 66,\n columnNumber: 9\n }, this), /*#__PURE__*/_jsxDEV(\"button\", {\n onClick: () => mutation.mutate(),\n children: \"Submit!\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 69,\n columnNumber: 9\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 61,\n columnNumber: 7\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 60,\n columnNumber: 5\n }, this);\n}\n_s(PageView, \"3Rz8iwWZfM7jQJQjiSWERZDbLq0=\", false, function () {\n return [useParams, useQuery, useMutation];\n});\n_c = PageView;\nexport default PageView;\nvar _c;\n$RefreshReg$(_c, \"PageView\");","map":{"version":3,"names":["logo","queryClient","App","useQuery","useMutation","useParams","useRef","jsxDEV","_jsxDEV","url","setCurrentPage","row","console","log","PageView","_s","pagenumber","isPending","error","data","queryKey","queryFn","fetch","method","headers","body","JSON","stringify","statements","q","params","then","res","json","results","rows","mutation","mutationFn","metthod","onSuccess","invalidateQueries","the_id","page_title","page_text","className","children","src","alt","fileName","_jsxFileName","lineNumber","columnNumber","contentEditable","onClick","mutate","_c","$RefreshReg$"],"sources":["/Users/shoofle/Projects/the-forest/src/PageView.jsx"],"sourcesContent":["import logo from './logo.svg';\nimport { queryClient, App } from './App.js';\nimport './App.css';\nimport { useQuery, useMutation } from '@tanstack/react-query';\nimport { useParams } from 'react-router-dom';\nimport { useRef } from 'react';\n\nconst url = \"http://127.0.0.1:8000\"\n\nfunction setCurrentPage(row) {\n console.log(\"\" + row[0] + \" \" + row[1] + \" \" + row[2]);\n}\n\nfunction PageView() {\n const { pagenumber } = useParams();\n\n const { isPending, error, data } = useQuery({\n queryKey: ['page', pagenumber],\n queryFn: () =>\n fetch(url, {\n method: 'POST',\n headers: {'Content-Type': 'application/json'},\n body: JSON.stringify({\n statements: [{\n q: 'select * from pages where id=@val',\n params: {'val': pagenumber}\n }]\n })\n }).then((res) => res.json())\n .then((data) => data[0].results.rows[0])\n })\n\n const mutation = useMutation({\n mutationFn: () => {\n if (isPending || error) return;\n return fetch(url, {\n metthod: 'POST',\n headers: {'Content-Type': 'application/json'},\n body: JSON.stringify({\n statements: [{\n q: 'replace into pages (id, title, description) values (?, ?, ?)',\n params: [], // TODO: gett the value of the contenteditable block\n }]\n })\n }).then((res) => console.log(res.json()));\n },\n onSuccess: () => {\n // Invalidate and refetch\n queryClient.invalidateQueries({ queryKey: ['page', pagenumber] })\n },\n });\n\n if (isPending) return \"Loading...\";\n\n if (error) return \"Uh oh!\";\n\n const [the_id, page_title, page_text] = data;\n\n return (\n <div className=\"App\">\n <header className=\"App-header\">\n <img src={logo} className=\"App-logo\" alt=\"logo\" />\n <div className=\"Page-title\">\n <h3>{the_id}. {page_title}</h3>\n </div>\n <div className=\"Page-contents\">\n <pre contentEditable=\"true\">{page_text}</pre>\n </div>\n <button onClick={() => mutation.mutate()} >Submit!</button>\n </header>\n </div>\n );\n}\n\nexport default PageView;"],"mappings":";;AAAA,OAAOA,IAAI,MAAM,YAAY;AAC7B,SAASC,WAAW,EAAEC,GAAG,QAAQ,UAAU;AAC3C,OAAO,WAAW;AAClB,SAASC,QAAQ,EAAEC,WAAW,QAAS,uBAAuB;AAC9D,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,MAAM,QAAQ,OAAO;AAAC,SAAAC,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