Skip to content

feat: make username required and add Share Guild Card button#229

Open
sadhami0519 wants to merge 7 commits into
LarytheLord:mainfrom
sadhami0519:feat-profile-share-flow
Open

feat: make username required and add Share Guild Card button#229
sadhami0519 wants to merge 7 commits into
LarytheLord:mainfrom
sadhami0519:feat-profile-share-flow

Conversation

@sadhami0519
Copy link
Copy Markdown
Contributor

What this does

Users without a username would 404 on their Guild Card. This makes username required at the schema level, adds a username input field at registration, and adds a Share Guild Card button to the adventurer dashboard so users can view and copy their Guild Card link.

Issue

Closes #166

Changes

  • prisma/schema.prisma — removed ? from username field, making it required
  • prisma/seed.ts — added username to all seed users to match the required field
  • app/api/auth/register/route.ts — added username field to schema validation and uniqueness check
  • app/register/page.tsx — added username input field to adventurer registration form
  • app/dashboard/page.tsx — added username to user select query, added <ShareGuildCard> component below rank chips
  • components/guild/ShareGuildCard.tsx — new client component with Guild Card link and copy to clipboard button

Schema changes

username String @unique (was String? @unique)

Test plan

  • Register a new user with a username and confirm it saves
  • Try registering with a taken username and confirm error shows
  • Visit /guild/[username] and confirm it loads
  • Check Share Guild Card button appears on the adventurer dashboard
  • Click Copy link and confirm toast shows "Guild Card link copied!"
  • npm run lint → 0 errors
  • npm run type-check → 0 errors
  • npm run build → passes

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 9, 2026

@sadhami0519 is attempting to deploy a commit to the larythelord's projects Team on Vercel.

A member of the Team first needs to authorize it.

@sadhami0519
Copy link
Copy Markdown
Contributor Author

sadhami0519 commented May 9, 2026

Hey @LarytheLord -- npm run type-check has been showing errors on payment-related files and a test file. Not sure how to proceed with this. Everything else seems to work fine.

@LarytheLord
Copy link
Copy Markdown
Owner

Thanks for this contribution! The feature is well-scoped and the UI/UX additions (Share Guild Card, username field) are solid.

One important caveat: This PR requires a schema migration to add the username field to the User model. Before merging, we'll need to:

  1. Add username String? @unique to prisma/schema.prisma
  2. Run npx prisma migrate dev --name add_username_field
  3. Update the user creation/update API routes to handle the new field

Also note: There are pre-existing test file errors in the repo (eslint-disable-next-line scope issues) that aren't blockers for this PR, but you may see them in local builds.

Once the schema migration is in place, this is ready to merge! 🎯

@sadhami0519
Copy link
Copy Markdown
Contributor Author

Hi, thanks for the review! Just to clarify, the schema change is already included in this PR. prisma/schema.prisma has been updated to username String @unique (without the ?) as specified in Issue #166. The migration just needs to be run on your end before merging. Let me know if anything else needs to be addressed.

For the API routes, yes I handled it. Updated app/api/auth/register/route.ts to validate and save the username.

@LarytheLord
Copy link
Copy Markdown
Owner

Cool @sadhami0519 sorry about that I pointed that because the CI/lint and the github check failed due to few reasons could you look into that see what went wrong

@sadhami0519
Copy link
Copy Markdown
Contributor Author

sadhami0519 commented May 15, 2026

Hey @LarytheLord, Lint passes with 0 errors. The warnings are all in pre-existing files I didn't touch. The type-check failures are also in pre-existing test files. None of these were introduced by this PR. Let me know if I should work on these in this PR or if that will be handled seperately.

@LarytheLord
Copy link
Copy Markdown
Owner

Code Review — PR #229: Username + Share Guild Card

Overall: ✅ Good to merge

The implementation is solid and well-scoped. Here's the breakdown:

What's great:

  • Username validation regex is correct: /^[a-z0-9]+$/ — only lowercase alphanumerics, prevents issues
  • Username uniqueness check before insert is correct
  • Auto-generated fallback when no username provided
  • ShareGuildCard component is clean and minimal
  • Seed data updated with usernames for all existing users

Minor suggestions (non-blocking):

  • app/register/page.tsx — the username field is marked required but the schema says optional(). If you want it required on the form, either enforce it in the schema too (z.string().min(3)...) or keep it optional and hide the field for companies. Currently company registration would send undefined for username, which works fine since the schema allows it.
  • components/guild/ShareGuildCard.tsx — using asChild on the button wrapping a Link is fine, but consider adding target="_blank" with rel="noopener noreferrer" if the guild card page opens external links.
  • No trailing newline in ShareGuildCard.tsx — minor linting issue.

Schema change:

  • Making username non-nullable is a breaking change. Existing users with username = null exist in production. You may want a migration to backfill usernames for them. Confirm this is acceptable before merging.

Missing consideration:

  • /guild/${username} route doesn't exist yet — the ShareGuildCard links to /guild/[username] but there's no page handler for it. This should either be created as part of this PR or tracked as a follow-up issue.

Verdict: ✅ Approve with note about /guild/[username] route

The username feature is well-implemented. The /guild/username page needs to be built for the share card to work — either add it to this PR or create an issue for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Guild Card — username required at registration + profile share flow

2 participants