Skip to content

Dominick/639 feat: add user account link to sidebar#651

Open
HoldUpFjord wants to merge 22 commits intodevelopfrom
dominick/639-feat-add-user-account-link-to-sidebar
Open

Dominick/639 feat: add user account link to sidebar#651
HoldUpFjord wants to merge 22 commits intodevelopfrom
dominick/639-feat-add-user-account-link-to-sidebar

Conversation

@HoldUpFjord
Copy link
Copy Markdown
Contributor

Added a link to navbar for the account/profile route.

Component view:
image
Page View
image

@appwrite
Copy link
Copy Markdown

appwrite Bot commented Nov 4, 2024

Gridiron Survivor Application 6616ea581ef9f5521c7d

Function ID Status Action
Your function has been successfully deployed.

Project name: Gridiron Survivor Application
Project ID: 6616ea581ef9f5521c7d

Function ID Status Action
userAuth 6626fef885a9f630442b ready Ready View Logs

Only deployments on the production branch are activated automatically. If you'd like to activate this deployment, navigate to your deployments. Learn more about Appwrite Function deployments.

💡 Did you know?
You can use Avatars API to generate QR code for any text or URLs

@vercel
Copy link
Copy Markdown

vercel Bot commented Nov 4, 2024

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

Name Status Preview Comments Updated (UTC)
gridiron-survivor ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 20, 2024 8:06pm
gridiron-survivor-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 20, 2024 8:06pm

mhchen
mhchen previously approved these changes Nov 4, 2024
Copy link
Copy Markdown
Contributor

@mhchen mhchen left a comment

Choose a reason for hiding this comment

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

If you're feeling bold I think you should refactor this into a NavLink component, since all 3 navlinks are pretty much identical except for the href/testid

@braydoncoyer
Copy link
Copy Markdown

Do we want any tests for this change? I see a data-testid added but no associated test.

@HoldUpFjord
Copy link
Copy Markdown
Contributor Author

@mhchen I think that makes a lot of sense. I'm feeling up to it. Just to clarify, this navlink refactor would be a part of this PR as opposed to making another ticket/pr for the refactor at a later time?

@braydoncoyer That's another question I had! The other links have tests written for them in the nav.test file. I wasn't sure if it would be out of scope to add a test for this or not. My opinion is it can't hurt to add it, and there's already a reference I can work off of. It seems like a easy pickup.

@shashilo
Copy link
Copy Markdown
Collaborator

shashilo commented Nov 9, 2024

@mhchen I think that makes a lot of sense. I'm feeling up to it. Just to clarify, this navlink refactor would be a part of this PR as opposed to making another ticket/pr for the refactor at a later time?

@braydoncoyer That's another question I had! The other links have tests written for them in the nav.test file. I wasn't sure if it would be out of scope to add a test for this or not. My opinion is it can't hurt to add it, and there's already a reference I can work off of. It seems like a easy pickup.

If you touch it, you test it.

@shashilo
Copy link
Copy Markdown
Collaborator

shashilo commented Nov 9, 2024

@mhchen I think that makes a lot of sense. I'm feeling up to it. Just to clarify, this navlink refactor would be a part of this PR as opposed to making another ticket/pr for the refactor at a later time?

@braydoncoyer That's another question I had! The other links have tests written for them in the nav.test file. I wasn't sure if it would be out of scope to add a test for this or not. My opinion is it can't hurt to add it, and there's already a reference I can work off of. It seems like a easy pickup.

When you come acrosss items that are repetitive, you should always look into componetizing them. It's easier to maintain and the code is only in 1 place.

@HoldUpFjord
Copy link
Copy Markdown
Contributor Author

@mhchen I think that makes a lot of sense. I'm feeling up to it. Just to clarify, this navlink refactor would be a part of this PR as opposed to making another ticket/pr for the refactor at a later time?
@braydoncoyer That's another question I had! The other links have tests written for them in the nav.test file. I wasn't sure if it would be out of scope to add a test for this or not. My opinion is it can't hurt to add it, and there's already a reference I can work off of. It seems like a easy pickup.

