1 line
8.1 KiB
JSON
1 line
8.1 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: page_text\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: \"\" + pagenumber + \"/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/Projects/the-forest/src/PageView.jsx"],"sourcesContent":["import 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';\n\nconst url = \"http://127.0.0.1:8000\"\n\nfunction PageView() {\n const queryClient = useQueryClient();\n const { pagenumber } = useParams();\n const [ text_of_page, setBodyText ] = useState(\"Not loaded yet\");\n const { isPending, error, data } = useQuery({ // fetch the currrent values\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 id, title, description from pages where id=?',\n params: [pagenumber]\n }]\n })\n }).then((res) => res.json())\n .then((data) => data[0].results.rows[0])\n .then((row) => {\n setBodyText(row[2]);\n return row;\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>{page_text}</pre>\n </div>\n <a href={\"\" + pagenumber + \"/edit\"}>\n <button type=\"submit\">Edit this page!</button>\n </a>\n </header>\n </div>\n );\n}\n\nexport default PageView;"],"mappings":";;AAAA,OAAOA,IAAI,MAAM,YAAY;AAC7B,SAASC,GAAG,QAAQ,UAAU;AAC9B,OAAO,WAAW;AAClB,SAASC,QAAQ,EAAEC,WAAW,EAAEC,cAAc,QAAQ,uBAAuB;AAC7E,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,QAAQ,QAAQ,OAAO;AAAC,SAAAC,MAAA,IAAAC,OAAA;AAEjC,MAAMC,GAAG,GAAG,uBAAuB;AAEnC,SAASC,QAAQA,CAAA,EAAG;EAAAC,EAAA;EAClB,MAAMC,WAAW,GAAGR,cAAc,CAAC,CAAC;EACpC,MAAM;IAAES;EAAW,CAAC,GAAGR,SAAS,CAAC,CAAC;EAClC,MAAM,CAAES,YAAY,EAAEC,WAAW,CAAE,GAAGT,QAAQ,CAAC,gBAAgB,CAAC;EAChE,MAAM;IAAEU,SAAS;IAAEC,KAAK;IAAEC;EAAK,CAAC,GAAGhB,QAAQ,CAAC;IAAE;IAC5CiB,QAAQ,EAAE,CAAC,MAAM,EAAEN,UAAU,CAAC;IAC9BO,OAA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