Cant join team if in team Profile page resets properly Post button spam no longer leads to crash due to duplicate calls Housekeeping: Made some name changes moved homescreenpages from layout -> homeFeed Deleted 2 unused classes, authService.dart and old loginPage.dart then renamed startPage.dart -> loginPage.dart Set up openApi on backend and added URL in Service classes
33 lines
1.0 KiB
Dart
33 lines
1.0 KiB
Dart
import 'dart:convert';
|
|
import 'package:http/http.dart' as http;
|
|
|
|
class SettingsService {
|
|
// todo just use teamMS?
|
|
final String baseUrl = 'https://group-10-15.pvt.dsv.su.se/settings';
|
|
|
|
// Hämta om leaderboarden ska visas
|
|
Future<bool> getLeaderboardVisibility() async {
|
|
final response = await http.get(Uri.parse('$baseUrl/leaderboard'));
|
|
|
|
if (response.statusCode == 200) {
|
|
final data = jsonDecode(response.body);
|
|
return data['visible'] ?? true; // true som fallback om null
|
|
} else {
|
|
throw Exception('Kunde inte hämta inställning för leaderboard');
|
|
}
|
|
}
|
|
|
|
// Uppdatera synligheten (t.ex. när admin slår på/av)
|
|
Future<void> setLeaderboardVisibility(bool visible) async {
|
|
final response = await http.post(
|
|
Uri.parse('$baseUrl/leaderboard'),
|
|
headers: {'Content-Type': 'application/json'},
|
|
body: jsonEncode({'visible': visible}),
|
|
);
|
|
|
|
if (response.statusCode != 200) {
|
|
throw Exception('Kunde inte uppdatera leaderboard-inställning');
|
|
}
|
|
}
|
|
}
|