package routes

import (
	"gitlab.com/pactual1/backend/controllers"

	"github.com/gin-gonic/gin"
)

func RegisterPublicRoutes(r *gin.Engine) {

	// Health checks
	r.GET("/health", controllers.HealthCheck)

	// Map dashboard
	r.GET("/dashboard/map/contract/devices", controllers.GetDevicesByContract)
	r.GET("/dashboard/map/contracts", controllers.GetLatestContracts)
	r.GET("/dashboard/map/device_data", controllers.GetDeviceData)

	// Invoices
	r.GET("/invoices", controllers.GetInvoices)
	r.GET("/invoices/:id", controllers.GetInvoiceByID)

	r.POST("/device_data/save", controllers.SaveDeviceInfo)
	r.GET("/buyers", controllers.ListCompanies)
	r.GET("/products", controllers.ListProductTemplates)
	r.GET("/templates", controllers.ListTextTemplates)
	r.POST("/templates/save", controllers.CreateTextTemplate)
	r.GET("/products/:template_id", controllers.GetProductTemplate)

	// Contracts
	r.GET("/contracts/statuses", controllers.GetContractStatuses)
	r.GET("/contracts", controllers.GetBuyerContracts)
	r.POST("/contracts/create", controllers.CreateContract)

	r.GET("/contracts/:contract_id", controllers.GetContractByID)
	r.PATCH("/contracts/:contract_id", controllers.UpdateContract)

	// Locations
	r.GET("/locations", controllers.SearchPlace)

	// Notifications
	r.GET("/notifications", controllers.GetNotifications)

	// Stats
	r.GET("/stats/measurements", controllers.GetCompanyRelatedDeviceInfoCount)
	r.GET("/stats/devices", controllers.GetCompanyRelatedDeviceInfoCountWithTempRange)
	r.GET("/stats/contracts", controllers.GetContractCountByStatus)
	r.GET("/stats/contracts/total", controllers.GetTotalContractCount)
	r.GET("/stats/invoices", controllers.GetInvoiceCountByStatus)
	r.GET("/stats/milestones", controllers.GetContractsMatchingDeviceLocation)

	//Users
	r.POST("/user/reset/password", controllers.ResetPassword)
	r.POST("/user/set/password", controllers.UpdatePassword)
	r.POST("/user/login", controllers.Login)
	r.POST("/user/logout", controllers.Logout)
}
