package crm

import (
	"context"

	"apps/backend/internal/logic/crmmap"
	"apps/backend/internal/svc"
	"apps/backend/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type SnoozeFollowUpLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewSnoozeFollowUpLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SnoozeFollowUpLogic {
	return &SnoozeFollowUpLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
}

func (l *SnoozeFollowUpLogic) SnoozeFollowUp(req *types.SnoozeFollowUpReq) (*types.FollowUpPublic, error) {
	uid, err := ownerUID(l.ctx)
	if err != nil {
		return nil, err
	}
	f, err := l.svcCtx.Crm.SnoozeFollowUp(l.ctx, uid, req.Id, req.Days)
	if err != nil {
		return nil, err
	}
	return crmmap.FollowUp(f), nil
}
