1 line
8.2 KiB
JSON
1 line
8.2 KiB
JSON
|
{"ast":null,"code":"var _jsxFileName = \"/Users/shoofle/Projects/the-forest/src/PageView.jsx\",\n _s = $RefreshSig$();\nimport logo from './logo.svg';\nimport { App } from './App.js';\nimport './App.css';\nimport { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';\nimport { useParams } from 'react-router-dom';\nimport { useState } from 'react';\nimport { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\nconst url = \"http://127.0.0.1:8000\";\nfunction PageView() {\n _s();\n const queryClient = useQueryClient();\n const {\n pagenumber\n } = useParams();\n const [text_of_page, setBodyText] = useState(\"Not loaded yet\");\n const {\n isPending,\n error,\n data\n } = useQuery({\n // fetch the currrent values\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 id, title, description from pages where id=?',\n params: [pagenumber]\n }]\n })\n }).then(res => res.json()).then(data => data[0].results.rows[0]).then(row => {\n setBodyText(row[2]);\n return row;\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: 43,\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: 45,\n columnNumber: 11\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 44,\n columnNumber: 9\n }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"Page-contents\",\n children: /*#__PURE__*/_jsxDEV(\"pre\", {\n children: data\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 48,\n columnNumber: 11\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 47,\n columnNumber: 9\n }, this), /*#__PURE__*/_jsxDEV(\"a\", {\n href: \"\" + {\n the_id\n } + \"/edit\",\n children: /*#__PURE__*/_jsxDEV(\"button\", {\n type: \"submit\",\n children: \"Edit this page!\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 51,\n columnNumber: 11\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 50,\n columnNumber: 9\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 42,\n columnNumber: 7\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 41,\n columnNumber: 5\n }, this);\n}\n_s(PageView, \"rjlqumsGWlQBmoDezU8SVjaHjlg=\", false, function () {\n return [useQueryClient, useParams, useQuery];\n});\n_c = PageView;\nexport default PageView;\nvar _c;\n$RefreshReg$(_c, \"PageView\");","map":{"version":3,"names":["logo","App","useQuery","useMutation","useQueryClient","useParams","useState","jsxDEV","_jsxDEV","url","PageView","_s","queryClient","pagenumber","text_of_page","setBodyText","isPending","error","data","queryKey","queryFn","fetch","method","headers","body","JSON","stringify","statements","q","params","then","res","json","results","rows","row","the_id","page_title","page_text","className","children","src","alt","fileName","_jsxFileName","lineNumber","columnNumber","href","type","_c","$RefreshReg$"],"sources":["/Users/shoofle/P
|