import 'package:flutter/material.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/community_structure_header_button.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import 'package:syncrow_web/utils/constants/assets.dart';

class CommunityStructureHeaderActionButtons extends StatelessWidget {
  const CommunityStructureHeaderActionButtons(
      {super.key,
      required this.theme,
      required this.isSave,
      required this.onSave,
      required this.onDelete,
      required this.selectedSpace,
      required this.onDuplicate,
      required this.onEdit});

  final ThemeData theme;
  final bool isSave;
  final VoidCallback onSave;
  final VoidCallback onDelete;
  final VoidCallback onDuplicate;
  final VoidCallback onEdit;

  final SpaceModel? selectedSpace;

  @override
  Widget build(BuildContext context) {
    final canShowActions = selectedSpace != null &&
        selectedSpace?.status != SpaceStatus.deleted &&
        selectedSpace?.status != SpaceStatus.parentDeleted;

    return Wrap(
      alignment: WrapAlignment.end,
      spacing: 10,
      children: [
        if (isSave)
          CommunityStructureHeaderButton(
            label: "Save",
            icon: const Icon(Icons.save,
                size: 18, color: ColorsManager.spaceColor),
            onPressed: onSave,
            theme: theme,
          ),
        if (canShowActions) ...[
          CommunityStructureHeaderButton(
            label: "Edit",
            svgAsset: Assets.editSpace,
            onPressed: onEdit,
            theme: theme,
          ),
          // CommunityStructureHeaderButton(
          //   label: "Duplicate",
          //   svgAsset: Assets.duplicate,
          //   onPressed: onDuplicate,
          //   theme: theme,
          // ),
          CommunityStructureHeaderButton(
            label: "Delete",
            svgAsset: Assets.spaceDelete,
            onPressed: onDelete,
            theme: theme,
          ),
        ],
      ],
    );
  }
}
