Skip to content

feat(navbar): update item label based on auth status#514

Merged
MrgSub merged 1 commit intoMail-0:stagingfrom
pietrodev07:feature/auth-navbar
Mar 25, 2025
Merged

feat(navbar): update item label based on auth status#514
MrgSub merged 1 commit intoMail-0:stagingfrom
pietrodev07:feature/auth-navbar

Conversation

@pietrodev07
Copy link
Contributor

@pietrodev07 pietrodev07 commented Mar 25, 2025

Description

Added the feature that update item label based on auth status


Type of Change

Please delete options that are not relevant.

  • 🎨 UI/UX improvement

Areas Affected

Please check all that apply:

  • User Interface/Experience

Testing Done

Describe the tests you've done:

  • Manual testing performed
  • Cross-browser testing (if UI changes)
  • Mobile responsiveness verified (if UI changes)

Checklist

  • I have read the CONTRIBUTING document
  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • My changes generate no new warnings

By submitting this pull request, I confirm that my contribution is made under the terms of the project's license.

Summary by CodeRabbit

  • New Features
    • Updated the navigation bar so that the link text now changes dynamically: authenticated users see "Dashboard" while others see "Sign in".

@vercel
Copy link

vercel bot commented Mar 25, 2025

@pietrodev07 is attempting to deploy a commit to the Zero Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 25, 2025

Walkthrough

This pull request adds a new import for the useSession hook from @/lib/auth-client in the Navbar component. The component now uses useSession to obtain session data and conditionally render the text inside a Link element, displaying "Dashboard" when a session exists and "Sign in" when it does not.

Changes

Files Change Summary
apps/.../navbar.tsx Added import for useSession from @/lib/auth-client and implemented conditional rendering of "Dashboard" or "Sign in" based on session data.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant N as Navbar Component
    participant S as useSession Hook
    participant L as Link Element
    U->>N: Visit Home
    N->>S: Retrieve session data
    S-->>N: Return session (or null)
    alt Session Exists
        N->>L: Render "Dashboard"
    else No Session
        N->>L: Render "Sign in"
    end
Loading

Suggested reviewers

  • needleXO

Poem

I hop with glee through lines of code,
Session checks lighten my humble abode.
"Dashboard" beams when the session's bright,
"Sign in" calls in the quiet night.
🐰 Hoppity cheers for changes just right!

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🔭 Outside diff range comments (1)
apps/mail/components/home/navbar.tsx (1)

81-86: 🛠️ Refactor suggestion

Consider updating both the link text and its destination based on authentication status.

While the link text now correctly changes based on authentication status, the href attribute remains static. For authenticated users, clicking "Dashboard" should navigate to a dashboard page rather than the login page.

<Link
-  href="login"
+  href={session ? "/dashboard" : "/login"}
  className="text-sm text-gray-800 transition-opacity hover:opacity-80 dark:bg-gradient-to-r dark:from-gray-300 dark:via-gray-100 dark:to-gray-200 dark:bg-clip-text dark:text-transparent"
>
  {session ? "Dashboard": "Sign in"}
</Link>
🧹 Nitpick comments (1)
apps/mail/components/home/navbar.tsx (1)

38-76: Apply authentication-aware navigation to mobile view.

The conditional text based on authentication status has been applied to the desktop navigation but not to the mobile navigation menu. Consider updating the mobile navigation to maintain consistency across viewport sizes.

Consider adding a similar conditional text somewhere in the mobile navigation sheet to maintain consistency with the desktop experience.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between db00358 and 1650306.

📒 Files selected for processing (1)
  • apps/mail/components/home/navbar.tsx (3 hunks)
🔇 Additional comments (4)
apps/mail/components/home/navbar.tsx (4)

4-4: Good addition of the useSession hook.

Adding the useSession hook is a good approach for accessing authentication state, making the UI responsive to user login status.


13-13: Clean implementation of session data destructuring.

The destructuring pattern follows React best practices and provides clear variable naming.


87-92: Review "Get Started" button behavior for authenticated users.

The "Get Started" button always directs to "/login" regardless of authentication status. Consider whether this button should be hidden or changed for authenticated users to maintain consistency with the Sign in/Dashboard link.

Does a logged-in user still need to see a "Get Started" button directing them to the login page? Consider:

{!session && (
  <Button
    className="h-[32px] w-[110px] rounded-md bg-gray-900 text-white hover:bg-black dark:bg-white dark:text-black dark:hover:bg-white/90"
    asChild
  >
    <Link href="/login">Get Started</Link>
  </Button>
)}

78-102: Verify environment-based rendering logic.

The component renders different content based on whether it's in a development environment. This approach might not be suitable for production features. Consider refactoring to use a feature flag or configuration setting instead of relying on NODE_ENV.

Is the environment check intentional for this feature? If this is a permanent feature, it should work consistently across all environments.

@vercel
Copy link

vercel bot commented Mar 25, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
0 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 25, 2025 8:49pm

@MrgSub MrgSub merged commit 63bccd5 into Mail-0:staging Mar 25, 2025
3 checks passed
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.

2 participants