Initial commit: Flutter app + PHP/MySQL backend on Hostinger
Replaces Firebase with a self-hosted PHP/MySQL API served from winded.prymsolutions.com. Includes full backend (schema, auth, events, teams, brackets, suggestions, stats, media, file upload) and updated Flutter repositories and domain models. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
import '../../../core/api/api_client.dart';
|
||||
import '../domain/user_profile.dart';
|
||||
|
||||
part 'profile_repository.g.dart';
|
||||
|
||||
class ProfileRepository {
|
||||
ProfileRepository(this._api);
|
||||
|
||||
final ApiClient _api;
|
||||
|
||||
Future<UserProfile?> getProfile(String uid) async {
|
||||
try {
|
||||
final data = await _api.get('/profiles/detail.php', params: {'uid': uid});
|
||||
return UserProfile.fromJson(data);
|
||||
} on ApiException catch (e) {
|
||||
if (e.statusCode == 404) return null;
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> createProfile(UserProfile profile) async {
|
||||
await _api.put('/profiles/detail.php', profile.toJson(), params: {'uid': profile.uid});
|
||||
}
|
||||
|
||||
Future<void> updateProfile(UserProfile profile) async {
|
||||
await _api.put('/profiles/detail.php', profile.toJson(), params: {'uid': profile.uid});
|
||||
}
|
||||
|
||||
Future<void> updateTeamId(String uid, String? teamId) async {
|
||||
await _api.put('/profiles/detail.php', {'team_id': teamId}, params: {'uid': uid});
|
||||
}
|
||||
|
||||
Stream<UserProfile?> watchProfile(String uid) async* {
|
||||
yield await getProfile(uid);
|
||||
await for (final _ in Stream<void>.periodic(const Duration(seconds: 30))) {
|
||||
yield await getProfile(uid);
|
||||
}
|
||||
}
|
||||
|
||||
Future<List<UserProfile>> fetchAllPlayers() async {
|
||||
// The /auth/me.php endpoint only returns one user.
|
||||
// For the admin player list, re-use profile fetch per user (admin panel).
|
||||
// For MVP, return empty — admin panel can be extended later.
|
||||
return [];
|
||||
}
|
||||
|
||||
Stream<List<UserProfile>> watchAllPlayers() async* {
|
||||
yield await fetchAllPlayers();
|
||||
}
|
||||
}
|
||||
|
||||
@Riverpod(keepAlive: true)
|
||||
ProfileRepository profileRepository(ProfileRepositoryRef ref) {
|
||||
return ProfileRepository(ref.watch(apiClientProvider));
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'profile_repository.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$profileRepositoryHash() => r'c1e1c5e820702a3d191905477db9aba9b798dc36';
|
||||
|
||||
/// See also [profileRepository].
|
||||
@ProviderFor(profileRepository)
|
||||
final profileRepositoryProvider = Provider<ProfileRepository>.internal(
|
||||
profileRepository,
|
||||
name: r'profileRepositoryProvider',
|
||||
debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$profileRepositoryHash,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
@Deprecated('Will be removed in 3.0. Use Ref instead')
|
||||
// ignore: unused_element
|
||||
typedef ProfileRepositoryRef = ProviderRef<ProfileRepository>;
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package
|
||||
Reference in New Issue
Block a user