package member

// Status 會員狀態
type Status int32

func (s *Status) CodeToString() string {
	result, ok := accountStatusMap[*s]
	if !ok {
		return ""
	}

	return result
}

var accountStatusMap = map[Status]string{
	AccountStatusUninitialized: "uninitialized", // 初始狀態（異常）
	AccountStatusUnverified:    "unverified",    // 尚未完成驗證
	AccountStatusActive:        "active",        // 帳號啟用中
	AccountStatusSuspended:     "suspended",     // 帳號停權中
}

func (s *Status) ToInt32() int32 {
	return int32(*s)
}

const (
	AccountStatusUninitialized Status = 0 // 初始狀態（異常）
	AccountStatusUnverified    Status = 1 // 尚未驗證
	AccountStatusActive        Status = 2 // 帳號啟用中
	AccountStatusSuspended     Status = 3 // 帳號停權中
)

// IsValid returns true if the status is valid
func (s Status) IsValid() bool {
	return s >= AccountStatusUninitialized && s <= AccountStatusSuspended
}
