Skip to content

add redirect; add footer with assets link; add not found page#95

Merged
abartczak01 merged 3 commits into
mainfrom
frontend/redirect-if-loggedin
Jun 24, 2025
Merged

add redirect; add footer with assets link; add not found page#95
abartczak01 merged 3 commits into
mainfrom
frontend/redirect-if-loggedin

Conversation

@abartczak01

@abartczak01 abartczak01 commented Jun 24, 2025

Copy link
Copy Markdown
Contributor

Summary by Sourcery

Implement client-side redirects based on authentication state, introduce a styled 404 page and auth layout guard, and refine the homepage, footer, search, and trips UI for consistency and responsiveness

New Features:

  • Redirect authenticated users from the homepage to the trips dashboard
  • Add a custom Not Found page with illustration and a link back to the homepage
  • Implement an auth layout to redirect logged-in users away from login/signup routes

Enhancements:

  • Redesign the homepage with a responsive flex layout, imagery, and updated padding
  • Add a global footer crediting Storyset for illustrations
  • Remove manual token checks and header injection from the search API call
  • Adjust spacing and responsive layout of the trips page controls

@sourcery-ai

sourcery-ai Bot commented Jun 24, 2025

Copy link
Copy Markdown

Reviewer's Guide

This PR enhances user routing and UI elements by implementing client/server redirects based on authentication, refining page layouts with responsive flex and Next Image components, simplifying search auth logic, adding a global footer, and introducing a custom 404 page.

Sequence diagram for client-side redirect on Home page based on authentication

sequenceDiagram
    actor User
    participant HomePage
    participant AuthLib as getToken()
    participant Router
    User->>HomePage: Visit /
    HomePage->>AuthLib: getToken()
    AuthLib-->>HomePage: token or null
    alt token exists
        HomePage->>Router: push('/trips')
        Router-->>User: Redirect to /trips
    else token missing
        HomePage-->>User: Show landing page
    end
Loading

Sequence diagram for server-side redirect on auth pages

sequenceDiagram
    actor User
    participant AuthLayout as (auth)/layout.tsx
    participant Cookies
    participant Router
    User->>AuthLayout: Request auth page (e.g., /sign-up)
    AuthLayout->>Cookies: cookies.get('token')
    Cookies-->>AuthLayout: token or null
    alt token exists
        AuthLayout->>Router: redirect('/trips')
        Router-->>User: Redirect to /trips
    else token missing
        AuthLayout-->>User: Render auth page
    end
Loading

Class diagram for new NotFound page component

classDiagram
    class NotFound {
      +render(): JSX.Element
    }
Loading

File-Level Changes

Change Details Files
Implement client and server redirects for authenticated users
  • Added "use client" directive and useEffect with next/router to Home
  • Redirect to /trips if getToken returns a token
  • Created LoggedUserLayout that reads cookies and server-redirects authenticated users
frontend/app/page.tsx
frontend/app/(auth)/layout.tsx
Refine Home and Trips page layouts and integrate images
  • Updated padding, border and responsive flex layout on Home
  • Embedded Next Image for placeholder and lost-page assets
  • Adjusted flex gap, padding, and container classes on Trips list/header
frontend/app/page.tsx
frontend/app/(root)/trips/page.tsx
Add global footer with asset attribution
  • Inserted footer in RootLayout
  • Styled footer with border, text-center, and link to Storyset
frontend/app/layout.tsx
Simplify search page authentication logic
  • Removed getToken check and logout fallback
  • Dropped manual Authorization header on axios call
frontend/app/(root)/search/page.tsx
Introduce custom NotFound page
  • Created NotFound component with client directive
  • Built responsive layout with heading, text, button, and image
frontend/app/not-found.tsx

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Summary of Changes

Hello @abartczak01, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on enhancing the application's user experience and structural integrity. It introduces intelligent routing for authenticated users, a dedicated page for handling 404 errors, and a global footer for necessary attributions. Additionally, it includes minor UI adjustments to existing pages and streamlines the authentication process for the search feature.

Highlights

  • User Experience Enhancements: Implemented redirects for authenticated users on the home page and authentication routes, ensuring a smoother navigation flow and preventing access to irrelevant pages once logged in.
  • Error Handling Improvement: Introduced a custom 404 'Not Found' page to provide a more user-friendly experience for invalid URLs, guiding users back to the main site.
  • UI/UX Refinements: Added a global footer for asset attribution across the application and made minor layout adjustments to the trips and home pages for improved responsiveness and visual appeal.
  • Authentication Flow Adjustment: Simplified the search functionality by removing explicit token handling, suggesting a more streamlined or cookie-based authentication approach for this endpoint.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey @abartczak01 - I've reviewed your changes - here's some feedback:

  • Consider moving the client-side redirect in Home to a server-side redirect (using Next.js redirect) to avoid flash of the landing page and improve UX.
  • You’re nesting inside a , which is semantically invalid—either style the Link as a button or wrap the button in the Link to maintain correct HTML structure.
  • The search page removed manual Authorization headers but no global interceptor was added; ensure your axios instance or middleware consistently attaches the token or handles unauthorized cases.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider moving the client-side redirect in Home to a server-side redirect (using Next.js redirect) to avoid flash of the landing page and improve UX.
