Skip to content

Commit

Permalink
pass match id to endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlipa91 committed Nov 5, 2023
1 parent 7eabbcf commit 6c16842
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
10 changes: 6 additions & 4 deletions lib/screens/BottomBarMatch.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ class BottomBarMatch extends StatelessWidget {
break;
case MatchStatus.unpublished:
if (match.organizerId == context.read<UserState>().currentUserId)
bottomBar = NotPublishedBottomBar(matchId: matchId,
isTest: match.isTest);
bottomBar =
NotPublishedBottomBar(matchId: matchId, isTest: match.isTest);
}

return bottomBar;
Expand Down Expand Up @@ -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
Expand All @@ -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))));
Expand Down
20 changes: 9 additions & 11 deletions lib/utils/Utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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<void> completeAccountAction(BuildContext context, bool isTest,
{String? matchId}) async {
await launchUrl(
{String? matchId}) => launchUrl(
Uri.parse(getStripeUrl(isTest,
context.read<UserState>().getLoggedUserDetails()!.documentId)),
context.read<UserState>().getLoggedUserDetails()!.documentId, matchId)),
mode: LaunchMode.externalApplication);
await context.read<UserState>().fetchLoggedUserDetails();
if (matchId != null) {
await context.read<MatchesState>().fetchMatch(matchId);
}
}

0 comments on commit 6c16842

Please sign in to comment.