package router

import (
	"jannex/robot-control-manager/routers/api/v1/control"
	"jannex/robot-control-manager/routers/api/v1/permitjoin"
	"jannex/robot-control-manager/routers/api/v1/robot"
	"jannex/robot-control-manager/routers/api/v1/robots"
	"jannex/robot-control-manager/routers/api/v1/sse"

	"github.com/gofiber/fiber/v2"
)

func SetupRoutes(app *fiber.App) {
	v1 := app.Group("/v1")

	r := v1.Group("/robot")
	r.Post("/", robot.FirstRequest)
	r.Post("/authorize/:robotId", robot.AuthorizeRobot)
	r.Delete("/:robotId", robot.DeleteRobot)
	r.Delete("/deny/:robotId", robot.DenyUnauthorizedRobot)
	r.Patch("/", robot.UpdateRobot)

	rs := v1.Group("/robots")
	rs.Get("/", robots.GetRobots)

	rsu := v1.Group("/urobots")
	rsu.Get("/", robots.GetUnauthorizedRobots)

	c := v1.Group("/control")
	c.Post("/1", control.ControlRex)
	c.Post("/1/finish", control.FinishControlRex)

	pj := v1.Group("/permitjoin")
	pj.Post("/:enabled", permitjoin.SetPermitJoin)
	pj.Get("/", permitjoin.GetPermitJoin)

	v1.Get("/sse", sse.SSE)

	app.Static("/", "./public/")
}
