package common

import (
	"github.com/fiskerinc/cloud-services/pkg/common/dbbasemodel"
)

type CarSetting struct {
	VIN      string `pg:"vin" json:"-"`
	DriverID string `pg:"driver_id" json:"-"`
	Name     string `pg:",pk" json:"name"`
	Value    string `json:"value"`
	Type     string `json:"type"`
	dbbasemodel.DBModelBase
}

type MobileSettingsUpdate struct {
	VIN      string       `json:"vin"`
	Settings []CarSetting `json:"settings"`
}

type HMISettingsUpdate struct {
	DriverID string       `json:"driver_id"`
	Settings []CarSetting `json:"settings"`
}

/*
It would be nice if we could do this easily, but requires a cast to string which isn't so nice
type CarSettingEnum string
*/
const (
	SEQUENCE_NUMBER      string = "SEQUENCE_NUMBER"
	BODY_COLOR           string = "BODY_COLOR"
	DELIVERY_DESTINATION string = "DELIVERY_DESTINATION"
)

// Take in the feature codes for the car, and convert it to body color string, will probably change
func FeatureCodeToBodyColor(VehicleFeatures []FeatureCodes) (bodyColor string) {
	var colorCode string
	for x := range VehicleFeatures {
		if VehicleFeatures[x].FamilyCode == "0103" {
			colorCode = VehicleFeatures[x].FeatureCode
			break
		}
	}

	switch colorCode {
	case "010300":
		return "PRIMERED"
	case "010301":
		return "SOLID_WHITE"
	case "010302":
		return "SOLID_BLACK"
	case "010303":
		return "BLUE_GREY_MET"
	case "010304":
		return "MID_BLUE_GLOSS"
	case "010305":
		return "MID_BLUE_MATTE"
	case "010306":
		return "VIVID_BLUE"
	case "010307":
		return "SPE_COOL_SILVER"
	case "010308":
		return "STEALTH_GREEN"
	case "010309":
		return "VIVID_ORANGE"
	case "010310":
		return "EARTH_COPPER"
	case "010311":
		return "METALLIC_BLUE_BLACK"
	case "010312":
		return "WHITE_PEARL"
	case "010313":
		return "STEALTH_GREEN_GLOSS"
	case "010314":
		return "SOLID_RED"
	default:
		return "MISSING_COLOR"
	}
}
