package seeds

import (
	"narasi-ahli-be/app/database/entity"

	"gorm.io/gorm"
)

type MasterApprovalStatusesSeeder struct{}

var masterApprovalStatuses = []entity.MasterApprovalStatuses{
	{
		ID:       1,
		Name:     "Accepted",
		IsActive: true,
	},
	{
		ID:       2,
		Name:     "Need Update",
		IsActive: true,
	},
	{
		ID:       3,
		Name:     "Rejected",
		IsActive: true,
	},
}

func (MasterApprovalStatusesSeeder) Seed(conn *gorm.DB) error {
	for _, row := range masterApprovalStatuses {
		if err := conn.Create(&row).Error; err != nil {
			return err
		}
	}

	return nil
}

func (MasterApprovalStatusesSeeder) Count(conn *gorm.DB) (int, error) {
	var count int64
	if err := conn.Model(&entity.MasterApprovalStatuses{}).Count(&count).Error; err != nil {
		return 0, err
	}

	return int(count), nil
}
