import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
import 'package:krow/core/presentation/styles/kw_box_decorations.dart';
import 'package:krow/core/presentation/styles/kw_text_styles.dart';
import 'package:krow/core/presentation/styles/theme.dart';
import 'package:krow/features/shifts/data/models/cancellation_reason.dart';

class ShiftItemCanceledWidget extends StatelessWidget {
  final CancellationReason? reason;
  final bool canceledByUser;

  const ShiftItemCanceledWidget(
      {super.key, required this.reason, required this.canceledByUser});

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: const EdgeInsets.all(12.0),
      margin: const EdgeInsets.only(left: 16, right: 16, top: 8),
      decoration:
          KwBoxDecorations.primaryLight8.copyWith(color: AppColors.tintBlue),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Row(
            children: [
              Text(
                'your_shift_canceled'.tr(),
                style: AppTextStyles.bodyMediumMed
                    .copyWith(color: AppColors.primaryBlue),
              ),
            ],
          ),
          const Gap(8),
          Text(
              'please_review_reason'.tr(),
              style: AppTextStyles.bodyTinyReg
                  .copyWith(color: AppColors.primaryBlue)),
          const Gap(8),
          Row(
            children: [
              Text(
                'canceled_by'.tr(),
                style: AppTextStyles.bodyTinyReg
                    .copyWith(color: AppColors.tintDarkBlue),
              ),
              const Gap(4),
              Text(
                canceledByUser ? 'user'.tr() : 'admin'.tr(),
                style: AppTextStyles.bodyTinyReg
                    .copyWith(color: AppColors.primaryBlue),
              ),
            ],
          ),
          const Gap(8),
          Container(
            padding: const EdgeInsets.all(12.0),
            decoration: KwBoxDecorations.primaryLight6,
            child: Row(
              children: [
                Text(
                  '${'reason'.tr()}:',
                  style: AppTextStyles.bodyMediumReg
                      .copyWith(color: AppColors.blackGray),
                ),
                const Gap(4),
                Text(reasonToString(reason).tr(),
                    style: AppTextStyles.bodyMediumMed),
              ],
            ),
          ),
        ],
      ),
    );
  }

  String reasonToString(CancellationReason? reason) {
    switch (reason) {
      case CancellationReason.sickLeave:
        return 'sick_leave';
      case CancellationReason.vacation:
        return 'vacation';
      case CancellationReason.other:
        return 'Other';
      case CancellationReason.health:
        return 'health';
      case CancellationReason.transportation:
        return 'transportation';
      case CancellationReason.personal:
        return 'personal';
      case CancellationReason.scheduleConflict:
        return 'schedule_conflict';
      case null:
        return 'other';

    }
  }
}
