Billing Stripe, link regia mobile e staff solo trasmissione.
Aggiunge fatturazione club, pagina regia condivisibile senza account, roster squadre e rimuove la modalità controller dall'app (v1.1.0). Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -14,26 +14,9 @@ import '../../shared/widgets/screen_insets.dart';
|
||||
import 'resume_session_sheet.dart';
|
||||
import 'no_team_onboarding.dart';
|
||||
import 'schedule_match_sheet.dart';
|
||||
import 'team_picker.dart';
|
||||
import 'team_providers.dart';
|
||||
|
||||
final matchesProvider = FutureProvider<List<MatchModel>>((ref) async {
|
||||
final auth = ref.watch(authProvider);
|
||||
if (!auth.isAuthenticated) return [];
|
||||
final teams = await ref.read(teamsProvider.future);
|
||||
if (teams.isEmpty) return [];
|
||||
final client = ref.read(apiClientProvider);
|
||||
final list = await client.fetchMatches(teams.first.id);
|
||||
list.sort((a, b) {
|
||||
final sa = a.scheduledAt;
|
||||
final sb = b.scheduledAt;
|
||||
if (sa == null && sb == null) return 0;
|
||||
if (sa == null) return 1;
|
||||
if (sb == null) return -1;
|
||||
return sa.compareTo(sb);
|
||||
});
|
||||
return list;
|
||||
});
|
||||
|
||||
class MatchesScreen extends ConsumerWidget {
|
||||
const MatchesScreen({super.key});
|
||||
|
||||
@@ -54,7 +37,7 @@ class MatchesScreen extends ConsumerWidget {
|
||||
icon: const Icon(Icons.group_outlined),
|
||||
tooltip: 'Gestisci staff',
|
||||
onPressed: () async {
|
||||
final team = await ref.read(primaryTeamProvider.future);
|
||||
final team = await ref.read(activeTeamProvider.future);
|
||||
final url = team?.staffManageUrl ?? team?.billingUrl;
|
||||
if (url != null && await canLaunchUrl(Uri.parse(url))) {
|
||||
await launchUrl(Uri.parse(url), mode: LaunchMode.externalApplication);
|
||||
@@ -126,6 +109,7 @@ class MatchesScreen extends ConsumerWidget {
|
||||
return RefreshIndicator(
|
||||
color: AppTheme.primaryRed,
|
||||
onRefresh: () async {
|
||||
ref.invalidate(teamsProvider);
|
||||
ref.invalidate(matchesProvider);
|
||||
await ref.read(matchesProvider.future);
|
||||
},
|
||||
@@ -146,6 +130,7 @@ class MatchesScreen extends ConsumerWidget {
|
||||
'Le tue partite',
|
||||
style: theme.textTheme.bodyMedium,
|
||||
),
|
||||
const TeamPickerBar(),
|
||||
if (activeMatch != null) ...[
|
||||
const SizedBox(height: 12),
|
||||
Material(
|
||||
@@ -315,8 +300,8 @@ class MatchesScreen extends ConsumerWidget {
|
||||
}
|
||||
|
||||
Future<void> _scheduleMatch(BuildContext context, WidgetRef ref) async {
|
||||
final teams = await ref.read(teamsProvider.future);
|
||||
if (teams.isEmpty) {
|
||||
final team = await ref.read(activeTeamProvider.future);
|
||||
if (team == null) {
|
||||
if (context.mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Nessuna squadra disponibile')),
|
||||
@@ -325,12 +310,12 @@ class MatchesScreen extends ConsumerWidget {
|
||||
return;
|
||||
}
|
||||
|
||||
final data = await showScheduleMatchSheet(context);
|
||||
final data = await showScheduleMatchSheet(context, teamName: team.name);
|
||||
if (data == null || !context.mounted) return;
|
||||
|
||||
try {
|
||||
final client = ref.read(apiClientProvider);
|
||||
final match = await client.createMatch(teams.first.id, {
|
||||
final match = await client.createMatch(team.id, {
|
||||
'opponent_name': data.opponentName,
|
||||
'scheduled_at': data.scheduledAt.toUtc().toIso8601String(),
|
||||
if (data.location != null) 'location': data.location,
|
||||
@@ -350,7 +335,7 @@ class MatchesScreen extends ConsumerWidget {
|
||||
backgroundColor: AppTheme.surface,
|
||||
title: const Text('Configurare ora?'),
|
||||
content: const Text(
|
||||
'Puoi preparare telefono e regia subito, oppure tornare quando sei in palestra.',
|
||||
'Puoi preparare la trasmissione subito, oppure tornare quando sei in palestra.',
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
@@ -378,8 +363,8 @@ class MatchesScreen extends ConsumerWidget {
|
||||
}
|
||||
|
||||
Future<void> _createMatchQuick(BuildContext context, WidgetRef ref) async {
|
||||
final teams = await ref.read(teamsProvider.future);
|
||||
if (teams.isEmpty) {
|
||||
final team = await ref.read(activeTeamProvider.future);
|
||||
if (team == null) {
|
||||
if (context.mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Nessuna squadra disponibile')),
|
||||
@@ -389,7 +374,7 @@ class MatchesScreen extends ConsumerWidget {
|
||||
}
|
||||
|
||||
final client = ref.read(apiClientProvider);
|
||||
final match = await client.createMatch(teams.first.id, {
|
||||
final match = await client.createMatch(team.id, {
|
||||
'opponent_name': 'Avversario',
|
||||
'sport': 'volleyball',
|
||||
'sets_to_win': 3,
|
||||
|
||||
Reference in New Issue
Block a user