package dashboard

import (
	"Wine-Server/utils"
	"Wine-Server/utils/tables"
	"github.com/gorilla/websocket"
)

func Handle(msg utils.WsMsg, conn *websocket.Conn, manager *tables.ManagerTable) {
	switch msg.Event {
	case "adminDashboardRankDevices":
		rankDevices(conn, manager, msg.Data)
		break
	case "adminDashboardRankWines":
		rankWines(conn, manager, msg.Data)
		break
	case "adminDashboardRankWorkers":
		rankWorkers(conn, manager, msg.Data)
		break
	case "adminDashboardQuerySelf":
		querySelf(conn, manager, msg.Data)
		break
	case "adminDashboardQueryDevice":
		queryDevice(conn, manager, msg.Data)
		break
	case "adminDashboardQueryWine":
		queryWine(conn, manager, msg.Data)
		break
	case "adminDashboardQueryWorker":
		queryWorker(conn, manager, msg.Data)
		break
	default:
		_ = conn.WriteJSON(utils.WsError("unrecognized event"))
		break
	}
}
