import 'package:flutter/material.dart';

import 'package:pweb/generated/i18n/app_localizations.dart';
import 'package:pweb/pages/dashboard/payouts/multiple/form.dart';


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

  static final List<MultiplePayoutRow> sampleRows = [
    MultiplePayoutRow(token: "d921...161", amount: "500", currency: "RUB", comment: "cashback001"),
    MultiplePayoutRow(token: "d921...162", amount: "100", currency: "USD", comment: "cashback002"),
    MultiplePayoutRow(token: "d921...163", amount: "120", currency: "EUR", comment: "cashback003"),
  ];

  @override
  Widget build(BuildContext context) {
    final theme = Theme.of(context);
    final l10n = AppLocalizations.of(context)!;

    final titleStyle = theme.textTheme.bodyLarge?.copyWith(
      fontSize: 18,
      fontWeight: FontWeight.w600,
    );

    final linkStyle = theme.textTheme.bodyMedium?.copyWith(
      color: theme.colorScheme.primary,
    );

    return Column(
      crossAxisAlignment: CrossAxisAlignment.stretch,
      children: [
        Row(
          children: [
            const Icon(Icons.filter_list),
            const SizedBox(width: 5),
            Text(l10n.exampleTitle, style: titleStyle),
          ],
        ),
        const SizedBox(height: 12),
        _buildDataTable(l10n),
        const SizedBox(height: 10),
        TextButton(
          onPressed: () {},
          style: TextButton.styleFrom(padding: EdgeInsets.zero),
          child: Text(l10n.downloadSampleCSV, style: linkStyle),
        ),
      ],
    );
  }

  Widget _buildDataTable(AppLocalizations l10n) {
    return DataTable(
      columnSpacing: 20,
      columns: [
        DataColumn(label: Text(l10n.tokenColumn)),
        DataColumn(label: Text(l10n.amount)),
        DataColumn(label: Text(l10n.currency)),
        DataColumn(label: Text(l10n.comment)),
      ],
      rows: sampleRows.map((row) {
        return DataRow(cells: [
          DataCell(Text(row.token)),
          DataCell(Text(row.amount)),
          DataCell(Text(row.currency)),
          DataCell(Text(row.comment)),
        ]);
      }).toList(),
    );
  }
}