Anonymous-Feedback is a application the gather the feedback from random users about you or your product. It is a full stack application built using NextJS.
Using ZOD for validation.
In NextJS, the server is not running every time it runs on demand. So we have to take care of the things like if we are already connected to the database or not.
Code should effectively handle both scenarios of registering a new user and updating an existing but unverified user account with a new password and verification code.
- Algorithm
IF existingUserByEmail EXISTS THEN
IF existingUserByEmail.isVerified THEN
success: false
ELSE
// Save the updated user
END IF
ELSE
// create a new user with the provided details
// Save the new user
END IF
- Using
resend email
for email verification - Using
react email
for email templates
- Implementing the Algorithm for sign-up
- Writing code for Sending OTP for verification
- We are using
next-auth
for signup. - We are simply using credentials to sign up the user. For that we are using
credentials
feature from Next-auth.
providers: [
// Here we are creating a component for sign up. By using this below information, next-auth will create a component for signup which will render on the screen
CredentialsProvider({
id: "credentials",
name: "Credentials",
credentials: {
email: {
label: "Email",
type: "text",
placeholder: "Enter password",
},
password: {
label: "Password",
type: "password",
placeholder: "Enter password",
},
},
async authorize(credentials: any): Promise<any> {
await dbConnect();
try {
const user = await UserModel.findOne({
$or: [
{email: credentials.identifier},
{username: credentials.identifier}
]
})
if (!user) {
throw new Error("No user found")
}
if(!user.isVerified) {
throw new Error("Please verify your account before login.")
}
} catch (error: any) {
throw new Error(error);
}
},
}),
],
- Check for unique username.
- OTP verification
- Create routes for accepting messages
- Create routes for get-messages
- Create routes for send-messages
- Integrate the Gemini AI for suggesting messages.
- Shadcn installation
- using
useHooks-ts
library to handle debouncing - React hook form
- Handling debouncing in sign-up page form
- Create UI for Verify Code and handle the verification.
- Creating a SignIp page and handling the sign in using next-auth's Credentials
- Design a Navbar component
- Fix the Redirect Bug
- Create MessageCard Component
- And Added Delete Route also
- Build the User dashboard.
- Handle the accept-messages switch with the React-hook forms to maintain the code consistency.
- Build the Home page of our application
- Use the Carousal component of shadcn UI