import 'package:flutter/material.dart';

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


class InvitationFormActions extends StatelessWidget {
  final int expiryDays;
  final ValueChanged<int> onExpiryChanged;
  final bool canCreate;
  final bool hasRoles;
  final VoidCallback onSubmit;

  const InvitationFormActions({
    super.key,
    required this.expiryDays,
    required this.onExpiryChanged,
    required this.canCreate,
    required this.hasRoles,
    required this.onSubmit,
  });

  @override
  Widget build(BuildContext context) {
    final loc = AppLocalizations.of(context)!;
    return Row(
      children: [
        Text(loc.invitationExpiresIn(expiryDays)),
        Expanded(
          child: Slider(
            label: '$expiryDays',
            min: 1,
            max: 30,
            value: expiryDays.toDouble(),
            onChanged: (value) => onExpiryChanged(value.round()),
          ),
        ),
        FilledButton.icon(
          onPressed: canCreate && hasRoles ? onSubmit : null,
          icon: const Icon(Icons.send_outlined),
          label: Text(loc.invitationSendButton),
        ),
      ],
    );
  }
}