- You’re nesting <Link> inside a <button>, which is semantically invalid—either style the Link as a button or wrap the button in the Link to maintain correct HTML structure.
- The search page removed manual Authorization headers but no global interceptor was added; ensure your axios instance or middleware consistently attaches the token or handles unauthorized cases.

## Individual Comments

### Comment 1
<location> `frontend/app/page.tsx:28` </location>
<code_context>
+            FareShare. From destinations to shared expenses — make every trip
+            effortless and unforgettable, together.
+          </p>
+          <button className="primary-btn text-heading4-medium px-16 py-3 mt-4">
+            <Link href="/sign-up">Get Started</Link>
+          </button>
+        </div>
</code_context>

<issue_to_address>
Button should wrap Link for accessibility and semantics.

Nesting a Link inside a button can cause accessibility and semantic problems. Refactor to avoid placing interactive elements inside each other.
</issue_to_address>

### Comment 2
<location> `frontend/app/not-found.tsx:16` </location>
<code_context>
+            <br />
+            Let's get you back on track.
+          </p>
+          <Link href="/">
+            <button className="primary-btn text-heading4-medium px-16 py-3 mt-6">
+              Go to Homepage
+            </button>
</code_context>

<issue_to_address>
Button should not be nested inside Link for accessibility.

Use a Link styled as a button, or a button with navigation logic, to avoid these issues.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread frontend/app/page.tsx
Comment on lines +28 to +29
<button className="primary-btn text-heading4-medium px-16 py-3 mt-4">
<Link href="/sign-up">Get Started</Link>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue: Button should wrap Link for accessibility and semantics.

Nesting a Link inside a button can cause accessibility and semantic problems. Refactor to avoid placing interactive elements inside each other.

Comment on lines +16 to +17
<Link href="/">
<button className="primary-btn text-heading4-medium px-16 py-3 mt-6">

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue: Button should not be nested inside Link for accessibility.

Use a Link styled as a button, or a button with navigation logic, to avoid these issues.

@github-actions

Copy link
Copy Markdown

Code Coverage

There is no coverage information present for the Files changed

Total Project Coverage 81.9% 🍏

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a redirect feature, a 404 page, and a footer. It also refactors the homepage and search page. I've provided feedback on server-side redirects, HTML validity, and responsive design.

Comment thread frontend/app/page.tsx
Comment on lines +11 to +16
useEffect(() => {
const token = getToken();
if (token) {
router.push('/trips');
}
}, [router]);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

Consider performing the redirect on the server side to avoid UI flicker. Using useEffect for redirection can cause a brief display of the original page content before redirecting. A server-side redirect would be more efficient.

Comment on lines 23 to 26
try {
const response = await axiosInstance.get(`user-info/search`, {
params: { name: query, page: 0, size: 20 },
headers: { Authorization: `Bearer ${token}` },
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The Authorization header is no longer being set on the request. Ensure that the backend does not require this header, or that authentication is being handled in a different way.

Comment on lines +17 to +19
<button className="primary-btn text-heading4-medium px-16 py-3 mt-6">
Go to Homepage
</button>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Nesting a <button> inside a <Link> is invalid HTML. The <Link> component renders an <a> tag, and <a> tags should not contain <button> elements1. Style the <Link> to look like a button instead.

          <Link
            href="/"
            className="primary-btn text-heading4-medium px-16 py-3 mt-6">
            Go to Homepage
          </Link>

Style Guide References

Footnotes

  1. <a> tags should not contain <button> elements. (link)

Comment thread frontend/app/page.tsx
Comment on lines +28 to +30
<Link href="/sign-up">Get Started</Link>
</button>
</div>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Nesting a <Link> inside a <button> is invalid HTML. Interactive elements like buttons should not contain other interactive elements like links1. Style the <Link> to look like a button instead.

          <Link href="/sign-up" className="primary-btn text-heading4-medium px-16 py-3 mt-4">
            Get Started
          </Link>

Style Guide References

Footnotes

  1. Interactive elements like buttons should not contain other interactive elements like links. (link)

return (
<div>
<div className="flex justify-between">
<div className="flex justify-between gap-4 sm:p-0 p-2 sm:flex-row flex-col ">

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Consider using flex-row and flex-col classes with the sm: prefix to control the layout at different screen sizes, instead of sm:flex-row flex-col1.

      <div className="flex justify-between gap-4 p-2 sm:p-0 sm:flex-row flex-col">

Style Guide References

Footnotes

  1. Use responsive prefixes like sm:, md:, lg:, and xl: to control layout at different screen sizes. (link)

</Link>
{trips && trips.length > 0 && (
<div className="flex flex-col items-center text-gray-700 md:flex-row gap-4">
<div className="flex items-center text-gray-700 gap-4">

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The md:flex-row class has been removed. Ensure that the layout is still responsive and works as expected on larger screens.

@github-actions

Copy link
Copy Markdown

Code Coverage

There is no coverage information present for the Files changed

Total Project Coverage 81.9% 🍏

@github-actions

Copy link
Copy Markdown

Code Coverage

There is no coverage information present for the Files changed

Total Project Coverage 81.9% 🍏

@abartczak01 abartczak01 merged commit 85cd070 into main Jun 24, 2025
1 check 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.

1 participant