Skip to content

Modified Routing Options in Index Page#177

Open
Jaswanth-Kumar-2007 wants to merge 2 commits into
OpenLake:mainfrom
Jaswanth-Kumar-2007:KJK
Open

Modified Routing Options in Index Page#177
Jaswanth-Kumar-2007 wants to merge 2 commits into
OpenLake:mainfrom
Jaswanth-Kumar-2007:KJK

Conversation

@Jaswanth-Kumar-2007

@Jaswanth-Kumar-2007 Jaswanth-Kumar-2007 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Third Issue -Author : @Jaswanth-Kumar-2007

Modified Routing Options in Index Page i.e Header

Testing Website : https://canonforces-trial.vercel.app/

Already Logged into the Account

image

Before this PR

Index Page Routing not Linked to Dashboard

image

After this PR

Index Page Routing Linked to Dashboard and In Place of Login and Signup Used the Dashboard and Display Name

image
The Display Name is Grabbed from the Local Storage already previously storing the "authUser" in Local Storage now Used that to get the Detail of the display Name.

Modified Files

 modified:   src/common/components/Footer/Footer.tsx
 modified:   src/common/components/Header/Header.tsx
 modified:   src/pages/index.tsx
 modified:   tailwind.config.js

Footer

Updated the Discord Link . Previous Link was Not Working in the Footer

Header and index

Updated the navigation to the Dashboard

tailwind.config

Added Black colour for the Usage


Thank You . After completion of review merge the PR .

Summary by CodeRabbit

  • New Features

    • Signed-in users now see personalized navigation, including a Dashboard link with their display name.
    • Home page action buttons route signed-in users to Dashboard; others go to Login.
  • UI Updates

    • Profile “EDIT” and modal controls now reflect editing/loading state (e.g., “Uploading...” while saving).
  • Bug Fixes

    • Updated the Discord invite link in the footer.
    • Improved handling of stored sign-in data so navigation consistently matches the current user state.

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

🎉 Thanks for Your Contribution to CanonForces! ☺️

