Feat/add customizable dashboard widgets with user prefrences persistence [ISSUE: #175]#393
Conversation
|
@abdullahxyz85 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. |
|
@Priyanshu-byte-coder check it now, I close the older PR and create new PRs by spliting from each others, please review and merge and make sure to add the labels, gssoc:approved and level. |
Priyanshu-byte-coder
left a comment
There was a problem hiding this comment.
Three issues before merge:
1. Migration timestamp conflict
20260519000000_add_widget_preferences.sql — timestamp 20260519000000 is already used by the merged 20260519000000_add_leaderboard_opt_in.sql. Rename to the next available timestamp, e.g. 20260520000001_add_widget_preferences.sql.
2. Duplicate import in settings/route.ts
import { supabaseAdmin, updateUserPublicFlag, ensureUserExists } from "@/lib/supabase";
import { supabaseAdmin } from "@/lib/supabase"; // ← duplicate — TypeScript errorDelete the second import line.
3. ensureUserExists has a race condition
The find-then-insert pattern:
const existing = await select().eq('github_id', id).single();
if (!existing) await insert([...]);Two concurrent sign-ins for the same user can both pass the !existing check and then both try to insert → unique constraint violation. Use upsert instead:
const { data } = await supabaseAdmin
.from('users')
.upsert({ github_id: githubId, github_login: githubLogin, ... }, { onConflict: 'github_id' })
.select('id,...').single();The widget preferences schema, settings UI, and DashboardWidgetSettings.tsx component all look solid. Fix these three and it's ready.
…ove duplicate import, fix race condition in ensureUserExists with upsert
|
@Priyanshu-byte-coder Done! Please make sure to add the label: gssoc:approved and level:adavanced. |
|
Closing — |
Description ISSUE: #175
Implement a comprehensive dashboard widget customization system that allows users to toggle the visibility of dashboard widgets. User preferences are persisted in Supabase and applied immediately without page reload.
Features
✅ User Widget Preferences
✅ Database
user_widget_prefsJSONB column to users table✅ Settings UI
✅ Dashboard Integration
✅ API Enhancement
/api/user/settingsto handle widget preferencesChanges Made
Database
File:
supabase/migrations/20260519000000_add_widget_preferences.sqlFile:
supabase/schema.sqlAPI Routes
src/app/api/user/settings/route.tsensureUserExists()call for auto user creationuser_widget_prefsuser_widget_prefsupdatesPages
File:
src/app/dashboard/settings/page.tsxhandleUpdateWidgetPrefs()handlerFile:
src/app/dashboard/page.tsxWidgets Supported
User Experience Flow
Testing Recommendations
Related Issues
Closes #175 (Dashboard Widget Customization)
Notes