import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/cupertino.dart';
import 'package:hmg_patient_app_new/core/app_assets.dart';
import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
import 'package:hmg_patient_app_new/features/my_appointments/models/resp_models/patient_appointment_history_response_model.dart';
import 'package:hmg_patient_app_new/generated/locale_keys.g.dart';
import 'package:hmg_patient_app_new/theme/colors.dart';

class AppointmentType {
  static var BOOKED = 0;
  static const BOOKED_STR = 'booked';
  static var CONFIRMED = 42;
  static const CONFIRMED_STR = 'confirmed';
  static var ARRIVED = 43;
  static const ARRIVED_STR = 'arrived';

  static bool isConfirmed(PatientAppointmentHistoryResponseModel appo) {
    return AppointmentType.isValid(appo) && appo.patientStatusType == AppointmentType.CONFIRMED;
  }

  static bool isBooked(PatientAppointmentHistoryResponseModel appo) {
    return AppointmentType.isValid(appo) && appo.patientStatusType == AppointmentType.BOOKED;
  }

  static bool isArrived(PatientAppointmentHistoryResponseModel appo) {
    return AppointmentType.isValid(appo) && appo.patientStatusType == AppointmentType.ARRIVED;
  }

  static isValid(appo) {
    return appo != null && appo.patientStatusType != null;
  }

  static String getAppointmentStatusType(int appoStatus) {
    switch (appoStatus) {
      case 0:
        return LocaleKeys.booked.tr();
      case 42:
        return LocaleKeys.confirmed.tr();
      case 43:
        return LocaleKeys.arrived.tr();
      default:
        return LocaleKeys.booked.tr();
    }
  }

  static Color getNextActionButtonColor(nextAction) {
    switch (nextAction) {
      case 0:
        return AppColors.successColor;
      case 10:
        return AppColors.successColor;
      case 15:
        return AppColors.greyColor;
      case 20:
        return AppColors.infoColor;
      case 50:
        return AppColors.successColor;
      case 90:
        return AppColors.alertColor;
      default:
        return AppColors.successColor;
    }
  }

  static String getNextActionText(nextAction) {
    switch (nextAction) {
      case 0:
        return "No Action".needTranslation;
      case 10:
        return LocaleKeys.confirm.tr();
      case 15:
        return LocaleKeys.pendingPayment.tr();
      case 20:
        return LocaleKeys.payNow.tr();
      case 50:
        return LocaleKeys.confirmLiveCare.tr();
      case 90:
        return LocaleKeys.checkinOption.tr();
      default:
        return "No Action".needTranslation;
    }
  }

  static String getNextActionIcon(nextAction) {
    switch (nextAction) {
      case 0:
        return AppAssets.checkmark_icon;
      case 10:
        return AppAssets.confirm_appointment_icon;
      case 15:
        return AppAssets.appointment_pay_icon;
      case 20:
        return AppAssets.appointment_pay_icon;
      case 50:
        return AppAssets.confirm_appointment_icon;
      case 90:
        return AppAssets.appointment_checkin_icon;
      default:
        return AppAssets.checkmark_icon;
    }
  }
}
