package models

import "time"

// Application represents a job application (from user or guest)
type Application struct {
	ID     string  `json:"id" db:"id"`
	JobID  string  `json:"jobId" db:"job_id"`
	UserID *string `json:"userId,omitempty" db:"user_id"` // NULL for guest applications

	// Applicant Info (for guest applications)
	Name     *string `json:"name,omitempty" db:"name"`
	Phone    *string `json:"phone,omitempty" db:"phone"`
	LineID   *string `json:"lineId,omitempty" db:"line_id"`
	WhatsApp *string `json:"whatsapp,omitempty" db:"whatsapp"`
	Email    *string `json:"email,omitempty" db:"email"`

	// Application Content
	Message   *string `json:"message,omitempty" db:"message"`
	ResumeURL *string `json:"resumeUrl,omitempty" db:"resume_url"`
	Documents JSONMap `json:"documents,omitempty" db:"documents"` // Array of {type, url}

	// Status & Notes
	Status string  `json:"status" db:"status"` // pending, reviewed, shortlisted, rejected, hired
	Notes  *string `json:"notes,omitempty" db:"notes"`

	// Metadata
	CreatedAt time.Time `json:"createdAt" db:"created_at"`
	UpdatedAt time.Time `json:"updatedAt" db:"updated_at"`
}

// ApplicationWithDetails includes job and user information
type ApplicationWithDetails struct {
	Application
	JobTitle       string  `json:"jobTitle"`
	CompanyID      string  `json:"companyId"`
	CompanyName    string  `json:"companyName"`
	ApplicantName  string  `json:"applicantName"` // From user or guest name
	ApplicantPhone *string `json:"applicantPhone,omitempty"`
}
