package handlers

import (
	client_handlers "cpone/handlers/client"
	corporate_handlers "cpone/handlers/corporate"
	dev_handlers "cpone/handlers/dev"
	public_handlers "cpone/handlers/public"
	client_services "cpone/services/client"
	corporate_services "cpone/services/corporate"
	dev_services "cpone/services/dev"
	public_services "cpone/services/public"

	"cpone/db"

	"github.com/labstack/echo/v4"
)

func SetupRoutes(app *echo.Echo, h *dev_handlers.UserHandler) {
	group := app.Group("/user")

	group.GET("", h.HandlerShowUsers)
	group.GET("/details/:id", h.HandlerShowUserById)

}

// PLAYGROUND TESTING
func SetupRoutesLogin(app *echo.Echo, h *dev_handlers.LoginHandler) {
	l := app.Group("/login")
	l.GET("/", h.HandlerShowLogin)
}
func SetupRoutesXsample(app *echo.Echo, h *dev_handlers.XsampleHandler) {
	xSample := app.Group("/xsample")
	xSample.GET("/xsample01", h.Hello)
	xSample.GET("/coba", h.ShowCoba)
	xSample.GET("/counter", h.ShowCounter)
	xSample.GET("/counterchange", h.ChangeCounter)
}
func SetupRoutesLandingPage(app *echo.Echo, h *dev_handlers.LandingPageHandler, mastermenuusergroupHandler *dev_handlers.MasterMenuUserGroupHandler) {
	Lp := app.Group("/landing_page")
	Lp.GET("/", h.ShowLandingPage)
	clientgroup := app.Group("/client")
	// mdgroup := clientgroup.Group("/md")
	// clientusergroup.GET("/md", mastermenuusergroupHandler.HandlerShowMasterMenuUserGroup)
	clientgroup.GET("/usergroup", mastermenuusergroupHandler.HandlerShowMasterMenuUserGroup)
	// autocomplete := app.Group("/client")
	// autocomplete.GET("/autocomplete", mastermenuusergroupHandler.HandlerListAutoComplete)
	// autocomplete.GET("/autoCompleteLoadMore/:pageOf/:searchParam/:limit", mastermenuusergroupHandler.HandlerListAutoCompleteLoadMore)
	// autocomplete.GET("/autoCompleteSetValue/:setvalue", mastermenuusergroupHandler.HandlerListAutoCompleteAfterSelected)

}
func SetupRoutesPieChart(app *echo.Echo, h *dev_handlers.PiechartHandler) {
	Lp := app.Group("/pie_chart")
	Lp.GET("/", h.ShowPieChart)
	Lp.GET("/peserta", h.ShowMcuPeserta)
	Lp.GET("/bar", h.ShowBarChart)
}
func SetupRoutesEmployee(app *echo.Echo, e *dev_handlers.EmployeeHandler) {
	employee := app.Group("/employee")
	employee.GET("/", e.ShowEmployee)
}
func SetupRoutesProject(app *echo.Echo) {

}
func SetupRoutesPublic(app *echo.Echo, appStore db.AppStore) {
	public := app.Group("/")
	l := public_services.NewServicesLandingPage(public_services.LandingPage{}, appStore)
	lh := public_handlers.NewLandingPageHandler(l)
	public.GET("landingpage", lh.ShowLandingPage)
	loginHdr := public_handlers.NewLoginHandler(l)
	public.GET("login", loginHdr.HandlerShowLogin)

	// kartu kontrol
	publicKartuKontrolServices := public_services.NewServicesKartuKontrol(appStore)
	publicKartuKontrolhandlers := public_handlers.NewKartuKontrolHandler(publicKartuKontrolServices)
	public.GET("kartukontrol/:nomorRegistrasi", publicKartuKontrolhandlers.HandlerShowKartuKontrol)
	public.GET("modalsurveykartukontrol", publicKartuKontrolhandlers.HandlerShowWordingModalSurveyMcu)

	// survey mcu page (pertanyaan dan jawaban)
	publicSurveyMcuServices := public_services.NewServicesSurveyMcu(appStore)
	publicSurveyMcuhandlers := public_handlers.NewSurveyMcuHandler(publicSurveyMcuServices)
	public.GET("surveymcu/:nomorRegistrasi", publicSurveyMcuhandlers.HandlerShowSurveyMcu)

	// hide toast
	public.GET("hidetoastkartukontrol", publicKartuKontrolhandlers.HandlerHideToast)

	// surveymcuproses
	public.POST("surveymcuproses/:nomorRegistrasi", publicSurveyMcuhandlers.HandlerProcessSurveyMcu)

	// redirect to survey mcu page
	public.GET("redirectsurveymcu", publicKartuKontrolhandlers.HandlerRedirectToSurveyMcu)
}
func SetupRoutesCorporate(app *echo.Echo, appStore db.AppStore) {
	public := app.Group("/corp")
	l := corporate_services.NewServicesCompany(appStore)
	lh := corporate_handlers.NewCompanyHandler(l)
	public.GET("/company", lh.ShowCompany)
	patientHandler := corporate_handlers.NewPatientHandler(l)
	public.GET("/patient", patientHandler.ShowPatient)
}

