1 line
8.4 KiB
JSON
1 line
8.4 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.css';\nimport { QueryClient, QueryClientProvider, useQuery } from '@tanstack/react-query';\nimport { useLoaderData, useParams } from 'react-router-dom';\nimport { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\nconst url = \"http://127.0.0.1:8000\";\nfunction fetchPage(id_we_want) {\n 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=?',\n params: [id_we_want]\n }]\n })\n }).then(res => res.json()).then(data => setCurrentPage(data[0].results.rows[0])).catch(err => console.log(err));\n}\nexport async function loader({\n params\n}) {\n return params.pagenumber;\n}\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: ['repoData'],\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 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: 59,\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: 61,\n columnNumber: 11\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 60,\n columnNumber: 9\n }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"Page-contents\",\n children: /*#__PURE__*/_jsxDEV(\"pre\", {\n children: page_text\n }, void 0, false, {\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)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 58,\n columnNumber: 7\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 57,\n columnNumber: 5\n }, this);\n}\n_s(PageView, \"C9gKGfWelU43z1tINJ4rsFyUmTU=\", false, function () {\n return [useParams, useQuery];\n});\n_c = PageView;\nexport default PageView;\nvar _c;\n$RefreshReg$(_c, \"PageView\");","map":{"version":3,"names":["logo","QueryClient","QueryClientProvider","useQuery","useLoaderData","useParams","jsxDEV","_jsxDEV","url","fetchPage","id_we_want","fetch","method","headers","body","JSON","stringify","statements","q","params","then","res","json","data","setCurrentPage","results","rows","catch","err","console","log","loader","pagenumber","row","PageView","_s","isPending","error","queryKey","queryFn","the_id","page_title","page_text","className","children","src","alt","fileName","_jsxFileName","lineNumber","columnNumber","_c","$RefreshReg$"],"sources":["/Users/shoofle/Projects/the-forest/src/PageView.jsx"],"sourcesContent":["import logo from './logo.svg';\nimport './App.css';\nimport { QueryClient, QueryClientProvider, useQuery } from '@tanstack/react-query'\nimport { useLoaderData, useParams } from 'react-router-dom'\n\nconst url = \"http://127.0.0.1:8000\"\n\nfunction fetchPage(id_we_want) {\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=?',\n params: [id_we_want]\n }]\n })\n })\n .then((res) => res.json())\n .then((data) => setCurrentPage(data[0].results.rows[0]))\n .catch((err) => console.log(err));\n}\n\nexport async function loader({ params }) {\n return params.pagenumber;\n}\n\nfunction setCurrentPage(row) {\n console.log(\"\" + row[0] + \" \" + row[1] + \" \" + row[2]);\n}\n\nfunction PageView() {\n const { pagenumber } = useParams();\n const { isPending, error, data } = useQuery({\n queryKey: ['repoData'],\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 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>{page_text}</pre>\n </div>\n </header>\n </div>\n );\n}\n\nexport default PageView;"],"mappings":";;AAAA,OAAOA,IAAI,MAAM,YAAY;AAC7B,OAAO,WAAW;AAClB,SAASC,WAAW,EAAEC,mBAAmB,EAAEC,QAAQ,QAAQ,uBAAuB;AAClF,SAASC,aAAa,EAAEC,SAAS,QAAQ,kBAAkB;AAAA,SAAAC,MAAA,IAAAC,OAAA;AAE3D,MAAMC,GAAG,GAAG,uBAAuB;AAEnC,SAASC,SAASA,CAACC,UAAU,EAAE;EAC7BC,KAAK,CAACH,GAAG,EAAE;IACTI,MAAM,EAAE,MAAM;IACdC,OAAO,EAAE;MAAC,cAAc,EAAE;IAAkB,CAAC;IAC7CC,IAAI,EAAEC,IAAI,CAACC,SAAS,CAAC;MACnBC,UAAU,EAAE,CAAC;QACXC,CAAC,EAAE,gCAAgC;QACnCC,MAAM,EAAE,CAACT,UAAU;MACrB,CAAC;IACH,CAAC;EACH,CAAC,CAAC,CACCU,IAAI,CAAEC,GAAG,IAAKA,GAAG,CAACC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