When you come acrosss items that are repetitive, you should always look into componetizing them. It's easier to maintain and the code is only in 1 place.

Great, thanks for the clarification. I'll get right on it!

Comment thread pnpm-lock.yaml
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why was this file changed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Because I'm not the brightest tool in the shed.

It's a mistake that's since been reverted.

kepsteen
kepsteen previously approved these changes Nov 14, 2024
Comment thread components/Nav/Nav.tsx Outdated
kepsteen
kepsteen previously approved these changes Nov 16, 2024
Copy link
Copy Markdown
Contributor

@kepsteen kepsteen left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Copy Markdown

@braydoncoyer braydoncoyer left a comment

Choose a reason for hiding this comment

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

LGTM! ✅

Comment thread components/Nav/Nav.tsx Outdated
import { Menu } from 'lucide-react';
import { Button } from '../Button/Button';
import Link from 'next/link';
import NavLink from '../NavLink/NavLink'; // Adjust the import path as necessary
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

remove comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed!

Comment thread components/Nav/Nav.tsx
* Handles closing the drawer.
* @returns {void} No return value.
*/
const handleClose = (): void => setOpen(false);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why do we need a variable to call this useState directly?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I was getting the following error if I didn't declare the useState directly:

Would you prefer this bit implemented differently?
image

Comment thread components/Nav/Nav.tsx
Leagues
</Link>
</li>
<NavLink
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nicely done!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thank you!

href: string;
testId: string;
children: React.ReactNode;
onClose?: () => void;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why is onClose optional?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I may be misunderstanding, but my line of thought was it needed to be optional because onClose it's a function that's toggled on click. The nature of the toggle indicating that the onClose function is always 'provided'/there.

Comment thread components/NavLink/NavLink.tsx Outdated

/**
* Renders a navigation link.
* @param {NavLinkProps} props - The properties for the navigation link.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: Call out all the props

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Something like this format? This example doesn't handle other nits.

/**
 * Renders a navigation link.
 * @param {string} props.href - The URL the link points to.
 * @param {string} props.testId - The test ID for the link.
 * @param {React.ReactNode} props.children - The content to be rendered inside the link.
 * @param {Function} [props.onClose] - Optional function to be called when the link is clicked.
 * @returns {JSX.Element} The rendered navigation link.
 */

className={cn(
'underline underline-offset-4 hover:text-primary-muted transition-colors',
)}
onClick={onClose}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

If this was optional, this code should fail.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oh that's true. If it was optional, would the better way of handling it defining a variable that states its conditional and then testing that? Something like:"

const NavLink = ({
  href,
  testId,
  children,
  onClose,
}: NavLinkProps): JSX.Element => {
  const handleClick = () => {
    if (onClose) {
      onClose();
    }
  };

  return (
    <a href={href} data-testid={testId} onClick={handleClick}>
      {children}
    </a>
  );
};

Comment thread components/Nav/Nav.tsx
@@ -69,28 +75,27 @@ export const Nav = (): JSX.Element => {
<DrawerTitle data-testid="title">Gridiron Survivor</DrawerTitle>
</DrawerHeader>
<ul className="m-0 flex flex-col gap-1 p-0">
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: could go as far as making this NavLinkContainer component.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't quite understand what you mean here. Are you thinking NavLinkContainer would be a new component leveraging the <Drawer/> component?

// Copyright (c) Gridiron Survivor.
// Licensed under the MIT License.

import React, { JSX } from 'react';
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Need a unit test for this new component.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah so I should take the relevant tests form the original nav.tsx and move them into a new NavList.test file? That makes sense.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

No. You should create a brand new NavLink unit test file. It should ensure that all the props that can change will change correctly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@shashilo Latest changes address this i think

// Copyright (c) Gridiron Survivor.
// Licensed under the MIT License.

import React, { JSX } from 'react';
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

No. You should create a brand new NavLink unit test file. It should ensure that all the props that can change will change correctly.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants