Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 22 commits into
base: develop
Choose a base branch
from

Conversation

HoldUpFjord
Copy link
Contributor

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

Component view:
image
Page View
image

Copy link

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

Copy link

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
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

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

@HoldUpFjord
Copy link
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
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
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
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!

pnpm-lock.yaml Outdated
Copy link
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
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
components/Nav/Nav.tsx Outdated Show resolved Hide resolved
kepsteen
kepsteen previously approved these changes Nov 16, 2024
Copy link
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

@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! ✅

@@ -6,7 +6,7 @@ import React, { JSX } from 'react';
import LogoNav from '../LogoNav/LogoNav';
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
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
Contributor Author

Choose a reason for hiding this comment

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

Removed!

* Handles closing the drawer.
* @returns {void} No return value.
*/
const handleClose = (): void => setOpen(false);
Copy link
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
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

Leagues
</Link>
</li>
<NavLink
Copy link
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
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
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
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.


/**
* Renders a navigation link.
* @param {NavLinkProps} props - The properties for the navigation link.
Copy link
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
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
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
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>
  );
};

@@ -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
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
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
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
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
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
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
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