Skip to content

Conversation

@ErikaKK
Copy link
Contributor

@ErikaKK ErikaKK commented Sep 17, 2025

Change Summary

[Briefly summarise the changes that you made. Just high-level stuff]

  • Added user change password view
  • adjusted profile page and user dashboard page
  • updated Clerk
image image - When see other people's profile image

Change Form

Fill this up (NA if not available). If a certain criteria is not met, can you please give a reason.

  • The pull request title has an issue number
  • The change works by "Smoke testing" or quick testing
  • The change has tests
  • The change has documentation

Other Information

[Is there anything in particular in the review that I should be aware of?]

@ErikaKK ErikaKK linked an issue Sep 17, 2025 that may be closed by this pull request
@vercel
Copy link

vercel bot commented Sep 17, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
website Ready Ready Preview Comment Sep 19, 2025 2:02am

@ErikaKK ErikaKK requested a review from Copilot September 17, 2025 15:34
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements a user change password feature by consolidating user settings, adding email change functionality, and updating the Clerk authentication integration. The changes streamline the user settings interface by merging social profile fields into the main personal form and replacing the separate socials tab with email management.

  • Consolidated social fields (GitHub, Discord, subscription preferences) into the personal details form
  • Added a new email change feature with OTP verification using Clerk
  • Updated Clerk client usage patterns across the codebase for consistency

Reviewed Changes

Copilot reviewed 21 out of 22 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/server/api/routers/users/update.ts Added GitHub, Discord, and subscription fields; enhanced error handling and Clerk metadata storage
src/server/api/routers/users/update-socials.ts Removed separate socials update endpoint
src/server/api/routers/users/update-email.ts Added new email update endpoint with Clerk integration
src/server/api/routers/users/index.ts Replaced updateSocials with updateEmail in router exports
src/middleware.ts Updated Clerk auth usage to use session-based pattern
src/app/profile/settings/@personal/form.tsx Integrated social fields and subscription checkbox into personal form
src/app/profile/settings/@email/form.tsx Added email change form with OTP verification
package.json Updated Clerk dependencies to newer versions
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 23 out of 24 changed files in this pull request and generated 4 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

import { TRPCError } from "@trpc/server"
import { Ratelimit } from "@upstash/ratelimit"
import { eq, sql } from "drizzle-orm"
import type { InferSelectModel } from "drizzle-orm"
Copy link

Copilot AI Sep 18, 2025

Choose a reason for hiding this comment

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

The InferSelectModel import is unused in this file. Remove the unused import to keep the code clean.

Copilot uses AI. Check for mistakes.
import { useReverification, useUser } from "@clerk/nextjs"
import { EmailAddressResource } from "@clerk/types"
import { zodResolver } from "@hookform/resolvers/zod"
import { se } from "date-fns/locale"
Copy link

Copilot AI Sep 18, 2025

Choose a reason for hiding this comment

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

The se import from date-fns/locale is unused in this file. Remove the unused import.

Suggested change
import { se } from "date-fns/locale"

Copilot uses AI. Check for mistakes.
} catch (err: unknown) {
// Narrow the error type
if (err instanceof Error) {
throw new Error(`Failed to update user metadata: ${err?.message}`)
Copy link

Copilot AI Sep 18, 2025

Choose a reason for hiding this comment

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

The optional chaining err?.message is unnecessary since you've already narrowed the type to Error in the previous condition. Use err.message directly.

Suggested change
throw new Error(`Failed to update user metadata: ${err?.message}`)
throw new Error(`Failed to update user metadata: ${err.message}`)

Copilot uses AI. Check for mistakes.
Comment on lines 107 to 110
toast({
title: "Update successful",
description: "Your personal details have been updated successfully.",
})
Copy link

Copilot AI Sep 18, 2025

Choose a reason for hiding this comment

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

The success toast is being shown in the onSubmit function, but the mutation might still fail. Move this toast to the onSuccess callback of the mutation to ensure it only shows when the update actually succeeds.

Copilot uses AI. Check for mistakes.
@ErikaKK ErikaKK linked an issue Sep 19, 2025 that may be closed by this pull request
@ErikaKK ErikaKK requested a review from Copilot September 19, 2025 02:03
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 23 out of 24 changed files in this pull request and generated 4 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

// )

try {
await updateClerkUserEmail(user, clerkUser.primaryEmailAddressId)
Copy link

Copilot AI Sep 19, 2025

Choose a reason for hiding this comment

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

The function updateClerkUserEmail is called with user and clerkUser.primaryEmailAddressId but the function definition expects userId: string, oldEmailAddressId: string, newEmailAddress: string. The parameters don't match the expected signature.

Copilot uses AI. Check for mistakes.
return user
})

const updateClerkUserEmail = async (user: InferSelectModel<typeof User>, oldEmailAddressId: string) => {
Copy link

Copilot AI Sep 19, 2025

Choose a reason for hiding this comment

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

The function signature expects 2 parameters but is called with 3 parameters on line 56. Either update the function signature to accept newEmailAddress: string as the third parameter or fix the function call.

Copilot uses AI. Check for mistakes.
title: "Email updated",
description: "Your email has been updated successfully.",
})
window.location.reload()
Copy link

Copilot AI Sep 19, 2025

Choose a reason for hiding this comment

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

Using window.location.reload() forces a full page refresh which can disrupt user experience. Consider using the router to navigate or update the UI state instead.

Copilot uses AI. Check for mistakes.
Comment on lines +73 to +74
github: input.github?.trim(),
discord: input.discord?.trim(),
Copy link

Copilot AI Sep 19, 2025

Choose a reason for hiding this comment

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

The trim() method is called on potentially undefined values. This will throw an error if input.github or input.discord is undefined. Use input.github?.trim() ?? null or similar.

Suggested change
github: input.github?.trim(),
discord: input.discord?.trim(),
github: input.github?.trim() ?? null,
discord: input.discord?.trim() ?? null,

Copilot uses AI. Check for mistakes.
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.

User Clerk metadata Add update email verification

2 participants