netlify-onegraph-internal
Advanced tools
Comparing version 0.3.7 to 0.3.8
@@ -40,3 +40,3 @@ "use strict"; | ||
name: ["pages", opts.operationData.displayName + "Form." + extension], | ||
content: "import Head from \"next/head\";\nimport React, { useState } from \"react\";\nimport { Auth } from 'netlify-graph-auth';" + ts(opts.netlifyGraphConfig, "\nimport NetlifyGraphAuth = Auth.NetlifyGraphAuth;") + notTs(opts.netlifyGraphConfig, "\n\nconst { NetlifyGraphAuth } = Auth;") + "\n\nexport default function Form(props) {\n const isServer = typeof window === \"undefined\";\n " + form.formHelpers + "\n const [result, setResult] = useState(null);\n const [auth, setAuth] = useState(\n isServer\n ? null\n : new NetlifyGraphAuth({\n siteId: props.siteId,\n })\n );\n\n const submitForm = async () => {\n const res = await fetch(\"" + opts.route + "\", {\n body: JSON.stringify(formVariables),\n headers: {\n \"Content-Type\": \"application/json\",\n ...auth?.authHeaders()\n },\n method: \"POST\"\n });\n\n const formResult = await res.json();\n setResult(formResult);\n };\n\n const needsLoginService = auth?.findMissingAuthServices(result)[0];\n\n return (\n <div className=\"container\">\n <Head>\n <title>" + opts.operationData.displayName + " form</title>\n </Head>\n <main>\n <h1>{props.title}</h1>\n" + addLeftWhitespace(form.formEl, 8) + "\n {needsLoginService ? (\n <button\n onClick={async () => {\n await auth.login(needsLoginService);\n const loginSuccess = await auth.isLoggedIn(needsLoginService);\n if (loginSuccess) {\n console.log(\"Successfully logged into \" + needsLoginService);\n submitForm();\n } else {\n console.log(\"The user did not grant auth to \" + needsLoginService);\n }\n }}\n >\n {`Log in to ${needsLoginService}`}\n </button>) \n : null}\n <pre>{JSON.stringify(formVariables, null, 2)}</pre>\n <pre>{JSON.stringify(result, null, 2)}</pre>\n </main>\n </div>\n )\n}\n\nexport async function getServerSideProps(context) {\n const siteId = process.env.SITE_ID;\n if (!siteId) {\n throw new Error(\"SITE_ID environment variable is not set. Be sure to run `netlify link` before `netlify dev`\");\n }\n\n return {\n props: {\n title: \"" + opts.operationData.displayName + " form\",\n siteId: siteId\n }\n }\n}\n\n" + formUpdateHandler + "\n", | ||
content: "import Head from \"next/head\";\nimport React, { useState } from \"react\";\nimport { Auth } from 'netlify-graph-auth';" + ts(opts.netlifyGraphConfig, "\nimport NetlifyGraphAuth = Auth.NetlifyGraphAuth;") + notTs(opts.netlifyGraphConfig, "\n\nconst { NetlifyGraphAuth } = Auth;") + "\n\nexport default function Form(props) {\n const isServer = typeof window === \"undefined\";\n " + form.formHelpers + "\n const [result, setResult] = useState(null);\n const [auth, setAuth] = useState(\n isServer\n ? null\n : new NetlifyGraphAuth({\n siteId: props.siteId,\n })\n );\n\n const submitForm = async () => {\n const res = await fetch(\"" + opts.route + "\", {\n body: JSON.stringify(formVariables),\n headers: {\n \"Content-Type\": \"application/json\",\n ...auth?.authHeaders()\n },\n method: \"POST\"\n });\n\n const formResult = await res.json();\n setResult(formResult);\n };\n\n const needsLoginService = auth?.findMissingAuthServices(result)[0];\n\n return (\n <div className=\"container\">\n <Head>\n <title>" + opts.operationData.displayName + " form</title>\n </Head>\n <main>\n <h1>{props.title}</h1>\n" + addLeftWhitespace(form.formEl, 8) + "\n {needsLoginService ? (\n <button\n onClick={async () => {\n await auth.login(needsLoginService);\n const loginSuccess = await auth.isLoggedIn(needsLoginService);\n if (loginSuccess) {\n console.log(\"Successfully logged into \" + needsLoginService);\n submitForm();\n } else {\n console.log(\"The user did not grant auth to \" + needsLoginService);\n }\n }}\n >\n {`Log in to ${needsLoginService.graphQLField}`}\n </button>) \n : null}\n <pre>{JSON.stringify(formVariables, null, 2)}</pre>\n <pre>{JSON.stringify(result, null, 2)}</pre>\n </main>\n </div>\n )\n}\n\nexport async function getServerSideProps(context) {\n const siteId = process.env.SITE_ID;\n if (!siteId) {\n throw new Error(\"SITE_ID environment variable is not set. Be sure to run `netlify link` before `netlify dev`\");\n }\n\n return {\n props: {\n title: \"" + opts.operationData.displayName + " form\",\n siteId: siteId\n }\n }\n}\n\n" + formUpdateHandler + "\n", | ||
}; | ||
@@ -43,0 +43,0 @@ }; |
{ | ||
"name": "netlify-onegraph-internal", | ||
"version": "0.3.7", | ||
"version": "0.3.8", | ||
"description": "Internal tools for use by Netlify", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
464990
6050