Skip to content

Conversation

@gchyuli
Copy link
Contributor

@gchyuli gchyuli commented Apr 25, 2025

📝 Replace useState with React Hook Form and update form layout

🛠️ Issue

📖 Description

This PR refactors the Profile Page to improve form state management and validation. We replaced the use of local useState and manual onChange handlers with [React Hook Form](https://react-hook-form.com/) and [Zod](https://zod.dev/) for schema-based validation. The form layout was also updated to use shadcn/ui components for consistency and better UX.

✅ Changes made

  • Integrated React Hook Form with a Zod schema (formSchema) to validate fields such as first name, last name, email, and country.
  • Replaced raw HTML elements with shadcn/ui components:
    Form, FormField, FormItem, FormControl, and FormMessage.
  • Displayed validation error messages below each input using <FormMessage>, preserving translation keys.
  • Kept the Stellar Wallet field disabled and non-editable as required.
  • Integrated the custom CountrySelect component with React Hook Form, syncing its internal state with the form value.
  • Maintained full internationalization support by using useTranslations() for all field labels and messages.

🖼️ Media (screenshots/videos)

image
image

📜 Additional Notes

  • This refactor aligns the Profile Page with the platform's UI/UX standards and improves scalability for future form enhancements.

@derianrddev derianrddev added frontend ODHack13 This issue will be available ONLY during the ODHack13 labels Apr 25, 2025
Copy link
Contributor

@derianrddev derianrddev left a comment

Choose a reason for hiding this comment

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

Hello @gchyuli

Some translation keys are missing — especially under profile.validation (e.g., nameRequired, surnameRequired, emailInvalid, countryRequired).

These should be included in the en.ts and es.ts files inside frontend/locales, specifically under the profile section.
You can organize them inside a nested validation object like this:

profile: {
  ...
  validation: {
    nameRequired: "Name is required",
    emailInvalid: "Invalid email format",
    countryRequired: "Country is required",
    ...
  }
}

image

image

Also, please apply the other requested changes from the review.
Once that's done, this will be ready to merge!

"@nestjs/mapped-types": "*",
"@nestjs/platform-express": "^11.0.7",
"@prisma/client": "^6.3.1",
"backend": "file:",
Copy link
Contributor

Choose a reason for hiding this comment

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

This "backend": "file:" entry looks unintended — please remove it.

Copy link
Contributor

Choose a reason for hiding this comment

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

This "frontend": "file:" entry seems accidental — it can be safely removed.

package.json Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

The "safeswap": "file:" entry doesn’t point to a valid local package — consider removing it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove package-lock.json from apps/backend — it's not needed in a workspace project using a single root lockfile.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove package-lock.json from apps/frontend

@gchyuli gchyuli requested a review from derianrddev April 26, 2025 05:58
Copy link
Contributor

@derianrddev derianrddev left a comment

Choose a reason for hiding this comment

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

Great job! Thank you very much!

@derianrddev derianrddev merged commit 1c9e67e into Kaizenode:main Apr 26, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend ODHack13 This issue will be available ONLY during the ODHack13

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT]: Refactor Profile Page with React Hook Form + Zod

2 participants