Skip to content

refactor: extract reusable dashboard API hooks#1115

Open
Rinki4738 wants to merge 10 commits into
Priyanshu-byte-coder:mainfrom
Rinki4738:feature/dashboard-api-hooks
Open

refactor: extract reusable dashboard API hooks#1115
Rinki4738 wants to merge 10 commits into
Priyanshu-byte-coder:mainfrom
Rinki4738:feature/dashboard-api-hooks

Conversation

@Rinki4738
Copy link
Copy Markdown

Summary

Refactored dashboard widget API calls into reusable custom hooks to improve code reusability, consistency, and testability.

Closes #1053

Type of Change

  • Refactor / code cleanup

Changes Made

  • Added reusable custom hooks:
    • useMetrics
    • useStreak
    • useNotifications
    • useUserSettings
  • Moved API fetching logic out of dashboard components
  • Standardized loading, error, and data state handling
  • Added manual refetch support in hooks
  • Updated consuming components to use hooks
  • Added TypeScript typings for hook return values
  • Added unit tests for all hooks

How to Test

  • Run npm install
  • Run npm run type-check
  • Run npm test
  • Optionally run npm run dev and verify dashboard widgets load correctly

Screenshots (if UI change)

No UI changes.

Checklist

  • Linked issue in summary
  • No TypeScript errors (npm run type-check)
  • Self-reviewed the diff
  • Added/updated tests if applicable

@vercel
Copy link
Copy Markdown

vercel Bot commented May 25, 2026

@Rinki4738 is attempting to deploy a commit to the PRIYANSHU DOSHI's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added gssoc26 GSSoC 2026 contribution type:refactor GSSoC type bonus: refactor (+10 pts) type:testing GSSoC type bonus: tests (+10 pts) labels May 25, 2026
@github-actions
Copy link
Copy Markdown

GSSoC Label Checklist 🏷️

@Priyanshu-byte-coder — please apply the appropriate labels before merging:

Difficulty (pick one):

  • level:beginner — 20 pts
  • level:intermediate — 35 pts
  • level:advanced — 55 pts
  • level:critical — 80 pts

Quality (optional):

  • quality:clean — ×1.2 multiplier
  • quality:exceptional — ×1.5 multiplier

Validation (required to score):

  • gssoc:approved — counts for points
  • gssoc:invalid / gssoc:spam / gssoc:ai-slop — does not score

Type labels (type:*) are auto-detected from files and title. Review and adjust if needed.
Points formula: (difficulty × quality_multiplier) + type_bonus

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Thanks for your first PR on DevTrack! 🎉

A maintainer will review it within 48 hours. While you wait:

  • Make sure CI is passing (type-check + lint)
  • Double-check the PR description is filled out and the issue is linked
  • Feel free to ask questions in Discussions if you need help

If you find DevTrack useful, a ⭐ star on the repo is always appreciated — it helps the project grow and attract more contributors!

@Priyanshu-byte-coder Priyanshu-byte-coder added level:intermediate GSSoC: Intermediate difficulty (35 pts) gssoc:approved GSSoC: PR approved for scoring labels May 26, 2026
@Priyanshu-byte-coder
Copy link
Copy Markdown
Owner

Merge conflict after several PRs landed on main — likely on e2e/landing.spec.js or a shared component. Rebase to unblock:

git fetch origin && git rebase origin/main
# resolve conflicts, then:
git push --force-with-lease

All CI checks look good otherwise — once rebased this is ready to merge.

@Rinki4738 Rinki4738 force-pushed the feature/dashboard-api-hooks branch from 8865585 to 52c7aa7 Compare May 26, 2026 07:13
@github-actions github-actions Bot added the type:security GSSoC type bonus: security (+20 pts) label May 26, 2026
@Rinki4738
Copy link
Copy Markdown
Author

Rebased with the latest upstream/main changes, resolved merge conflicts, and updated the branch. All tests are passing locally now. Thanks!

@Priyanshu-byte-coder
Copy link
Copy Markdown
Owner

The refactor looks good, but adding the repo OAuth scope (giving full repo read/write access) is a breaking change that forces all users to re-authorize. Please remove it unless one of the new hooks explicitly requires it and explain why.

@Rinki4738 Rinki4738 force-pushed the feature/dashboard-api-hooks branch from 52c7aa7 to c34aacf Compare May 26, 2026 09:39
@Rinki4738
Copy link
Copy Markdown
Author

Updated the branch and resolved the related test issues after rebasing. Also removed the unnecessary repo OAuth scope and adjusted the auth tests accordingly. All tests are passing locally now.

@Priyanshu-byte-coder
Copy link
Copy Markdown
Owner

This PR has a merge conflict with main. Please rebase your branch and resolve conflicts. Additionally, please review the OAuth scope changes in auth.ts — ensure no unnecessary scopes are being added, and that the existing read:user user:email read:discussion scope configuration is preserved.

@Rinki4738 Rinki4738 force-pushed the feature/dashboard-api-hooks branch from c34aacf to b0dafec Compare May 27, 2026 09:21
@Rinki4738
Copy link
Copy Markdown
Author

Rebased the branch with the latest main changes and resolved the merge conflicts. Also verified that the GitHub OAuth scope remains unchanged (read:user user:email read:discussion) and updated the related auth test mocks accordingly. All tests are passing locally now.

@Priyanshu-byte-coder
Copy link
Copy Markdown
Owner

Hi! This PR has been approved (gssoc:approved) but has merge conflicts with the latest main. Please rebase your branch on main, resolve any conflicts, and push — we'll merge right away. Thank you for your contribution!

Copy link
Copy Markdown
Owner

@Priyanshu-byte-coder Priyanshu-byte-coder left a comment

Choose a reason for hiding this comment

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

This PR has 10 merge conflicts with current main — it needs a rebase before it can be merged. The hooks pattern (useMetrics, useStreak, etc.) and the test additions are a great idea. Please rebase and resolve the conflicts.

@Priyanshu-byte-coder
Copy link
Copy Markdown
Owner

This PR has conflicts with the current main branch. Please rebase on main to resolve conflicts so it can be reviewed and merged. Run: git fetch upstream main && git rebase upstream/main

@Rinki4738 Rinki4738 force-pushed the feature/dashboard-api-hooks branch from b0dafec to d08fd64 Compare May 29, 2026 17:58
Copy link
Copy Markdown
Owner

@Priyanshu-byte-coder Priyanshu-byte-coder left a comment

Choose a reason for hiding this comment

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

This PR now has merge conflicts with main due to recent merges. Please rebase onto the latest main branch and resolve all conflicts to proceed with merging.

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

Labels

gssoc:approved GSSoC: PR approved for scoring gssoc26 GSSoC 2026 contribution level:intermediate GSSoC: Intermediate difficulty (35 pts) type:refactor GSSoC type bonus: refactor (+10 pts) type:security GSSoC type bonus: security (+20 pts) type:testing GSSoC type bonus: tests (+10 pts)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: extract dashboard API calls into custom React hooks

2 participants