diff --git a/docs/r/forgot-password-template.json b/docs/r/forgot-password-template.json new file mode 100644 index 0000000..e1caac5 --- /dev/null +++ b/docs/r/forgot-password-template.json @@ -0,0 +1,14 @@ +{ + "name": "forgot-password-template", + "type": "registry:block", + "category": "generators", + "subcategory": "dbAuth", + "registryDependencies": ["button", "card", "input", "label"], + "files": [ + { + "path": "dbAuth/forgotPassword.tsx.template", + "content": "import { useEffect, useRef } from 'react'\n\nimport { FieldError, Form, Label, TextField } from '@redwoodjs/forms'\nimport { navigate, routes } from '@redwoodjs/router'\nimport { Metadata } from '@redwoodjs/web'\nimport { toast, Toaster } from '@redwoodjs/web/toast'\n\nimport { useAuth } from 'src/auth'\nimport { Button } from '@/registry/default/ui/Button'\nimport {\n Card,\n CardContent,\n CardDescription,\n CardHeader,\n CardTitle,\n} from '@/registry/default/ui/Card'\n\nconst ForgotPasswordPage = () => {\n const { isAuthenticated, forgotPassword } = useAuth()\n\n useEffect(() => {\n if (isAuthenticated) {\n navigate(routes.home())\n }\n }, [isAuthenticated])\n\n const ${usernameCamelCase}Ref = useRef(null)\n useEffect(() => {\n ${usernameCamelCase}Ref?.current?.focus()\n }, [])\n\n const onSubmit = async (data: { ${usernameCamelCase}: string }) => {\n const response = await forgotPassword(data.${usernameCamelCase})\n\n if (response.error) {\n toast.error(response.error)\n } else {\n // The function `forgotPassword.handler` in api/src/functions/auth.js has\n // been invoked, let the user know how to get the link to reset their\n // password (sent in email, perhaps?)\n // toast.success(\n // 'A link to reset your ${passwordLowerCase} was sent to ' + response.email\n // )\n navigate(routes.login())\n }\n }\n\n return (\n <>\n \n\n
\n \n \n \n Forgot ${passwordTitleCase}\n \n Enter your ${usernameTitleCase} below and click Submit\n \n \n \n
\n
\n
\n \n ${usernameTitleCase}\n \n \n\n \n
\n\n \n
\n
\n
\n
\n
\n \n )\n}\n\nexport default ForgotPasswordPage\n", + "type": "registry:page" + } + ] +} diff --git a/docs/r/signup-template.json b/docs/r/signup-template.json index 943b43f..4203407 100644 --- a/docs/r/signup-template.json +++ b/docs/r/signup-template.json @@ -3,17 +3,12 @@ "type": "registry:block", "category": "generators", "subcategory": "dbAuth", - "registryDependencies": [ - "button", - "card", - "input", - "label" - ], + "registryDependencies": ["button", "card", "input", "label"], "files": [ { "path": "dbAuth/signup.tsx.template", - "content": "import { useEffect, useRef } from 'react'\n\nimport {\n Form,\n Label,\n TextField,\n PasswordField,\n FieldError,\n} from '@redwoodjs/forms'\nimport { Link, navigate, routes } from '@redwoodjs/router'\nimport { Metadata } from '@redwoodjs/web'\nimport { toast, Toaster } from '@redwoodjs/web/toast'\n\nimport { useAuth } from 'src/auth'\nimport { Button } from 'src/components/ui/Button'\nimport {\n Card,\n CardContent,\n CardDescription,\n CardHeader,\n CardTitle,\n} from 'src/components/ui/Card'\n\nconst SignupPage = () => {\n const { isAuthenticated, signUp } = useAuth()\n\n useEffect(() => {\n if (isAuthenticated) {\n navigate(routes.home())\n }\n }, [isAuthenticated])\n\n // focus on ${usernameLowerCase} box on page load\n const ${usernameCamelCase}Ref = useRef(null)\n useEffect(() => {\n ${usernameCamelCase}Ref.current?.focus()\n }, [])\n\n const onSubmit = async (data: Record) => {\n const response = await signUp({ username: data.${usernameCamelCase}, password: data.${passwordCamelCase} })\n\n if (response.message) {\n toast(response.message)\n } else if (response.error) {\n toast.error(response.error)\n } else {\n // user is signed in automatically\n toast.success('Welcome!')\n }\n }\n\n return (\n <>\n \n\n
\n \n\n \n \n Signup\n \n Enter your ${usernameLowerCase} and desired ${passwordLowerCase}\n below to create to your account\n \n \n \n
\n
\n
\n \n ${usernameTitleCase}\n \n \n\n \n
\n\n
\n \n ${passwordTitleCase}\n \n \n\n \n
\n\n \n
\n
\n
\n
\n
\n Already have an account?{' '}\n \n Log in!\n \n
\n
\n \n )\n}\n\nexport default SignupPage\n", + "content": "import { useEffect, useRef } from 'react'\n\nimport {\n FieldError,\n Form,\n Label,\n PasswordField,\n TextField,\n} from '@redwoodjs/forms'\nimport { Link, navigate, routes } from '@redwoodjs/router'\nimport { Metadata } from '@redwoodjs/web'\nimport { toast, Toaster } from '@redwoodjs/web/toast'\n\nimport { useAuth } from 'src/auth'\nimport { Button } from '@/registry/default/ui/Button'\nimport {\n Card,\n CardContent,\n CardDescription,\n CardHeader,\n CardTitle,\n} from '@/registry/default/ui/Card'\n\nconst SignupPage = () => {\n const { isAuthenticated, signUp } = useAuth()\n\n useEffect(() => {\n if (isAuthenticated) {\n navigate(routes.home())\n }\n }, [isAuthenticated])\n\n // focus on ${usernameLowerCase} box on page load\n const ${usernameCamelCase}Ref = useRef(null)\n useEffect(() => {\n ${usernameCamelCase}Ref.current?.focus()\n }, [])\n\n const onSubmit = async (data: Record) => {\n const response = await signUp({ username: data.${usernameCamelCase}, password: data.${passwordCamelCase} })\n\n if (response.message) {\n toast(response.message)\n } else if (response.error) {\n toast.error(response.error)\n } else {\n // user is signed in automatically\n toast.success('Welcome!')\n }\n }\n\n return (\n <>\n \n\n
\n \n\n \n \n Signup\n \n Enter your ${usernameLowerCase} and desired ${passwordLowerCase}\n below to create to your account\n \n \n \n
\n
\n
\n \n ${usernameTitleCase}\n \n \n\n \n
\n\n
\n \n ${passwordTitleCase}\n \n \n\n \n
\n\n \n
\n
\n
\n
\n
\n Already have an account?{' '}\n \n Log in!\n \n
\n
\n \n )\n}\n\nexport default SignupPage\n", "type": "registry:page" } ] -} \ No newline at end of file +}