Skip to content

feat(frontend): implement centralized state management with Zustand (…#216

Merged
RUKAYAT-CODER merged 2 commits intoEarnQuestOne:mainfrom
Thosine-01:feat/state-management
Apr 4, 2026
Merged

feat(frontend): implement centralized state management with Zustand (…#216
RUKAYAT-CODER merged 2 commits intoEarnQuestOne:mainfrom
Thosine-01:feat/state-management

Conversation

@Thosine-01
Copy link
Copy Markdown
Contributor

@Thosine-01 Thosine-01 commented Mar 30, 2026

Close #173

Summary

Implements centralized state management using Zustand, eliminating prop drilling and inconsistent UI state across the app.

Changes

Store Configuration

  • Configured Zustand store with devtools and persist middleware
  • Fixed SSR crash in persistence middleware using noopStorage fallback
  • Added partialize to control exactly what gets persisted to localStorage
  • Added typed selectors to store index

State Slices Created

  • userSlice — profile, stats, achievements, activities
  • questSlice — list, filters, pagination, loading/error state
  • submissionSlice — submissions, drafts, status, pagination, optimistic updates
  • notificationSlice — notifications, unread count (auto-derived), settings
  • uiSlice — theme, sidebar, modals
  • walletSlice — address, connection state, modal state, error

Hooks Connected to Store

  • useProfile — reads/writes user state from store
  • useQuests — reads/writes quest state from store
  • useSubmissions — reads/writes submission state from store, exposes optimistic update
  • useNotifications — reads/writes notification state from store

Wallet

  • Refactored WalletContext to delegate all state to Zustand store
  • Wallet kit instance stays local (non-serialisable), state is centralised

Components

  • Fixed UserProfile — replaced full store selector with granular selectors to prevent unnecessary rerenders
  • Simplified ProfilePage — removed redundant double state management

Checklist

  • Store configured correctly
  • All state slices created
  • Selectors work efficiently
  • Persistence saves to localStorage
  • Devtools show state changes
  • Optimistic updates implemented
  • Components connected to store
  • No prop drilling needed
  • Repo starred ⭐

@drips-wave
Copy link
Copy Markdown

drips-wave bot commented Mar 30, 2026

@Thosine-01 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@RUKAYAT-CODER RUKAYAT-CODER merged commit d3327c4 into EarnQuestOne:main Apr 4, 2026
0 of 2 checks 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.

Implement State Management System

2 participants