// Package offices is the single source of truth for the firm's office list.
//
// The keys here must stay in sync with the CHECK constraints on
// paliad.users.office (mig 002) and paliad.partner_units.office
// (mig 018, renamed mig 024 + mig 027). Madrid added mig 106.
package offices

// Office is a single firm office with its i18n-ready labels.
type Office struct {
	Key     string `json:"key"`
	LabelDE string `json:"label_de"`
	LabelEN string `json:"label_en"`
}

// All offices in display order. Keep in sync with the DB CHECK constraint.
var All = []Office{
	{Key: "munich", LabelDE: "München", LabelEN: "Munich"},
	{Key: "duesseldorf", LabelDE: "Düsseldorf", LabelEN: "Düsseldorf"},
	{Key: "hamburg", LabelDE: "Hamburg", LabelEN: "Hamburg"},
	{Key: "amsterdam", LabelDE: "Amsterdam", LabelEN: "Amsterdam"},
	{Key: "london", LabelDE: "London", LabelEN: "London"},
	{Key: "paris", LabelDE: "Paris", LabelEN: "Paris"},
	{Key: "milan", LabelDE: "Mailand", LabelEN: "Milan"},
	{Key: "madrid", LabelDE: "Madrid", LabelEN: "Madrid"},
}

// IsValid reports whether the given key names a known office.
func IsValid(key string) bool {
	for _, o := range All {
		if o.Key == key {
			return true
		}
	}
	return false
}

// Keys returns the office keys in display order.
func Keys() []string {
	keys := make([]string, len(All))
	for i, o := range All {
		keys[i] = o.Key
	}
	return keys
}
