import 'package:flutter/material.dart';

import 'package:go_router/go_router.dart';

import 'package:provider/provider.dart';

import 'package:pshared/controllers/payment/source.dart';
import 'package:pshared/models/payment/source_type.dart';
import 'package:pshared/models/payment/type.dart';

import 'package:pweb/app/router/payout_routes.dart';

import 'package:pweb/generated/i18n/app_localizations.dart';


class SendPayoutButton extends StatelessWidget {
  const SendPayoutButton({super.key});

  @override
  Widget build(BuildContext context) {
    final loc = AppLocalizations.of(context)!;
    final source = context.watch<PaymentSourceController>();

    final sourceType = source.selectedType;
    final paymentType = switch (sourceType) {
      PaymentSourceType.wallet => PaymentType.wallet,
      PaymentSourceType.ledger => PaymentType.ledger,
      _ => null,
    };

    return ElevatedButton(
      style: ElevatedButton.styleFrom(shadowColor: null, elevation: 0),
      onPressed: paymentType == null
          ? null
          : () {
              context.pushNamed(
                PayoutRoutes.payment,
                queryParameters: PayoutRoutes.buildQueryParameters(
                  paymentType: paymentType,
                ),
              );
            },
      child: Text(loc.payoutNavSendPayout),
    );
  }
}
