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

1 line
12 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 { useState } 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 // 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=@val',\n params: {\n 'val': pagenumber\n }\n }]\n })\n }).then(res => res.json()).then(data => data[0].results.rows[0])\n });\n const [text_of_page, setBodyText] = useState(!(isPending || error) ? data[2] : \"Some kinda prroblem loading data\");\n const mutation = useMutation({\n // for changing the value when we're done with it\n mutationFn: ({\n id,\n title,\n text\n }) => {\n console.log(\"trying to mutate with values \" + id + \" \" + title + \" \" + text);\n fetch(url, {\n method: '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: [id, title, text]\n }]\n })\n }).then(res => console.log(\"tried to insert!\", res.json()));\n console.log(\"made the request\");\n },\n onSuccess: () => {\n // Invalidate and refetch\n queryClient.invalidateQueries({\n queryKey: ['page', pagenumber]\n });\n }\n });\n function handleSubmit(e) {\n e.preventDefault();\n const formData = new FormData(e.target);\n mutation.mutate({\n id: pagenumber,\n title: page_title,\n text: formData.get(\"page_text\")\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(\"form\", {\n onSubmit: handleSubmit,\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: 77,\n columnNumber: 11\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: 79,\n columnNumber: 13\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 78,\n columnNumber: 11\n }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"Page-contents\",\n children: /*#__PURE__*/_jsxDEV(\"input\", {\n name: \"page_text\",\n type: \"text\",\n onChange: e => setBodyText(e.target.value),\n value: text_of_page\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 82,\n columnNumber: 13\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 81,\n columnNumber: 11\n }, this), /*#__PURE__*/_jsxDEV(\"button\", {\n type: \"submit\",\n children: \"Submit!\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 84,\n columnNumber: 11\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 76,\n columnNumber: 9\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 75,\n columnNumber: 7\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 74,\n columnNumber: 5\n }, this);\n}\n_s(PageView, \"PTa+ootI1Y/5sIJcqu3h6OesEVQ=\", 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","useState","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","text_of_page","setBodyText","mutation","mutationFn","id","title","text","onSuccess","invalidateQueries","handleSubmit","e","preventDefault","formData","FormData","target","mutate","page_title","get","the_id","page_text","className","children","onSubmit","src","alt","fileName","_jsxFileName","lineNumber","columnNumber","name","type","onChange","value","_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 { useState } 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\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=@val',\n params: {'val': pagenumber}\n }]\n })\n }).then((res) => res.json())\n .then((data) => data[0].results.rows[0])\n })\n const [ text_of_page, setBodyText ] = useState(\n !(isPending || error) ? data[2] : \"Some kinda prroblem loading data\"\n );\n const mutation = useMutation({ // for changing the value when we're done with it\n mutationFn: ({id, title, text}) => {\n console.log(\"trying to mutate with values \" + id + \" \" + title + \" \" + text);\n fetch(url, {\n method: 'POST',\n headers: {'Content-Type': 'application/json'},\n body: JSON.stringify({\n statements: [{\n q: 'replace into pages (id, title, description) values (?, ?, ?)',\n params: [id, title, text],\n }]\n })\n }).then((res) => console.log(\"tried to insert!\", res.json()));\n console.log(\"made the request\");\n },\n onSuccess: () => {\n // Invalidate and refetch\n queryClient.invalidateQueries({ queryKey: ['page', pagenumber] })\n },\n });\n\n function handleSubmit(e) {\n e.preventDefault()\n const formData = new FormData(e.target);\n mutation.mutate({\n id: pagenumber, \n title: page_title, \n text: formData.get(\"page_text\"),\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 <form onSubmit={handleSubmit}>\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 <input name=\"page_text\" type=\"text\" onChange={e => setBodyText(e.target.value)} value={text_of_page}></input>\n </div>\n <button type=\"submit\">Submit!</button>\n </header>\n </form>\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,QAAQ,QAAQ,OAAO;AAAC,SAAAC,MAAA,IAAAC,OAAA;AAEjC,MAAMC,GAAG,GAAG,uBAAuB;AAEnC,SAASC,cAAcA,CAACC,GAAG,EAAE;EAC3BC,OAAO,CAACC,GAAG,CAAC,EAAE,GAAGF,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,GAAGA,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,GAAGA,GAAG,CAAC,CAAC,CAAC,CAAC;AACxD;AAEA,SAASG,QAAQA,CAAA,EAAG;EAAAC,EAAA;EAClB,MAAM;IAAEC;EAAW,CAAC,GAAGX,SAAS,CAAC,CAAC;EAGlC,MAAM;IAAEY,SAAS;I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