-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Signup Page #55
base: main
Are you sure you want to change the base?
Signup Page #55
Changes from all commits
08b9938
1e5b19d
917bc1d
c68a0ef
991d353
aa37b09
4ba3bef
d6fc7b6
81908d9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,28 @@ | ||
import LanguageSwitcher from "./components/languageSwitcher"; | ||
import External from "./components/translationDemo"; | ||
// import LanguageSwitcher from "./components/languageSwitcher"; | ||
// import External from "./components/translationDemo"; | ||
|
||
export default function Home() { | ||
// export default function Home() { | ||
// return ( | ||
// <div className="grid grid-rows-[20px_1fr_20px] items-center min-h-screen"> | ||
// <main className="flex flex-col gap-8 row-start-2 items-center"> | ||
// {/* Added the LanguageSwitcher component */} | ||
// <LanguageSwitcher /> | ||
// {/* External is my text component */} | ||
// <External></External> | ||
// </main> | ||
// </div> | ||
// ); | ||
// } | ||
import React from "react"; | ||
import Signup from "./signup/page"; | ||
|
||
const Page = () => { | ||
return ( | ||
<div className="grid grid-rows-[20px_1fr_20px] items-center min-h-screen"> | ||
<main className="flex flex-col gap-8 row-start-2 items-center"> | ||
{/* Added the LanguageSwitcher component */} | ||
<LanguageSwitcher /> | ||
{/* External is my text component */} | ||
<External></External> | ||
</main> | ||
<div> | ||
<h1>Signup Page</h1> | ||
<Signup /> | ||
</div> | ||
); | ||
} | ||
}; | ||
|
||
export default Page; |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
"use client"; | ||
|
||
import { zodResolver } from "@hookform/resolvers/zod"; | ||
import React from "react"; | ||
import { useForm } from "react-hook-form"; | ||
import { z } from "zod"; | ||
|
||
const formSchema = z.object({ | ||
firstName: z.string().min(1, "First name is required"), | ||
lastName: z.string().min(1, "Last name is required"), | ||
email: z.string().email("Invalid email address"), | ||
password: z | ||
.string() | ||
.min(8, "Password must be at least 8 characters") | ||
.regex(/[A-Z]/, "Password must contain at least one uppercase letter") | ||
.regex(/[a-z]/, "Password must contain at least one lowercase letter") | ||
.regex(/\d/, "Password must contain at least one number") | ||
.regex(/[!@#$%^&*(),.?":{}|<>]/, "Password must contain at least one special character"), | ||
}); | ||
|
||
type FormData = z.infer<typeof formSchema>; | ||
|
||
const SignUpPage = () => { | ||
const { | ||
register, | ||
handleSubmit, | ||
formState: { errors, isValid }, | ||
} = useForm<FormData>({ | ||
resolver: zodResolver(formSchema), | ||
mode: "onChange", | ||
}); | ||
|
||
const onSubmit = (data: FormData) => { | ||
console.log("Signed Up!", data); | ||
alert("Signed Up!"); | ||
}; | ||
|
||
return ( | ||
<div className="flex flex-col items-center justify-center min-h-screen p-4 bg-primary"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. min-h-screen here is plus the padding added by the layout.tsx is causing the screen to scroll which is not what we want |
||
<div className="w-full max-w-md bg-white p-6 rounded-2xl shadow-md"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. having the max-w-md makes the component width too small |
||
<h1 className="text-2xl font-bold text-left mb-2 text-primary">Get started</h1> | ||
<p className="text-left text-gray-600 mb-6">Welcome to SPAGen</p> | ||
<form onSubmit={handleSubmit(onSubmit)}> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To resolve this linter error you might need to do
and call this new function here instead of handleSubmit |
||
<div className="mb-4 flex space-x-4"> | ||
{/* First Name Input */} | ||
<div className="w-1/2"> | ||
<label className="block text-sm font-medium mb-1 text-black">First Name</label> | ||
<input | ||
{...register("firstName")} | ||
className="w-full p-2 border rounded-lg focus:ring-2 focus:ring-blue-500 placeholder-disabled" | ||
placeholder="Enter your first name" | ||
/> | ||
{errors.firstName && ( | ||
<p className="text-red-500 text-xs mt-1">{errors.firstName.message}</p> | ||
)} | ||
</div> | ||
|
||
{/* Last Name Input */} | ||
<div className="w-1/2"> | ||
<label className="block text-sm font-medium mb-1 text-black">Last Name</label> | ||
<input | ||
{...register("lastName")} | ||
className="w-full p-2 border rounded-lg focus:ring-2 focus:ring-blue-500 placeholder-disabled" | ||
placeholder="Enter your last name" | ||
/> | ||
{errors.lastName && ( | ||
<p className="text-red-500 text-xs mt-1">{errors.lastName.message}</p> | ||
)} | ||
</div> | ||
</div> | ||
|
||
{/* Email Input */} | ||
<div className="mb-4"> | ||
<label className="block text-sm font-medium mb-1 text-black">Enter your email</label> | ||
<input | ||
type="email" | ||
{...register("email")} | ||
className="w-full p-2 border rounded-lg focus:ring-2 focus:ring-blue-500 placeholder-disabled" | ||
placeholder="Enter your email" | ||
/> | ||
{errors.email && <p className="text-red-500 text-xs mt-1">{errors.email.message}</p>} | ||
</div> | ||
|
||
{/* Create a Password */} | ||
<div className="mb-4"> | ||
<label className="block text-sm font-medium mb-1 text-black">Create a Password</label> | ||
<input | ||
type="password" | ||
{...register("password")} | ||
className="w-full p-2 border rounded-lg focus:ring-2 focus:ring-blue-500 placeholder-disabled" | ||
placeholder="Create a password" | ||
/> | ||
{errors.password && ( | ||
<p className="text-red-500 text-xs mt-1">{errors.password.message}</p> | ||
)} | ||
</div> | ||
|
||
<div className="flex justify-end"> | ||
<button | ||
type="submit" | ||
disabled={!isValid} | ||
className={`w-30 p-2 rounded-lg font-bold text-white mt-4 ${ | ||
isValid ? "bg-primary hover:bg-primary-dark" : "bg-gray-300 cursor-not-allowed" | ||
}`} | ||
> | ||
Continue | ||
</button> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default SignUpPage; |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There should be no package files in the root |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There should be no backage files in the root. did you install react-hook-form by mistake in the root? This should be in the frontend folder and react-hook-form is missing |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"dependencies": { | ||
"@hookform/resolvers": "^3.10.0", | ||
"react-hook-form": "^7.54.2", | ||
"zod": "^3.24.1" | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keep the original page.tsx file.