package dailyChecklists

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

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

func DailyChecklistRoutes(v1 fiber.Router, u user.UserService, s dailyChecklist.DailyChecklistService) {
	ctrl := controller.NewDailyChecklistController(s)

	route := v1.Group("/daily-checklists")
	route.Use(m.Auth(u))

	route.Get("/", m.RequirePermissions(m.P_DailyChecklistGetAll), ctrl.GetAll)
	route.Get("/report", m.RequirePermissions(m.P_DailyChecklistReports), ctrl.GetReport)

	route.Get("/summary", m.RequirePermissions(m.P_DailyChecklistDashboardList), ctrl.GetSummary)

	// route.Get("/report", ctrl.GetReport)

	// upsert daily checklist
	route.Post("/", m.RequirePermissions(m.P_DailyChecklistCreateOne), ctrl.CreateOne)

	// get detail data daily checklist by id
	route.Get("/relation/:idDailyChecklist", m.RequirePermissions(m.P_DailyChecklistGetOne), ctrl.GetOne)

	// get phases by daily checklist id
	route.Get("/phase/:idDailyChecklist", m.RequirePermissions(m.P_DailyChecklistCreateOne), ctrl.GetPhaseByIdChecklist)

	// create task
	/*
		ketika add phase
	*/
	route.Post("/phase/:idDailyChecklist", m.RequirePermissions(m.P_DailyChecklistCreateOne), ctrl.CreateDailyChecklistPhase)

	// create assigment
	/*
		ketika add ABK
	*/
	route.Post("/assignment/:idDailyChecklist", m.RequirePermissions(m.P_DailyChecklistCreateOne), ctrl.CreateAssignment)

	// remove assignment
	/*
		ketika remove ABK
	*/
	route.Delete("/:idDailyChecklist/assignments/:idEmployee", m.RequirePermissions(m.P_DailyChecklistCreateOne), ctrl.RemoveAssignment)

	//get all tasks
	route.Get("/tasks", m.RequirePermissions(m.P_DailyChecklistCreateOne), ctrl.GetAllTasks)

	// update assignment
	/*
		ketika check dan uncheck tugas oleh ABK
	*/
	route.Post("/assignment", m.RequirePermissions(m.P_DailyChecklistCreateOne), ctrl.UpdateAssignment)

	route.Patch("/bulk-update", m.RequirePermissions(m.P_DailyChecklistCreateOne), ctrl.BulkUpdate)
	route.Patch("/:idDailyChecklist", m.RequirePermissions(m.P_DailyChecklistCreateOne), ctrl.UpdateOne)
	route.Delete("/:idDailyChecklist", m.RequirePermissions(m.P_DailyChecklistCreateOne), ctrl.DeleteOne)
}