We'll review it as soon as possible. In the meantime, please:

  • ✅ Double-check the file changes.
  • ✅ Ensure that all commits are clean and meaningful.
  • ✅ Link the PR to its related issue (e.g., Closes #123).
  • ✅ Resolve any unaddressed review comments promptly.

💬 Need help or want faster feedback?
Join our Discord 👉 CanonForces Discord

Thanks again for contributing 🙌 – @Jaswanth-Kumar-2007!
cc: @aviralsaxena16

@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Header and Home page now read authUser from localStorage to conditionally render Dashboard links and authenticated routes. Profile edit controls and styles were updated, the Footer Discord URL changed, and a Tailwind color entry was reformatted.

Changes

Auth-aware navigation

Layer / File(s) Summary
Header auth state and conditional nav links
src/common/components/Header/Header.tsx
Loads parsed authUser data and renders Dashboard or Login/Signup links based on its presence.
Home page auth state and conditional routing
src/pages/index.tsx
Loads parsed authUser data and routes Explore/Dashboard buttons to /dashboard or /login.

Profile edit UI

Layer / File(s) Summary
Profile edit controls and styling
src/common/components/Profile/Profile.tsx, src/common/components/Profile/Profile.module.css
Adds edit overlay styles and updates edit and save labels for editing and upload states.

Footer link and config formatting

Layer / File(s) Summary
Footer Discord URL and Tailwind formatting
src/common/components/Footer/Footer.tsx, tailwind.config.js
Updates the Discord invite URL and compacts the black color entry formatting.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Visitor
  participant Header
  participant Home
  participant LocalStorage

  Visitor->>Header: Load page
  Header->>LocalStorage: Read "authUser"
  LocalStorage-->>Header: JSON string or null
  Header->>Header: Render Dashboard or Login/Signup

  Visitor->>Home: Load page
  Home->>LocalStorage: Read "authUser"
  LocalStorage-->>Home: JSON string or null
  Home->>Home: Route to /dashboard or /login
Loading

Possibly related PRs

Suggested reviewers: Jagath-P, aviralsaxena16

Poem

I hop through auth's little den,
To Dashboard and back again.
Profile buttons softly glow,
Discord links refreshed below.
One tiny space has gone—hooray! 🐇

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is mostly freeform and misses required template sections like Related Issue, Why This Change, Testing, and Checklist. Rewrite it using the repository template and fill in the issue link, change bullets, rationale, testing steps, screenshots, and checklist items.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and clearly relates to the routing and header navigation changes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

src/common/components/Profile/Profile.module.css

Parsing error: Unexpected token (1:0)


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

Comment @coderabbitai help to get the list of available commands.

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/common/components/Header/Header.tsx (1)

7-24: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extract duplicated localStorage auth logic into a shared hook.

Both Header.tsx (lines 11–23) and src/pages/index.tsx (lines 29–41) contain identical useEffect + useState logic to read and parse authUser from localStorage. Extract this into a custom hook (e.g., useAuthUser) to eliminate duplication and ensure consistent behavior when the logic needs to evolve (e.g., adding auth-sync from the previous comment).

♻️ Proposed custom hook
+// src/common/hooks/useAuthUser.ts
+import { useState, useEffect } from "react";
+
+export function useAuthUser() {
+  const [authUser, setAuthUser] = useState<any>(null);
+
+  useEffect(() => {
+    try {
+      const data = localStorage.getItem("authUser");
+      if (data) setAuthUser(JSON.parse(data));
+    } catch (e) {
+      console.error(e);
+    }
+  }, []);
+
+  return authUser;
+}

Then in Header.tsx:

-import { useState,useEffect } from "react";
+import { useAuthUser } from "../hooks/useAuthUser";
 
 export default function Header() {
-  const [userDetails , setUserdetails] = useState<any>(null);
-
-  useEffect(() => {
-    try{
-      const data = localStorage.getItem("authUser");
-      if(data){
-        setUserdetails(JSON.parse(data));
-      };
-    }catch (e){
-      console.log(e);
-    }
-  },[])
+  const userDetails = useAuthUser();

Also applies to: 28-42

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/common/components/Header/Header.tsx` around lines 7 - 24, The `Header`
component duplicates the same `useState`/`useEffect` `localStorage` parsing
logic that also exists in the home page, so move that auth reading into a shared
custom hook such as `useAuthUser`. Create the hook to encapsulate loading and
parsing `authUser` from `localStorage`, then update `Header` (and the matching
logic in `src/pages/index.tsx`) to consume the hook instead of keeping separate
copies. Keep the hook’s behavior consistent with the current `Header`/`index`
logic, including the try/catch and null fallback.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/common/components/Header/Header.tsx`:
- Around line 7-24: The Header component currently reads auth state only once on
mount, so it won’t update when `authUser` is removed elsewhere; update `Header`
to subscribe to auth changes (for example via the Firebase listener used in
`_app.tsx`) or handle `storage` events so `userDetails` stays in sync after
logout. Also change the caught-exception logging in `useEffect` from
`console.log` to `console.error`, and rename `setUserdetails` to match the
`userDetails` state casing for consistency.

---

Nitpick comments:
In `@src/common/components/Header/Header.tsx`:
- Around line 7-24: The `Header` component duplicates the same
`useState`/`useEffect` `localStorage` parsing logic that also exists in the home
page, so move that auth reading into a shared custom hook such as `useAuthUser`.
Create the hook to encapsulate loading and parsing `authUser` from
`localStorage`, then update `Header` (and the matching logic in
`src/pages/index.tsx`) to consume the hook instead of keeping separate copies.
Keep the hook’s behavior consistent with the current `Header`/`index` logic,
including the try/catch and null fallback.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6fd7a198-e28d-4f27-a336-b698d770e59b

📥 Commits

Reviewing files that changed from the base of the PR and between 0450fca and 2a62320.

📒 Files selected for processing (4)
  • src/common/components/Footer/Footer.tsx
  • src/common/components/Header/Header.tsx
  • src/pages/index.tsx
  • tailwind.config.js

Comment on lines +7 to +24
import { useState,useEffect } from "react";

export default function Header() {

const [userDetails , setUserdetails] = useState<any>(null);

useEffect(() => {
try{
const data = localStorage.getItem("authUser");

if(data){
setUserdetails(JSON.parse(data));
};
}catch (e){
console.log(e);
}
},[])

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Stale auth state — Header won't reflect logout without a page refresh.

The useEffect reads authUser from localStorage only on mount. If the user logs out elsewhere (e.g., via onAuthStateChanged in _app.tsx which calls localStorage.removeItem("authUser")), the Header will continue displaying "Dashboard : displayName" until a full page reload. Consider syncing with the Firebase auth listener or listening to storage events for cross-tab updates.

Additionally, console.log should be console.error for caught exceptions, and the setter setUserdetails has inconsistent casing vs the state variable userDetails.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/common/components/Header/Header.tsx` around lines 7 - 24, The Header
component currently reads auth state only once on mount, so it won’t update when
`authUser` is removed elsewhere; update `Header` to subscribe to auth changes
(for example via the Firebase listener used in `_app.tsx`) or handle `storage`
events so `userDetails` stays in sync after logout. Also change the
caught-exception logging in `useEffect` from `console.log` to `console.error`,
and rename `setUserdetails` to match the `userDetails` state casing for
consistency.

@Jaswanth-Kumar-2007

Copy link
Copy Markdown
Contributor Author

I don't think this will cause any issues regarding CodeRabbit's suggestion.

The reason is that my plan: whenever users revisited the website, they were prompted to log in again. This happened because the index page didn't include navigation to the dashboard.

With this change, that issue should be resolved, as returning users will be able to navigate back to the dashboard instead of being forced through the login flow again.

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/common/components/Profile/Profile.tsx`:
- Around line 271-273: Update the button label in the Profile component’s
handleEditToggle control so its editing-state text accurately describes the
action, such as “Cancel Edit,” instead of “Scroll Down 👇”; keep the existing
edit icon and “EDIT” label for the non-editing state.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7d068310-1e54-4e8f-ab7f-a9b50a89768b

📥 Commits

Reviewing files that changed from the base of the PR and between 2a62320 and e6fb173.

📒 Files selected for processing (2)
  • src/common/components/Profile/Profile.module.css
  • src/common/components/Profile/Profile.tsx

Comment on lines 271 to 273
<button className={styles.editButton} onClick={handleEditToggle}>
<HiPencilSquare size={16} /> EDIT
{(isEditing) ? (<>Scroll Down 👇</>):<><HiPencilSquare size={16} /> EDIT</>}
</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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Use an action-accurate label for the edit toggle.

While editing, this button still calls handleEditToggle, so clicking “Scroll Down 👇” closes the editor instead of scrolling. Use a label such as “Cancel Edit,” or make scrolling a separate control.

Proposed fix
- {(isEditing) ? (<>Scroll Down 👇</>):<><HiPencilSquare size={16} /> EDIT</>}
+ {isEditing ? 'Cancel Edit' : <><HiPencilSquare size={16} /> EDIT</>}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<button className={styles.editButton} onClick={handleEditToggle}>
<HiPencilSquare size={16} /> EDIT
{(isEditing) ? (<>Scroll Down 👇</>):<><HiPencilSquare size={16} /> EDIT</>}
</button>
<button className={styles.editButton} onClick={handleEditToggle}>
{isEditing ? 'Cancel Edit' : <><HiPencilSquare size={16} /> EDIT</>}
</button>
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/common/components/Profile/Profile.tsx` around lines 271 - 273, Update the
button label in the Profile component’s handleEditToggle control so its
editing-state text accurately describes the action, such as “Cancel Edit,”
instead of “Scroll Down 👇”; keep the existing edit icon and “EDIT” label for
the non-editing state.

@Jaswanth-Kumar-2007

Jaswanth-Kumar-2007 commented Jul 12, 2026

Copy link
Copy Markdown
Contributor Author

Fourth Issue -Author : @Jaswanth-Kumar-2007

Modified Edit Profile Section (UI of Edit Profile)

Testing Website : https://canonforces-trial.vercel.app/

Initially In the Profile

image

After Clicking the Edit

image

And The Profile Section Modified with the CSS

image

And After Submitting the Scroll Down Button Changes to Edit Again


@Jaswanth-Kumar-2007

Copy link
Copy Markdown
Contributor Author

Fifth Issue -Author : @Jaswanth-Kumar-2007

Regarding the Gemini Model and the Quiz Stats

Testing Website : https://canonforces-trial.vercel.app/

Updated the Gemini Model to the gemini-3.1-flash-lite So No Issue with the Gemini


Need to Add the Firebase Admin Keys

Required to Save the Quiz Score

Screenshot 2026-07-12 113602

Needed at the Firebase Admin

Screenshot 2026-07-12 113620

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