package sresponse

import (
	"net/http"

	"github.com/tech/sendico/pkg/api/http/response"
	"github.com/tech/sendico/pkg/mlogger"
	"github.com/tech/sendico/pkg/model"
)

type pendingLoginResponse struct {
	Account      accountResponse `json:"account"`
	PendingToken TokenData       `json:"pendingToken"`
	Target       string          `json:"target"`
}

func LoginPending(logger mlogger.Logger, account *model.Account, pendingToken *TokenData, target string) http.HandlerFunc {
	return response.Accepted(
		logger,
		&pendingLoginResponse{
			Account: accountResponse{
				Account:      *_createAccount(account, false),
				authResponse: authResponse{},
			},
			PendingToken: *pendingToken,
			Target:       target,
		},
	)
}
