package models

import (
	"time"

	"github.com/google/uuid"
)

type IngredientComposition struct {
	ID                 uuid.UUID  `json:"id"`
	OrganizationID     uuid.UUID  `json:"organization_id"`
	OutletID           *uuid.UUID `json:"outlet_id"`
	ParentIngredientID uuid.UUID  `json:"parent_ingredient_id"`
	ChildIngredientID  uuid.UUID  `json:"child_ingredient_id"`
	Quantity           float64    `json:"quantity"`
	CreatedAt          time.Time  `json:"created_at"`
	UpdatedAt          time.Time  `json:"updated_at"`

	// Relations
	ParentIngredient *Ingredient `json:"parent_ingredient,omitempty"`
	ChildIngredient  *Ingredient `json:"child_ingredient,omitempty"`
}

type CreateIngredientCompositionRequest struct {
	OutletID           *uuid.UUID `json:"outlet_id"`
	ParentIngredientID uuid.UUID  `json:"parent_ingredient_id" validate:"required"`
	ChildIngredientID  uuid.UUID  `json:"child_ingredient_id" validate:"required"`
	Quantity           float64    `json:"quantity" validate:"required,gt=0"`
}

type UpdateIngredientCompositionRequest struct {
	OutletID *uuid.UUID `json:"outlet_id"`
	Quantity float64    `json:"quantity" validate:"required,gt=0"`
}

type IngredientCompositionResponse struct {
	ID                 uuid.UUID  `json:"id"`
	OrganizationID     uuid.UUID  `json:"organization_id"`
	OutletID           *uuid.UUID `json:"outlet_id"`
	ParentIngredientID uuid.UUID  `json:"parent_ingredient_id"`
	ChildIngredientID  uuid.UUID  `json:"child_ingredient_id"`
	Quantity           float64    `json:"quantity"`
	CreatedAt          time.Time  `json:"created_at"`
	UpdatedAt          time.Time  `json:"updated_at"`

	// Relations
	ParentIngredient *Ingredient `json:"parent_ingredient,omitempty"`
	ChildIngredient  *Ingredient `json:"child_ingredient,omitempty"`
}
