import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';

export interface ContactFormData {
  firstName: string;
  lastName: string;
  email: string;
  phone?: string;
  eventType: string;
  eventDate?: string;
  guestCount?: number;
  budget?: string;
  message: string;
  privacy: boolean;
}

export interface EmailResponse {
  success: boolean;
  message: string;
  ticketId?: string;
}

@Injectable({
  providedIn: 'root'
})
export class EmailService {
  private apiUrl = '/api';

  constructor(private http: HttpClient) {}

  sendContactForm(formData: ContactFormData): Observable<EmailResponse> {
    return this.http.post<EmailResponse>(`${this.apiUrl}/contact`, formData);
  }

  subscribeNewsletter(email: string): Observable<EmailResponse> {
    return this.http.post<EmailResponse>(`${this.apiUrl}/newsletter`, { email });
  }
}