From 6c16842c067b488a6ea953f0c74dde3d68f19bd2 Mon Sep 17 00:00:00 2001 From: Alessandro Liparoti Date: Sun, 5 Nov 2023 20:35:12 +0100 Subject: [PATCH] pass match id to endpoint --- lib/screens/BottomBarMatch.dart | 10 ++++++---- lib/utils/Utils.dart | 20 +++++++++----------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/screens/BottomBarMatch.dart b/lib/screens/BottomBarMatch.dart index 857bf24..01f1d54 100644 --- a/lib/screens/BottomBarMatch.dart +++ b/lib/screens/BottomBarMatch.dart @@ -57,8 +57,8 @@ class BottomBarMatch extends StatelessWidget { break; case MatchStatus.unpublished: if (match.organizerId == context.read().currentUserId) - bottomBar = NotPublishedBottomBar(matchId: matchId, - isTest: match.isTest); + bottomBar = + NotPublishedBottomBar(matchId: matchId, isTest: match.isTest); } return bottomBar; @@ -213,7 +213,8 @@ class NotPublishedBottomBar extends StatelessWidget { final String matchId; final bool isTest; - const NotPublishedBottomBar({Key? key, required this.matchId, required this.isTest}) + const NotPublishedBottomBar( + {Key? key, required this.matchId, required this.isTest}) : super(key: key); @override @@ -224,7 +225,8 @@ class NotPublishedBottomBar extends StatelessWidget { subText: "Complete your Stripe account to receive payments and publish this match", button: InkWell( - onTap: () => completeAccountAction(context, isTest, matchId: matchId), + onTap: () => + completeAccountAction(context, isTest, matchId: matchId), child: Padding( padding: EdgeInsets.only(top: 8), child: Text("GO TO STRIPE", style: TextPalette.linkStyle)))); diff --git a/lib/utils/Utils.dart b/lib/utils/Utils.dart index a610698..1b4acc9 100644 --- a/lib/utils/Utils.dart +++ b/lib/utils/Utils.dart @@ -3,7 +3,6 @@ import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; import 'package:nutmeg/api/CloudFunctionsUtils.dart'; import 'package:nutmeg/model/Match.dart'; -import 'package:nutmeg/state/MatchesState.dart'; import 'package:package_info_plus/package_info_plus.dart'; import 'package:provider/provider.dart'; import 'package:share_plus/share_plus.dart'; @@ -107,17 +106,16 @@ class ConfigsUtils { static bool feesOnOrganiser(String orgId) => false; } -String getStripeUrl(bool isTest, String userId) => CloudFunctionsClient() - .getUrl("stripe/account/onboard?is_test=$isTest&user_id=$userId"); +String getStripeUrl(bool isTest, String userId, String? matchId) { + var path = "stripe/account/onboard?is_test=$isTest&user_id=$userId"; + if (matchId != null) { + path = path + "&match_id=$matchId"; + } + return CloudFunctionsClient().getUrl(path); +} Future completeAccountAction(BuildContext context, bool isTest, - {String? matchId}) async { - await launchUrl( + {String? matchId}) => launchUrl( Uri.parse(getStripeUrl(isTest, - context.read().getLoggedUserDetails()!.documentId)), + context.read().getLoggedUserDetails()!.documentId, matchId)), mode: LaunchMode.externalApplication); - await context.read().fetchLoggedUserDetails(); - if (matchId != null) { - await context.read().fetchMatch(matchId); - } -}