Skip to content

feat(platform-config): add global PlatformConfigContext and expose feePercent#121

Merged
PeterOche merged 2 commits intodegenspot:mainfrom
Oluwaseyi89:feature/Global-Platform-Fee-Context-Provider
Mar 24, 2026
Merged

feat(platform-config): add global PlatformConfigContext and expose feePercent#121
PeterOche merged 2 commits intodegenspot:mainfrom
Oluwaseyi89:feature/Global-Platform-Fee-Context-Provider

Conversation

@Oluwaseyi89
Copy link
Copy Markdown
Contributor

Pull Request: Global Platform Fee Context Provider

Closes #114

📦 Summary

This PR introduces a global PlatformConfigProvider that fetches the platform configuration (including dynamic fee percent) from GET /config on app boot and makes it available to all child components via usePlatformConfig() hook, eliminating individual backend calls.

✅ Changes

  • Added PlatformConfigProvider using SWR for caching and automatic refetch
  • Created usePlatformConfig() hook to access { config, isLoading, error }
  • Added mock GET /api/config endpoint for development
  • Wrapped app with provider in layout.tsx
  • Updated NavBar.tsx to demonstrate usage

📁 Files Changed

File Change
packages/frontend/src/contexts/PlatformConfigContext.tsx New provider with SWR fetching
packages/frontend/src/app/api/config/route.ts Mock config endpoint
packages/frontend/src/types/config.ts Type definitions
packages/frontend/src/app/layout.tsx Wrapped with provider
packages/frontend/src/components/NavBar.tsx Consumed feePercent
packages/frontend/package.json Added swr dependency

🧪 How to Test

  1. Run the frontend app
  2. Fee percent should display in the navbar (or any component using usePlatformConfig())
  3. No individual backend calls needed for accessing platform fee

Closes #114

…ePercent (degenspot#114)Add PlatformConfigProvider using SWR to fetch /api/config on app boot and expose { config, isLoading, error } via usePlatformConfig().Wrap app with PlatformConfigProvider in layout.tsx so children can access feePercent without individual backend calls.Add config.ts type and a dev GET /api/config mock at route.ts.Demonstrate usage in NavBar.tsx.Add swr dependency for caching/config fetching.
@drips-wave
Copy link
Copy Markdown

drips-wave bot commented Mar 23, 2026

@Oluwaseyi89 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

@Oluwaseyi89
Copy link
Copy Markdown
Contributor Author

@PeterOche please, review. All checks have passed.

@PeterOche PeterOche merged commit cec09d6 into degenspot:main Mar 24, 2026
3 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.

Global Platform Fee Context Provider

2 participants