import 'package:flutter/material.dart';

import 'package:provider/provider.dart';

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

import 'package:pweb/pages/payout_page/wallet/edit/fields/ledger/section.dart';
import 'package:pweb/pages/payout_page/wallet/edit/fields/wallet/wallet_section.dart';

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

  @override
  Widget build(BuildContext context) {
    return Consumer<PaymentSourceController>(
      builder: (context, sourceController, _) {
        final wallet = sourceController.selectedWallet;
        if (wallet != null) {
          return WalletSection(wallet: wallet);
        }

        final ledger = sourceController.selectedLedgerAccount;
        if (ledger != null) {
          return LedgerSection(ledger: ledger);
        }

        return const SizedBox.shrink();
      },
    );
  }
}
