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 "superDashboardRankAdmins":
		rankAdmins(conn, manager, msg.Data)
		break
	case "superDashboardRankDevices":
		rankDevices(conn, manager, msg.Data)
		break
	case "superDashboardRankWines":
		rankWines(conn, manager, msg.Data)
		break
	case "superDashboardRankWorkers":
		rankWorkers(conn, manager, msg.Data)
		break
	case "superDashboardQueryAdmin":
		queryAdmin(conn, manager, msg.Data)
		break
	case "superDashboardQueryDevice":
		queryDevice(conn, manager, msg.Data)
		break
	case "superDashboardQueryWine":
		queryWine(conn, manager, msg.Data)
		break
	case "superDashboardQueryWorker":
		queryWorker(conn, manager, msg.Data)
		break
	default:
		_ = conn.WriteJSON(utils.WsError("unrecognized event"))
		break
	}
}
