the-forest/client/node_modules/.cache/babel-loader/b23662220977cb386e951b2084594178b70a3931e078d249340e609509594b81.json
2024-09-17 20:35:18 -04:00

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, useNavigate } 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 navigate = useNavigate();\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: 44,\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: 46,\n columnNumber: 11\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 45,\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: 49,\n columnNumber: 11\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 48,\n columnNumber: 9\n }, this), /*#__PURE__*/_jsxDEV(\"button\", {\n type: \"submit\",\n onClick: () => navigate(`/${pagenumber}/edit`),\n children: \"Edit this page!\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 51,\n columnNumber: 9\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 43,\n columnNumber: 7\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 42,\n columnNumber: 5\n }, this);\n}\n_s(PageView, \"y3bZ9/biNFkczNtNOOZIEIUo6YY=\", false, function () {\n return [useNavigate, 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","useNavigate","useState","jsxDEV","_jsxDEV","url","PageView","_s","navigate","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","type","onClick","_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, useNavigate } from 'react-router-dom';\nimport { useState } from 'react';\n\nconst url = \"http://127.0.0.1:8000\"\n\nfunction PageView() {\n const navigate = useNavigate();\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 <button type=\"submit\" onClick={() => navigate(`/${pagenumber}/edit`)}>Edit this page!</button>\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,EAAEC,WAAW,QAAQ,kBAAkB;AACzD,SAASC,QAAQ,QAAQ,OAAO;AAAC,SAAAC,MAAA,IAAAC,OAAA;AAEjC,MAAMC,GAAG,GAAG,uBAAuB;AAEnC,SAASC,QAAQA,CAAA,EAAG;EAAAC,EAAA;EAClB,MAAMC,QAAQ,GAAGP,WAAW,CAAC,CAAC;EAC9B,MAAMQ,WAAW,GAAGV,cAAc,CAAC,CAAC;EACpC,MAAM;IAAEW;EAAW,CAAC,GAAGV,SAAS,CAAC,CAAC;EAClC,MAAM,CAAEW,YAAY,EAAEC,WAAW,CAAE,GAAGV,QAAQ,CAAC,gBAAgB,CAAC;EAChE,MAAM;IAAEW,SAAS;IAAEC,KAAK;IAAEC;EA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