package models

import "time"

// UserResponse represents a user response (without sensitive data)
// MIGRATION UUID: ID est string (UUID serialisé)
type UserResponse struct {
	ID        string `json:"id"`
	Email     string `json:"email"`
	Username  string `json:"username"`
	FirstName string `json:"first_name,omitempty"`
	LastName  string `json:"last_name,omitempty"`
	AvatarURL string `json:"avatar_url,omitempty"`
	Role      string `json:"role,omitempty"`
	CreatedAt string `json:"created_at"`
}

// FromUser creates a UserResponse from a User model
// MIGRATION UUID: user.ID est uuid.UUID, serialisé en string
// INT-008: Standardize date format to ISO 8601 (RFC3339)
func (ur *UserResponse) FromUser(user *User) {
	ur.ID = user.ID.String()
	ur.Email = user.Email
	ur.Username = user.Username
	ur.FirstName = user.FirstName
	ur.LastName = user.LastName
	ur.CreatedAt = user.CreatedAt.UTC().Format(time.RFC3339)
}
