package domain

import (
	"fmt"

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

type ReportRequestStatus string

var (
	PendingReportRequest ReportRequestStatus = "pending"
	SuccessReportRequest ReportRequestStatus = "success"
	RejectReportRequest  ReportRequestStatus = "reject"
)

func (r ReportRequestStatus) IsValid() bool {
	switch r {
	case PendingReportRequest, SuccessReportRequest, RejectReportRequest:
		return true
	default:
		return false
	}
}

func ParseReportRequestStatus(val string) (ReportRequestStatus, error) {
	r := ReportRequestStatus(val)
	if !r.IsValid() {
		return "", fmt.Errorf("invalid ReportRequestStatus: %q", val)
	}
	return r, nil
}

type ValidReportRequestStatus struct {
	Value ReportRequestStatus
	Valid bool
}

func (v ValidReportRequestStatus) ToPG() pgtype.Text {
	return pgtype.Text{
		String: string(v.Value),
		Valid:  v.Valid,
	}
}
