import 'package:flutter/material.dart';

import 'package:intl/intl.dart';

import 'package:pshared/models/invitation/invitation.dart';

import 'package:pweb/pages/invitations/widgets/card/helpers.dart';

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


class InvitationCardDetails extends StatelessWidget {
  final Invitation invitation;
  final String roleLabel;
  final String inviterName;
  final DateFormat dateFormat;
  final AppLocalizations loc;

  const InvitationCardDetails({
    super.key,
    required this.invitation,
    required this.roleLabel,
    required this.inviterName,
    required this.dateFormat,
    required this.loc,
  });

  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Wrap(
          spacing: 20,
          runSpacing: 10,
          children: [
            InvitationInfoRow(
              icon: Icons.badge_outlined,
              label: loc.invitationRoleLabel,
              value: roleLabel,
            ),
            InvitationInfoRow(
              icon: Icons.schedule_outlined,
              label: invitation.isExpired
                  ? loc.invitationExpired(dateFormat.format(invitation.expiresAt.toLocal()))
                  : loc.invitationExpires(dateFormat.format(invitation.expiresAt.toLocal())),
              value: '',
            ),
            InvitationInfoRow(
              icon: Icons.person_outline,
              label: loc.invitationInvitedBy,
              value: inviterName,
            ),
          ],
        ),
        if (invitation.content.comment.isNotEmpty) ...[
          const SizedBox(height: 12),
          Text(
            invitation.content.comment,
            style: Theme.of(context).textTheme.bodyMedium,
          ),
        ],
      ],
    );
  }
}
