package expenses

import (
	m "gitlab.com/mbugroup/lti-api.git/internal/middleware"
	controller "gitlab.com/mbugroup/lti-api.git/internal/modules/expenses/controllers"
	expense "gitlab.com/mbugroup/lti-api.git/internal/modules/expenses/services"
	user "gitlab.com/mbugroup/lti-api.git/internal/modules/users/services"

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

func ExpenseRoutes(v1 fiber.Router, u user.UserService, s expense.ExpenseService) {
	ctrl := controller.NewExpenseController(s)

	route := v1.Group("/expenses")
	route.Use(m.Auth(u))

	// route.Use(m.Auth(u))
	// route.Get("/", m.Auth(u), ctrl.GetAll)
	// route.Post("/", m.Auth(u), ctrl.CreateOne)
	// route.Get("/:id", m.Auth(u), ctrl.GetOne)
	// route.Patch("/:id", m.Auth(u), ctrl.UpdateOne)
	// route.Delete("/:id", m.Auth(u), ctrl.DeleteOne)

	route.Get("/", m.RequirePermissions(m.P_ExpenseGetAll), ctrl.GetAll)
	route.Post("/", m.RequirePermissions(m.P_ExpenseCreateOne), ctrl.CreateOne)
	route.Get("/:id", m.RequirePermissions(m.P_ExpenseGetOne), ctrl.GetOne)
	route.Patch("/:id", m.RequirePermissions(m.P_ExpenseUpdateOne), ctrl.UpdateOne)
	route.Delete("/:id", m.RequirePermissions(m.P_ExpenseDeleteOne), ctrl.DeleteOne)

	route.Post("/approvals/head-area", m.RequirePermissions(m.P_ExpenseApprovalHeadArea), ctrl.Approval)
	route.Post("/approvals/finance", m.RequirePermissions(m.P_ExpenseApprovalFinance), ctrl.Approval)
	route.Post("/approvals/unit-vice-president", m.RequirePermissions(m.P_ExpenseApprovalUnitVicePresident), ctrl.Approval)
	route.Post("/approvals/bulk", ctrl.BulkApproveToStatus)

	route.Post("/:id/realizations", m.RequirePermissions(m.P_ExpenseCreateRealizations), ctrl.CreateRealization)
	route.Patch("/:id/realizations", m.RequirePermissions(m.P_ExpenseUpdateRealizations), ctrl.UpdateRealization)
	route.Post("/:id/complete", m.RequirePermissions(m.P_ExpenseCompleteExpense), ctrl.CompleteExpense)
	route.Delete("/:id/documents/:documentId", m.RequirePermissions(m.P_ExpenseDocument), ctrl.DeleteDocument)
	route.Delete("/:id/realization-documents/:documentId", m.RequirePermissions(m.P_ExpenseDocumentRealizations), ctrl.DeleteRealizationDocument)
}