func SetupRoutesClient(app *echo.Echo, appStore db.AppStore) {
	public := app.Group("/client")

	lpanel := client_services.NewServicesMdPanel(appStore)
	lhpanel := client_handlers.NewMdPanelHandler(lpanel)
	public.GET("/md/panel", lhpanel.ShowMdPanel)

	lpasien := client_services.NewServicesMdPasien(appStore)
	lhpasien := client_handlers.NewMdPasienHandler(lpasien)
	public.GET("/md/pasien", lhpasien.ShowMdPasien)

	ldokter := client_services.NewServicesMdDokter(appStore)
	lhdokter := client_handlers.NewMdDokterHandler(ldokter)
	public.GET("/md/dokter", lhdokter.ShowMdDokter)

	lhargasingle := client_services.NewServicesMdHargaSingle(appStore)
	lhhargasingle := client_handlers.NewMdHargaSingleHandler(lhargasingle)
	public.GET("/md/hargasingle", lhhargasingle.ShowMdHargaSingle)

	lresultnonlab := client_services.NewServicesMdResultNonLab(appStore)
	lhresultnonlab := client_handlers.NewMdResultNonLabHandler(lresultnonlab)
	public.GET("/md/resultnonlab", lhresultnonlab.ShowMdResultNonLab)

	ltemplatefisik := client_services.NewServicesMdTemplateFisik(appStore)
	lhtemplatefisik := client_handlers.NewMdTemplateFisikHandler(ltemplatefisik)
	public.GET("/md/templatefisik", lhtemplatefisik.ShowMdTemplateFisik)

	lhargapanel := client_services.NewServicesMdHargaPanel(appStore)
	lhhargapanel := client_handlers.NewMdHargaPanelHandler(lhargapanel)
	public.GET("/md/hargapanel", lhhargapanel.ShowMdHargaPanel)

	lhargaprofile := client_services.NewServicesMdHargaProfile(appStore)
	lhhargaprofile := client_handlers.NewMdHargaProfileHandler(lhargaprofile)
	public.GET("/md/hargaprofile", lhhargaprofile.ShowMdHargaProfile)

	lpaket := client_services.NewServicesMdPaket(appStore)
	lhpaket := client_handlers.NewMdPaketHandler(lpaket)
	public.GET("/md/paket", lhpaket.ShowMdPaket)

	lsamplestation := client_services.NewServicesMdSampleStation(appStore)
	lhsamplestation := client_handlers.NewMdSampleStationHandler(lsamplestation)
	public.GET("/md/samplestation", lhsamplestation.ShowMdSampleStation)

	lsampletype := client_services.NewServicesMdSampleType(appStore)
	lhsampletype := client_handlers.NewMdSampleTypeHandler(lsampletype)
	public.GET("/md/sampletype", lhsampletype.ShowMdSampleType)
	//MD BAHAN
	mdBahanService := client_services.NewServicesMdBahan(appStore)
	mdbahanHandler := client_handlers.NewMdBahanHandler(mdBahanService)
	public.GET("/md/bahan", mdbahanHandler.ShowMdBahan)

	//Client Dahboard
	clientDashboardService := client_services.NewServicesClientDashboard(appStore)
	clientdshbrdHandler := client_handlers.NewClientDashboardHandler(clientDashboardService)
	public.GET("", clientdshbrdHandler.ShowClientDashboard)

	//MD User
	mdUserService := client_services.NewServicesMdUser(appStore)
	mdUserHandler := client_handlers.NewMdUserHandler(mdUserService)
	public.GET("/md/user", mdUserHandler.ShowMdUser)

	// MD Corp
	mdCorpService := client_services.NewServicesMdCorp(appStore)
	mdCorpHandler := client_handlers.NewMdCorpHandler(mdCorpService)
	public.GET("/md/corp", mdCorpHandler.ShowMdCorp)

	// Md User Group
	mdUserGroupService := client_services.NewServicesMdUserGroup(appStore)
	mdUserGroupHandler := client_handlers.NewMdUserGroupHandler(mdUserGroupService)
	public.GET("/md/usergroup", mdUserGroupHandler.ShowMdUserGroup)

	//MD Test
	mdTestService := client_services.NewServicesMdTest(appStore)
	mdTestHandler := client_handlers.NewMdTestHandler(mdTestService)
	public.GET("/md/test", mdTestHandler.ShowMdTest)

	//MD Profile
	mdProfileService := client_services.NewServicesMdProfile(appStore)
	mdProfileHandler := client_handlers.NewMdProfileHandler(mdProfileService)
	public.GET("/md/profile", mdProfileHandler.ShowMdProfile)

	//MCU Setup
	mcuSetupService := client_services.NewServicesMCUSetup(appStore)
	mcuSetupHandler := client_handlers.NewMCUSetupHandler(mcuSetupService)
	public.GET("/mcu/setup", mcuSetupHandler.ShowMCUSetup)

	//MCU Preregister
	mcuPreregisterService := client_services.NewServicesMCUPreregister(appStore)
	mcuPreregisterHandler := client_handlers.NewMCUPreregisterHandler(mcuPreregisterService)
	public.GET("/mcu/preregister", mcuPreregisterHandler.ShowMCUPreregister)

	//Transaksi Sample Station
	txSampleStationService := client_services.NewServicesTransaksiSampleStation(appStore)
	txSampleStationHandler := client_handlers.NewTransaksiSampleStationHandler(txSampleStationService)
	public.GET("/transaksi/samplestation", txSampleStationHandler.ShowTransaksiSampleStation)
}

