package handlers

import (
	"html/template"

	"abuse_registration_poc/internal/auth"
	"abuse_registration_poc/internal/store"
	"abuse_registration_poc/internal/web"
)

type Dependencies struct {
	Store   *store.MemoryStore
	Users   *auth.UserStore
	Version string
	AppName string
	BaseURL string
}

type Handler struct {
	store   *store.MemoryStore
	users   *auth.UserStore
	index   *template.Template
	version string
	appName string
	baseURL string
}

func New(deps Dependencies) (*Handler, error) {
	index, err := template.ParseFS(web.Templates, "templates/index.html")
	if err != nil {
		return nil, err
	}
	return &Handler{
		store:   deps.Store,
		users:   deps.Users,
		index:   index,
		version: deps.Version,
		appName: deps.AppName,
		baseURL: deps.BaseURL,
	}, nil
}
