fix: resolve 3 console errors (RenderFlex overflow, gamification 404s, CORS)
- Wrap Top Events skeleton Row in SingleChildScrollView to fix 225px RenderFlex overflow when 3x 200px skeletons exceed container width - Fix gamification service using POST for GET endpoints: dashboard, leaderboard, and shop/items all use router.get() on the Node.js server - CORS: add http://localhost:8080 to CORS_ALLOWED_ORIGINS (applied live to eventify-django container + local settings.py)
This commit is contained in:
@@ -24,7 +24,7 @@ class GamificationService {
|
|||||||
Future<DashboardResponse> getDashboard() async {
|
Future<DashboardResponse> getDashboard() async {
|
||||||
final email = await _getUserEmail();
|
final email = await _getUserEmail();
|
||||||
final url = '${ApiEndpoints.gamificationDashboard}?user_id=$email';
|
final url = '${ApiEndpoints.gamificationDashboard}?user_id=$email';
|
||||||
final res = await _api.post(url, requiresAuth: false);
|
final res = await _api.get(url, requiresAuth: false);
|
||||||
|
|
||||||
final profileJson = res['profile'] as Map<String, dynamic>? ?? {};
|
final profileJson = res['profile'] as Map<String, dynamic>? ?? {};
|
||||||
final rawSubs = res['submissions'] as List? ?? [];
|
final rawSubs = res['submissions'] as List? ?? [];
|
||||||
@@ -51,7 +51,7 @@ class GamificationService {
|
|||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
Future<DashboardResponse> getDashboardForUser(String userId) async {
|
Future<DashboardResponse> getDashboardForUser(String userId) async {
|
||||||
final url = '${ApiEndpoints.gamificationDashboard}?user_id=$userId';
|
final url = '${ApiEndpoints.gamificationDashboard}?user_id=$userId';
|
||||||
final res = await _api.post(url, requiresAuth: false);
|
final res = await _api.get(url, requiresAuth: false);
|
||||||
|
|
||||||
final profileJson = res['profile'] as Map<String, dynamic>? ?? {};
|
final profileJson = res['profile'] as Map<String, dynamic>? ?? {};
|
||||||
final rawSubs = res['submissions'] as List? ?? [];
|
final rawSubs = res['submissions'] as List? ?? [];
|
||||||
@@ -102,7 +102,7 @@ class GamificationService {
|
|||||||
|
|
||||||
final query = Uri(queryParameters: params).query;
|
final query = Uri(queryParameters: params).query;
|
||||||
final url = '${ApiEndpoints.leaderboard}?$query';
|
final url = '${ApiEndpoints.leaderboard}?$query';
|
||||||
final res = await _api.post(url, requiresAuth: false);
|
final res = await _api.get(url, requiresAuth: false);
|
||||||
|
|
||||||
final rawList = res['leaderboard'] as List? ?? [];
|
final rawList = res['leaderboard'] as List? ?? [];
|
||||||
final entries = rawList
|
final entries = rawList
|
||||||
@@ -128,7 +128,7 @@ class GamificationService {
|
|||||||
// GET /v1/shop/items
|
// GET /v1/shop/items
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
Future<List<ShopItem>> getShopItems() async {
|
Future<List<ShopItem>> getShopItems() async {
|
||||||
final res = await _api.post(ApiEndpoints.shopItems, requiresAuth: false);
|
final res = await _api.get(ApiEndpoints.shopItems, requiresAuth: false);
|
||||||
final rawItems = res['items'] as List? ?? [];
|
final rawItems = res['items'] as List? ?? [];
|
||||||
return rawItems
|
return rawItems
|
||||||
.map((e) => ShopItem.fromJson(Map<String, dynamic>.from(e as Map)))
|
.map((e) => ShopItem.fromJson(Map<String, dynamic>.from(e as Map)))
|
||||||
|
|||||||
@@ -1590,7 +1590,10 @@ class _HomeScreenState extends State<HomeScreen> with SingleTickerProviderStateM
|
|||||||
SizedBox(
|
SizedBox(
|
||||||
height: 200,
|
height: 200,
|
||||||
child: _allFilteredByDate.isEmpty && _loading
|
child: _allFilteredByDate.isEmpty && _loading
|
||||||
? Row(children: List.generate(3, (_) => const Padding(padding: EdgeInsets.only(right: 12), child: EventCardSkeleton())))
|
? SingleChildScrollView(
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
child: Row(children: List.generate(3, (_) => const Padding(padding: EdgeInsets.only(right: 12), child: EventCardSkeleton()))),
|
||||||
|
)
|
||||||
: _allFilteredByDate.isEmpty
|
: _allFilteredByDate.isEmpty
|
||||||
? Center(child: Text(
|
? Center(child: Text(
|
||||||
_selectedDateFilter.isNotEmpty ? 'No events for "$_selectedDateFilter"' : 'No events found',
|
_selectedDateFilter.isNotEmpty ? 'No events for "$_selectedDateFilter"' : 'No events found',
|
||||||
|
|||||||
Reference in New Issue
Block a user