/**
 * Shared types for CustomersPanel components
 */

import type { Lang } from "@/lib/config";

// Customer type from database
export interface DBCustomer {
  id: string;
  name: string;
  phone: string;
  email: string | null;
  notes: string | null;
  createdAt: string;
  updatedAt: string;
}

// Booking type matching database schema
export interface CustomerBooking {
  id: string;
  customerName: string;
  customerPhone: string;
  customerEmail?: string | null;
  service: string;
  appointmentDate: string | Date;
  appointmentTime: string;
  duration?: number;
  staffMember?: string | null;
  depositAmount?: number | null;
  depositPaid?: boolean;
  totalAmount?: number;
  status: "pending" | "confirmed" | "completed" | "cancelled" | "no_show";
  source?: string;
  notes?: string | null;
  createdAt?: string | Date;
  updatedAt?: string | Date;
}

// Customer type for frontend state (enriched with booking data)
export interface Customer {
  id: string;
  name: string;
  phone: string;
  email: string;
  notes: string;
  createdAt: Date;
  bookings: CustomerBooking[];
  totalSpent: number;
  lastVisit: Date | null;
  isFromDB: boolean; // Flag to track if customer is from database
}

// Form data for customer creation/editing
export interface CustomerFormData {
  name: string;
  phone: string;
  email: string;
  notes: string;
}

// Props for components
export interface CustomersPanelProps {
  lang: Lang;
  bookings: CustomerBooking[];
}

export interface CustomerFiltersProps {
  lang: Lang;
  searchQuery: string;
  onSearchChange: (query: string) => void;
  totalCustomers: number;
  returningCustomers: number;
  avgBookings: string;
  onAddCustomer: () => void;
}

export interface CustomerTableProps {
  lang: Lang;
  customers: Customer[];
  isLoading: boolean;
  onViewDetails: (customer: Customer) => void;
  onEdit: (customer: Customer) => void;
  onDelete: (customer: Customer) => void;
  onAddCustomer: () => void;
}

export interface CustomerFormProps {
  lang: Lang;
  isOpen: boolean;
  isEditing: boolean;
  formData: CustomerFormData;
  formErrors: Record<string, string>;
  isSaving: boolean;
  onClose: () => void;
  onFormChange: (data: CustomerFormData) => void;
  onSave: () => void;
}

export interface CustomerDetailModalProps {
  lang: Lang;
  customer: Customer;
  onClose: () => void;
  onEdit: (customer: Customer) => void;
  onViewAppointment: (booking: CustomerBooking) => void;
}

export interface CustomerDeleteModalProps {
  lang: Lang;
  customer: Customer;
  isSaving: boolean;
  onClose: () => void;
  onConfirm: () => void;
}

// Dashboard translations type (partial, for the keys we use)
export interface DashboardTranslations {
  customers: string;
  customersDesc: string;
  addCustomer: string;
  totalCustomers: string;
  returningCustomers: string;
  avgBookingsPerCustomer: string;
  searchCustomers: string;
  noCustomersYet: string;
  noCustomersYetDesc: string;
  customerName: string;
  phone: string;
  email: string;
  totalBookings: string;
  lastVisit: string;
  lifetimeValue: string;
  actions: string;
  viewCustomerDetails: string;
  edit: string;
  delete: string;
  editCustomer: string;
  addNewCustomer: string;
  fullName: string;
  fullNamePlaceholder: string;
  mobileNumber: string;
  mobileNumberPlaceholder: string;
  emailAddress: string;
  emailPlaceholder: string;
  notes: string;
  notesPlaceholder: string;
  cancelAction: string;
  updateCustomer: string;
  saveCustomer: string;
  requiredField: string;
  invalidPhone: string;
  invalidEmail: string;
  customerSince: string;
  contactInfo: string;
  appointmentHistory: string;
  noAppointmentHistory: string;
  sendMessage: string;
  createAppointmentFor: string;
  confirmDelete: string;
  confirmDeleteDesc: string;
  deleteCustomer: string;
}
