/*
 * Community 组件的组件路由
 */
import 'package:cpt_payment/modules/add_card/add_card_page.dart';
import 'package:cpt_payment/modules/offline_payment/offline_payment_page.dart';
import 'package:cpt_payment/provider/stripe_service.dart';
import 'package:plugin_basic/provider/global_provider_container.dart';
import 'package:router/componentRouter/payment_service.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';

import '../../modules/payment/payment_page.dart';

part 'payment_component_service.g.dart';

@Riverpod(keepAlive: true)
PaymentService paymentService(Ref ref) {
  return PaymentComponentService();
}

class PaymentComponentService extends PaymentService {
  @override
  void startPaymentPage() {
    PaymentPage.startInstance();
  }

  @override
  void startAddCardPage() {
    AddCardPage.startInstance();
  }

  @override
  void startChooseCardPage() {

  }

  @override
  Future<bool> executePayment({required String orderId}) {
    return globalContainer.read(stripeServiceProvider).executePayment(orderId: orderId);
  }

  @override
  void startWithPopOfflinePaymentPage(String? popTargetRouter) {
    OfflinePaymentPage.startWithPop(popTargetRouter: popTargetRouter);
  }
}
