package controller

import (
	"ticket-pimp/adapters"
	"ticket-pimp/internal/domain"
	"ticket-pimp/internal/storage/db"

	"github.com/jackc/pgx/v5/pgxpool"
)

type WorkflowController struct {
	IGit   adapters.IGit
	ICloud adapters.ICloud
	ICoda  adapters.ICoda
	pool   *pgxpool.Pool
	q      *db.Queries
	conf   *domain.Config
}

func NewApp(
	git adapters.IGit,
	cloud adapters.ICloud,
	coda adapters.ICoda,
	pool *pgxpool.Pool,
	conf *domain.Config,
) *WorkflowController {
	return &WorkflowController{
		IGit:   git,
		ICloud: cloud,
		ICoda:  coda,
		pool:   pool,
		q:      db.New(pool),
		conf:   conf,
	}
}

type ProjectResponse struct {
	Project *domain.Project
	Message error
}

type TaskConvertable struct {
	*db.Task
}

func newConvertable(db *db.Task) *TaskConvertable {
	return &TaskConvertable{
		Task: db,
	}
}

func (t *TaskConvertable) ExtractDomain() *domain.Task {
	return &domain.Task{
		ID: t.ID,
		// Summary:     "",
		Description: t.Description.String,
		Creator:     t.Creator.String,
		CreatorLink: t.CreatorLink.String,
		Assignee:    t.Assignee.String,
		CreatedAt:   t.CreatedAt.Time,
		DeletedAt:   t.DeletedAt.Time,
		UpdatedAt:   t.UpdatedAt.Time,
		// URL:         "",
	}
}
