import 'package:flutter/material.dart';
import 'package:krow/core/data/models/staff/pivot.dart';
import 'package:krow/core/entity/position_entity.dart';
import 'package:krow/core/presentation/styles/theme.dart';

class StaffContact {
  final String id;
  PivotStatus status;
  final String? photoUrl;
  final String firstName;
  final String lastName;
  final String? phoneNumber;
  final String? email;
  final double rate;
  final ValueNotifier<double> rating = ValueNotifier(0);
  final bool isFavorite;
  final bool isBlackListed;
  final String startAt;
  final String endAt;
  final String breakIn;
  final String breakOut;
  final String skillName;
  PositionEntity? parentPosition;

  StaffContact(
      {required this.id,
      required this.firstName,
      required this.lastName,
      this.photoUrl,
      this.status = PivotStatus.assigned,
      this.phoneNumber,
      this.email,
      this.rate = 0,
      this.isFavorite = false,
      this.isBlackListed = false,
      this.startAt = '',
      this.endAt = '',
      this.breakIn = '',
      this.breakOut = '',
      this.parentPosition,
      this.skillName = ''});

  StaffContact copyWith({
    String? id,
    PivotStatus? status,
    String? photoUrl,
    String? firstName,
    String? lastName,
    String? phoneNumber,
    String? email,
    double? rate,
    double? rating,
    bool? isFavorite,
    bool? isBlackListed,
    String? startAt,
    String? endAt,
    String? skillName,
    PositionEntity? parentPosition,
  }) {
    return StaffContact(
      id: id ?? this.id,
      status: status ?? this.status,
      photoUrl: photoUrl ?? this.photoUrl,
      firstName: firstName ?? this.firstName,
      lastName: lastName ?? this.lastName,
      phoneNumber: phoneNumber ?? this.phoneNumber,
      email: email ?? this.email,
      rate: rate ?? this.rate,
      isFavorite: isFavorite ?? this.isFavorite,
      isBlackListed: isBlackListed ?? this.isBlackListed,
      startAt: startAt ?? this.startAt,
      endAt: endAt ?? this.endAt,
      skillName: skillName ?? this.skillName,
      parentPosition: parentPosition ?? this.parentPosition,
    );
  }
}

extension PivotStatusStatusX on PivotStatus {
  Color getStatusTextColor() {
    return switch (this) {
      PivotStatus.assigned || PivotStatus.confirmed => AppColors.primaryBlue,
      PivotStatus.ongoing || PivotStatus.completed => AppColors.statusSuccess,
      PivotStatus.canceledByStaff ||
      PivotStatus.canceledByBusiness ||
      PivotStatus.canceledByAdmin ||
      PivotStatus.requestedReplace ||
      PivotStatus.noShowed ||
      PivotStatus.declineByStaff =>
        AppColors.statusError
    };
  }

  Color getStatusBorderColor() {
    return switch (this) {
      PivotStatus.assigned || PivotStatus.confirmed => AppColors.tintBlue,
      PivotStatus.ongoing || PivotStatus.completed => AppColors.tintGreen,
      PivotStatus.canceledByStaff ||
      PivotStatus.canceledByBusiness ||
      PivotStatus.canceledByAdmin ||
      PivotStatus.declineByStaff ||
      PivotStatus.noShowed ||
      PivotStatus.requestedReplace =>
        AppColors.tintRed
    };
  }
}