func SetupRoutesDev(app *echo.Echo, appStore db.AppStore) {
	dev := app.Group("/dev")

	dvlpserv := dev_services.NewServicesLandingPage(appStore)
	devlphan := dev_handlers.NewLandingPageHandler(dvlpserv)
	dev.GET("/landingpage", devlphan.ShowLandingPage)

	//DEV USERGROUP
	devUGServices := dev_services.NewServicesMasterMenuUserGroup(appStore)
	devUGhandlers := dev_handlers.NewMasterMenuUserGroupHandler(devUGServices)
	// dev.GET("/usergroup", devUGhandlers.HandlerShowMasterMenuUserGroup)
	// dev.GET("/usergroup/pagination", devUGhandlers.HandleChangePage)
	dev.POST("/usergroup/add", devUGhandlers.AddUserGroup)
	dev.POST("/usergroup/edit", devUGhandlers.EditUserGroup)
	dev.POST("/usergroup/delete", devUGhandlers.DeleteUserGroup)

	// try
	dev.GET("/usergroupv1", devUGhandlers.HandlerShowMasterMenuUserGroupV1)
	dev.GET("/breadcrumbv1", devUGhandlers.HandlerShowBreadCrumbV1)
	dev.GET("/searchusergroupv1", devUGhandlers.HandlerShowMasterMenuUserGroupSearchV1)
	dev.GET("/usergroupv1pagination", devUGhandlers.HandlerShowMasterMenuUserGroupPaginationV1)
	dev.POST("/usergrouphandlecloseform", devUGhandlers.HandleCloseForm)
	dev.POST("/usergrouphandlecloseformedit", devUGhandlers.HandleCloseFormEdit)
	dev.POST("/usergrouphandlecloseformdelete", devUGhandlers.HandleCloseFormDelete)
	dev.GET("/usergroupshoweditform", devUGhandlers.HandleEditForm)
	dev.GET("/usergroupshowdeleteform", devUGhandlers.HandleDeleteForm)

	//ugcobanady
	dev.GET("/usergrouptryandy", devUGhandlers.HandlerShowMasterMenuUserGroupTryAndy)

	dev.GET("/hidetoast", devUGhandlers.HandlerHideToast)

	dev.GET("/xtemplmulti", devUGhandlers.HandlerXTemplMulti)

	// clientgroup.GET("/usergroup/edit", mastermenuusergroupHandler.ChangeFormEdit)
	// clientgroup.GET("/usergroup/pagination", mastermenuusergroupHandler.HandleChangePage)

	// group result
	devGRServices := dev_services.NewServicesGroupResult(appStore)
	devGRhandlers := dev_handlers.NewGroupResultHandler(devGRServices)
	dev.GET("/groupresult", devGRhandlers.HandlerShowGroupResultV1)
	dev.GET("/searchgroupresultv1", devGRhandlers.HandlerShowGroupResultSearchV1)
	dev.GET("/groupresultv1pagination", devGRhandlers.HandlerShowGroupResultPaginationV1)

	//New User Group
	devMdUserGroupServices := dev_services.NewMdUserGroupServices(appStore)
	devMdUserGroupHandlers := dev_handlers.NewMdUserGroupHandler(devMdUserGroupServices)
	dev.GET("/md/usergroupv2", devMdUserGroupHandlers.HandleShowMdUserGroupScreen)
	dev.GET("/md/usergroupv2/filter", devMdUserGroupHandlers.HandleFilterMdUserGroup)
	dev.GET("/md/usergroupv2/changepage", devMdUserGroupHandlers.HandleChangePageMdUserGroup)
	dev.POST("/md/usergroupv2/closeaddform", devMdUserGroupHandlers.HandleCloseFormAdd)
	dev.POST("/md/usergroupv2/add", devMdUserGroupHandlers.HandleAddUserGroup)
	dev.GET("/md/usergroupv2/openedit", devMdUserGroupHandlers.HandleOpenEditForm)
	dev.POST("/md/usergroupv2/closeeditform", devMdUserGroupHandlers.HandleCloseFormEdit)
	dev.POST("/md/usergroupv2/edit", devMdUserGroupHandlers.HandleEditUserGroup)
	dev.GET("/md/usergroupv2/opendelete", devMdUserGroupHandlers.HandleOpenDeleteForm)
	dev.POST("/md/usergroupv2/closedeleteform", devMdUserGroupHandlers.HandleCloseFormDelete)
	dev.POST("/md/usergroupv2/delete", devMdUserGroupHandlers.HandleDeleteUserGroup)

	// group result
	devGRServices := dev_services.NewServicesGroupResult(appStore)
	devGRhandlers := dev_handlers.NewGroupResultHandler(devGRServices)
	dev.GET("/groupresult", devGRhandlers.HandlerShowGroupResultV1)
	dev.GET("/searchgroupresultv1", devGRhandlers.HandlerShowGroupResultSearchV1)
	dev.GET("/groupresultv1pagination", devGRhandlers.HandlerShowGroupResultPaginationV1)
	dev.POST("/groupresulthandlecloseform", devGRhandlers.HandleCloseForm)
	dev.POST("/groupresulthandlecloseformedit", devGRhandlers.HandleCloseFormEdit)
	dev.GET("/groupresultshoweditform", devGRhandlers.HandleEditForm)
	dev.GET("/groupresultshowdeleteform", devGRhandlers.HandleDeleteForm)
	// dev.GET("/groupresultshowdeleteform", devGRhandlers.HandleDeleteForm)
	// form add
	dev.POST("/groupresult/add", devGRhandlers.AddGroupResult)
	dev.POST("/groupresult/edit", devGRhandlers.EditGroupResult)
	dev.POST("/groupresult/delete", devGRhandlers.DeleteGroupResult)
	// md sample station
	devMDSampleStationServices := dev_services.NewMDSampleStationServices(appStore)
	devMDSampleStationHandlers := dev_handlers.NewMDSampleStationHandler(devMDSampleStationServices)
	dev.GET("/md/samplestation", devMDSampleStationHandlers.HandleShowMDSampleStationScreen)
	dev.GET("/md/samplestation/changepage", devMDSampleStationHandlers.HandleChangePageSampleStation)
	// masterdata nat unit
	devMdNatUnitServices := dev_services.NewMdNatUnitServices(appStore)
	devMdNatUnitHandlers := dev_handlers.NeWMdNatUnitHandler(devMdNatUnitServices)
	dev.GET("/md/natunit", devMdNatUnitHandlers.HandleShowMdNatUnitScreen)
	dev.GET("/md/natunit/filter", devMdNatUnitHandlers.HandleFilterMdNatUnit)
	dev.GET("/md/natunit/changepage", devMdNatUnitHandlers.HandlerChangePageMdNatUnit)
	dev.POST("/md/natunit/closeaddform", devMdNatUnitHandlers.HandlerCloseFormAdd)
	dev.POST("/md/natunit/add", devMdNatUnitHandlers.HandlerAddNatUnit)
	dev.GET("/md/natunit/openedit", devMdNatUnitHandlers.HandlerOpenEditForm)
	dev.POST("/md/natunit/closeeditform", devMdNatUnitHandlers.HandlerCloseFormEdit)
	dev.POST("/md/natunit/edit", devMdNatUnitHandlers.HandlerEditNatUnit)
	dev.GET("/md/natunit/opendelete", devMdNatUnitHandlers.HandlerOpenDeleteForm)
	dev.POST("/md/natunit/closedeleteform", devMdNatUnitHandlers.HandlerCloseFormDelete)
	dev.POST("/md/natunit/delete", devMdNatUnitHandlers.HandlerDeleteNatUnit)

	// group result v2
	devMdGRServices := dev_services.NewServicesMdGroupResult(appStore)
	devMdGRhandlers := dev_handlers.NewMdGroupResultHandler(devMdGRServices)
	dev.GET("/md/groupresultv2", devMdGRhandlers.HandleShowMdGroupResultScreen)
	dev.GET("/md/groupresultv2/filter", devMdGRhandlers.HandleFilterMdGroupResult)
	dev.GET("/md/groupresultv2/changepage", devMdGRhandlers.HandleChangePageMdGroupResult)
	dev.POST("/md/groupresultv2/closeaddform", devMdGRhandlers.HandleCloseFormAdd)
	dev.POST("/md/groupresultv2/add", devMdGRhandlers.HandleAddGroupResult)
	dev.GET("/md/groupresultv2/openedit", devMdGRhandlers.HandleOpenEditForm)
	dev.POST("/md/groupresultv2/closeeditform", devMdGRhandlers.HandleCloseFormEdit)
	dev.POST("/md/groupresultv2/edit", devMdGRhandlers.HandleEditGroupResult)
	dev.GET("/md/groupresultv2/opendelete", devMdGRhandlers.HandleOpenDeleteForm)
	dev.POST("/md/groupresultv2/closedeleteform", devMdGRhandlers.HandleCloseFormDelete)
	dev.POST("/md/groupresultv2/delete", devMdGRhandlers.HandleDeleteUserGroup)
	//MD BAHAN
	devMdBahanServices := dev_services.NewMdBahanServices(appStore)
	devMdBahanHandlers := dev_handlers.NewMdBahanHandler(devMdBahanServices)
	dev.GET("/md/bahan", devMdBahanHandlers.HandleShowMdBahanScreen)
	dev.GET("/md/bahan/filter", devMdBahanHandlers.HandleFilterMdBahan)
	dev.GET("/md/bahan/pagination", devMdBahanHandlers.HandlePaginationMdBahan)
	dev.POST("/md/bahan/add", devMdBahanHandlers.HandleAddMdBahan)
	dev.POST("/md/bahan/closeaddform", devMdBahanHandlers.HandleCloseFormAddMdBahan)
	dev.GET("/md/bahan/openedit", devMdBahanHandlers.HandleOpenEditMdBahan)
	dev.POST("/md/bahan/closeeditform", devMdBahanHandlers.HandleCloseFormEditMdBahan)
	dev.POST("/md/bahan/edit", devMdBahanHandlers.HandleEditMdBahan)
	dev.GET("/md/bahan/opendelete", devMdBahanHandlers.HandleOpenDeleteMdBahan)
	dev.POST("/md/bahan/closedeleteform", devMdBahanHandlers.HandleCloseDeleteMdBahan)
	dev.POST("/md/bahan/delete", devMdBahanHandlers.HandleDeleteMdBahan)
}
