import 'package:flutter/material.dart';

import 'package:pshared/models/payment/quote/status_type.dart';

import 'package:pweb/controllers/payouts/multiple_payouts.dart';
import 'package:pweb/pages/dashboard/payouts/quote_status/widgets/card.dart';
import 'package:pweb/utils/quote_duration_format.dart';

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


class MultipleQuoteStatusCard extends StatelessWidget {
  const MultipleQuoteStatusCard({
    super.key,
    required this.controller,
  });

  final MultiplePayoutsController controller;

  @override
  Widget build(BuildContext context) {
    final loc = AppLocalizations.of(context)!;
    final isLoading = controller.quoteIsLoading;
    final statusType = controller.quoteStatusType;
    final timeLeft = controller.quoteTimeLeft;

    String statusText;
    String? helperText;
    switch (statusType) {
      case QuoteStatusType.loading:
        statusText = loc.quoteUpdating;
        break;
      case QuoteStatusType.error:
        statusText = loc.quoteErrorGeneric;
        break;
      case QuoteStatusType.missing:
        statusText = loc.quoteUnavailable;
        break;
      case QuoteStatusType.expired:
        statusText = loc.quoteExpired;
        break;
      case QuoteStatusType.active:
        statusText = timeLeft == null
            ? loc.quoteActive
            : loc.quoteExpiresIn(formatQuoteDuration(timeLeft));
        break;
    }

    return QuoteStatusCard(
      statusType: statusType,
      statusText: statusText,
      helperText: helperText,
      isLoading: isLoading,
      canRefresh: false,
      showPrimaryRefresh: false,
      onRefresh: () {},
    );
  }
}
