Skip to content
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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
39 changes: 38 additions & 1 deletion frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
"prepare": "cd .. && husky"
},
"dependencies": {
"@hookform/resolvers": "^3.10.0",
"i18next": "^24.2.1",
"i18next-browser-languagedetector": "^8.0.2",
"next": "15.1.3",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"react-i18next": "^15.4.0"
"react-i18next": "^15.4.0",
"zod": "^3.24.1"
},
"devDependencies": {
"@eslint/eslintrc": "^3",
Expand Down
35 changes: 24 additions & 11 deletions frontend/src/app/page.tsx
Copy link
Member

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.

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";

Check warning on line 16 in frontend/src/app/page.tsx

View workflow job for this annotation

GitHub Actions / Frontend lint and style check

There should be at least one empty line between import groups
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;
115 changes: 115 additions & 0 deletions frontend/src/app/signup/page.tsx
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
Still doesn't match the designs.

Becaues of the way next.js works

the purple background should be applied conditionally in the layout.tsx page inside the app folder
because layout.tsx adds a padding which the thing giving you a white surrounding

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">
Copy link
Member

Choose a reason for hiding this comment

The 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">
Copy link
Member

Choose a reason for hiding this comment

The 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)}>

Check failure on line 43 in frontend/src/app/signup/page.tsx

View workflow job for this annotation

GitHub Actions / Frontend lint and style check

Promise-returning function provided to attribute where a void return was expected
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To resolve this linter error you might need to do

  const handleFormSubmit = (event: React.FormEvent<HTMLFormElement>) => {
    event.preventDefault();
    void handleSubmit(onSubmit)();
  };

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;
2 changes: 2 additions & 0 deletions frontend/tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export default {
colors: {
background: "var(--background)",
foreground: "var(--foreground)",
primary: "#3B3B62",
disabled: "#COC8CB",
},
},
},
Expand Down
58 changes: 58 additions & 0 deletions package-lock.json
Copy link
Member

Choose a reason for hiding this comment

The 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.

7 changes: 7 additions & 0 deletions package.json
Copy link
Member

Choose a reason for hiding this comment

The 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"
}
}
Loading