package routes

import (
	"nearle/controllers"

	"nearle/middlewares"
	"net/http"

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

func DevSetup(app *fiber.App) {

	app.Get("/", func(c *fiber.Ctx) error {
		return c.JSON(fiber.Map{
			"code":    http.StatusOK,
			"message": "Welcome to Nearle",
			"status":  true,
		})

	})

	dev := app.Group("/dev/api")

	customer := dev.Group("/v1/customers")
	customer.Post("/login", controllers.CustomerLogin)
	customer.Post("/create", controllers.CreateCustomer)

	util := dev.Group("/v1/utils")
	util.Get("/getapplocations", controllers.GetApplocations)
	util.Get("/getappconfig", controllers.GetAppConfig)

}

func LiveSetup(app *fiber.App) {

	live := app.Group("/live/api")

	users := live.Group("/v1/users")
	users.Post("/login", controllers.Login)
	users.Post("/tenant/login", controllers.TenantLogin)
	users.Post("/partner/login", controllers.Partnerlogin)
	users.Post("/rider/login", controllers.Riderlogin)
	users.Post("/admin/login", controllers.AdminLogin)
	users.Post("/console/login", controllers.AdminConsoleLogin)
	users.Post("/tenant/weblogin", controllers.TenantWebLogin)
	users.Post("/applogin", controllers.AppLogin)
	users.Post("/create", controllers.CreateUser)
	users.Post("/createconsoleuser", controllers.CreateConsoleUser)
	users.Put("/update", controllers.UpdateStaff)
	users.Delete("/delete", controllers.DeleteUser)
	users.Get("/getusers", controllers.GetUserInfo)
	users.Get("/getallusers", controllers.GetAllUsers)

	users = live.Group("/v2/users")
	users.Post("/applogin", middlewares.RoleCheckMiddleware(0), controllers.TenantWebLoginv2)
	users.Post("/tenant/weblogin", middlewares.RoleCheckMiddleware(1), controllers.TenantWebLoginv2)
	users.Post("/create", controllers.CreateUserV2)
	users.Put("/update", controllers.UpdateUserV2)
	users.Post("/rider/login", controllers.Riderloginv2)
	users.Get("/getallusers", controllers.GetAllUsersv2)

	customer := live.Group("/v1/customers")
	customer.Get("/", controllers.BasicRoute)
	customer.Post("/login", controllers.CustomerLogin)
	customer.Post("/create", controllers.CreateCustomer)
	customer.Put("/update", controllers.UpdateCustomer)
	customer.Get("/getbyid", controllers.GetCustomer)
	customer.Get("/getbyno", controllers.GetCustomer)
	customer.Get("/getbytid", controllers.GetCustomersbytenent)
	customer.Get("/gettenantcustomers", controllers.GetTenantCustomers)
	customer.Get("/getcustomerlocation", controllers.GetCustomerLocations)
	customer.Post("/createlocations", controllers.CreateCustomerLocation)
	customer.Get("/getcustomersbyapplocation", controllers.GetCustomersbyapplocation)
	customer.Get("/getallcustomers", controllers.GetallCustomers)
	customer.Get("getcustomersummary", controllers.GetCustomerSummary)
	customer.Get("/search", controllers.SearchCustomer)
	customer.Delete("/delete", controllers.DeleteCustomer)
	customer.Post("/createcustomerrequest", controllers.CreateCustomerRequest)
	customer.Get("/getcustomerrequests", controllers.GetCustomerRequests)

	util := live.Group("/v1/utils")
	util.Get("/getapplocations", controllers.GetApplocations)
	util.Get("/getappconfig", controllers.GetAppConfig)
	util.Get("/getallappconfig", controllers.GetAllAppConfig)
	util.Get("/getapptypes", controllers.GetApptypes)
	util.Get("/getappmodule", controllers.GetAppModule)
	util.Get("/getsubcategories", controllers.GetSubcategories)
	util.Get("/getcategories", controllers.GetCategories)
	util.Post("/notifyuser", controllers.NotifyUser)
	util.Post("/sendnotifications", controllers.NotifyUsers)
	util.Get("/getapppricing", controllers.GetAppPricing)
	util.Get("/getallpricing", controllers.GetAllAppPricing)
	util.Get("/getallpricing", controllers.GetAllAppPricing)
	util.Post("/createapppricing", controllers.CreateAppPricing)
	util.Get("/getapplocationconfig", controllers.GetApplocationConfig)
	util.Post("/notifyadmin", controllers.NotifyAdmin)
	util.Post("/notifytenant", controllers.NotifyTenant)
	util.Get("/gettenantnotifications", controllers.GetTenantNotifications)
	util.Post("/webhooks", controllers.WebhookHandler)
	util.Post("/register-webhook", controllers.RegisterWebhookHandler)
	util.Post("/createwebhook", controllers.Createwebhook)
	util.Post("/webhooksreceiver", controllers.WebhookReceiver)
	util.Get("/getshopfrontorders", controllers.GetShopfrontOrders)
	util.Post("/webhooks/inventory", controllers.RegisterInventoryWebhook)
	util.Get("/getuserbonussummary", controllers.GetUserBonusSummary)
	util.Post("/createapplocationconfig", controllers.CreateAppLocationConfig)
	util.Put("/updateapplocationconfig", controllers.UpdateAppLocationConfig)
	util.Get("/getuserroles", controllers.GetUserRoles)
	util.Post("/createuserredis", controllers.CreateUserRedis)
	util.Get("/getuserredis", controllers.GetUserRedis)
	util.Post("/createriderperiodiclog", controllers.CreateRiderPeriodicLog)
	util.Get("/getriderperiodiclogs", controllers.GetRiderPeriodicLogs)
	util.Post("/createriderstatus", controllers.CreateRiderStatus)
	util.Get("/getriderstatus", controllers.GetRiderStatus)

	util = live.Group("/v2/utils")
	util.Get("/getapplocations", controllers.GetApplocationsv2)

	partner := live.Group("/v1/partners")
	partner.Get("/getriders", controllers.GetActiveRiders)
	partner.Get("/getactiveriderssummary", controllers.GetActiveRidersSummary)
	partner.Get("/getridershifts", controllers.GetRiderShifts)
	partner.Get("/getriderpricing", controllers.GetRiderPricing)
	partner.Get("/getriderpool", controllers.GetRiderPool)
	partner.Get("/getriderinfo", controllers.GetRiderInfo)

	partner.Get("/getriderdetail", controllers.GetRiderDetails)
	partner.Get("/getallriders", controllers.GetAllRiders)
	partner.Get("/getpartners", controllers.GetPartners)
	partner.Get("/getlocations", controllers.GetLocationConfig)
	partner.Get("/getpartnerusers", controllers.GetPartnerusers)
	partner.Get("/getallorderbystatus", controllers.GetOrders)
	partner.Get("/getadmintoken", controllers.GetAdminToken)

	partner.Post("/createshift", controllers.CreateRiderShift)
	partner.Post("/createrider", controllers.CreateRider)
	partner.Put("/updateridersettings", controllers.UpdateRiderSettings)
	partner.Put("/updaterider", controllers.UpdateRiderInfo)

	partner.Post("/createriderlog", controllers.CreateRiderLog)
	partner.Put("/updateriderlog", controllers.UpdateRiderLog)
	partner.Get("/getriderlog", controllers.GetRiderLog)
	partner.Get("/getriderlogs", controllers.GetRiderLogs)
	partner.Get("/getridercount", controllers.GetRiderOrderCount)
	partner.Post("/createbreaklog", controllers.CreateBreakLog)
	partner.Put("/updatebreaklog", controllers.UpdateBreakLog)
	partner.Get("/getriderweeklykms", controllers.GetRiderWeeklyKms)
	partner.Post("/createridersupport", controllers.CreateRiderSupport)
	partner.Get("/getridersupport", controllers.GetRiderSupport)
	partner.Get("/getallridersummary", controllers.GetAllRidersSummary)
	partner.Get("/getuserlocationsummary", controllers.GetUserLocationSummary)
	partner.Get("/getriderpricing", controllers.GetRiderPricing)

	partner = live.Group("/v2/partners")
	partner.Get("/getriderinfo", controllers.GetRiderInfov2)
	partner.Get("/getriders", controllers.GetActiveRidersv2)
	partner.Post("/createbreaklog", controllers.CreateBreakLogv1)
	partner.Put("/updatebreaklog", controllers.UpdateBreakLogv1)
	partner.Get("/getdeliverystats", controllers.GetDeliveryStats)
	partner.Post("/createriderlog", controllers.CreateRiderLogv1)
	partner.Put("/updateriderlog", controllers.UpdateRiderLogv1)
	partner.Get("/getriderlogs", controllers.GetRiderLogsv1)
	partner.Delete("/deleteriderlog", controllers.DeleteRiderLogs)

	substitutions := live.Group("/v1/substitutions")
	substitutions.Get("/", controllers.GetSubstitutions)
	substitutions.Get("/:id", controllers.GetSubstitutionByID)
	substitutions.Post("/", controllers.CreateSubstitutions)
	substitutions.Put("/:id", controllers.UpdateSubstitution)
	substitutions.Patch("/:id/status", controllers.UpdateSubstitutionStatus)
	substitutions.Delete("/:id", controllers.DeleteSubstitution)

	invoice := live.Group("/v1/invoice")
	invoice.Get("/getseqno", controllers.InvoiceSeqno)
	invoice.Get("/getinvoiceorders", controllers.GetInvoiceOrders)
	invoice.Post("/create", controllers.CreateInvoice)
	invoice.Get("/getallinvoice", controllers.GetallInvoice)
	invoice.Get("/getinvoiceinsight", controllers.GetInvoiceInsight)
	invoice.Put("/update", controllers.UpdateInvoice)
	invoice.Put("/updatestatus", controllers.UpdateInvoiceStatus)

	tenant := live.Group("/v1/tenants")
	tenant.Post("/create", controllers.Createtenant)
	tenant.Post("/createlocation", controllers.CreateLocation)
	tenant.Post("/createtenantuser", controllers.CreatetenantUser)
	tenant.Put("/update", controllers.UpdateTenant)
	tenant.Put("/updatelocation", controllers.UpdateLocation)
	tenant.Put("/createpartneruser", controllers.UpdateTenant)
	tenant.Get("/gettenantinfo", controllers.GetTenantInfo)
	tenant.Get("/search", controllers.SearchTenant)
	tenant.Post("/createtenantcustomer", controllers.Createtenantcustomer)

	tenant.Post("/createstaff", controllers.CreateStaff)
	tenant.Put("/updatestaff", controllers.UpdateStaff)
	tenant.Get("/getstaffs", controllers.GetStaffs)
	tenant.Get("/gettenants", controllers.GetTenants)
	tenant.Get("/getalltenants", controllers.GetAllTenants)
	tenant.Get("/gettenantsummary", controllers.GetTenantSummary)
	tenant.Get("/getcloudstore", controllers.GetCloudStore)
	tenant.Get("/gettenantlocations", controllers.GetTenantLocations)
	tenant.Get("/gettenantslots", controllers.GetTenantSlot)
	tenant.Get("/gettenantlocation", controllers.GetTenantLocation)
	tenant.Post("/createpricing", controllers.CreatePricing)
	tenant.Get("/gettenantpricing", controllers.GetTenantPricing)
	tenant.Post("/createtenantrequest", controllers.CreateTenantRequest)
	tenant.Get("/gettenantrequests", controllers.GetTenantRequests)
	tenant.Get("/getpricinglist", controllers.GetPricingList)
	tenant.Post("/createtenantpromotions", controllers.CreateTenantPromotion)
	tenant.Get("/gettenantpromotions", controllers.GetTenantPromotions)

	tenant = live.Group("/v2/tenants")
	tenant.Post("/createtenantlocation", controllers.CreateTenantLocation)
	tenant.Put("/updatetenantlocation", controllers.UpdateTenantLocation)
	tenant.Get("/getlocationsummary", controllers.GetLocationSummary)
	tenant.Get("/gettenantstaffsummary", controllers.GetTenantStaffSummary)
	tenant.Get("/gettenantridersummary", controllers.GetTenantRiderSummary)
	tenant.Get("/getcustomertenants", controllers.GetCustomerTenants)

	products := live.Group("v1/products")
	products.Get("/getallproducts", controllers.GetAllProducts)
	products.Get("/getproductinfo", controllers.GetProductInfo)
	products.Get("/getproductcategories", controllers.GetProductCategory)
	products.Get("/getproductsubcategories", controllers.GetProductSubCategory)
	products.Post("/create", controllers.CreateProduct)
	products.Put("/update", controllers.UpdateProduct)
	products.Delete("/delete", controllers.DeleteProduct)
	products.Get("/getproductsbysubcategory", controllers.GetProductsBySubcategory)
	products.Get("/getproductscount", controllers.GetProductCount)
	products.Get("/getproductbyvariant", controllers.GetProductByVariant)
	products.Post("/createproductvariant", controllers.CreateProductVariant)
	products.Get("/getproductvariants", controllers.GetProductVariants)
	products.Post("/createproductdiscount", controllers.CreateProductDiscount)
	products.Get("/getproductdiscounts", controllers.GetProductDiscounts)

	products = live.Group("v2/products")
	products.Get("/getcatalougeproducts", controllers.GetCatalougeProducts)
	products.Get("/getlocationproducts", controllers.GetLocationProducts)
	products.Get("/getlocationproductsummary", controllers.GetLocationProductSummary)
	products.Get("/getstockstatement", controllers.GetStockstatement)
	products.Post("/createproductlocation", controllers.CreateProductLocation)
	products.Put("/updateproductlocation", controllers.UpdateProductLocation)
	products.Post("/createproductstock", controllers.CreateProductStock)
	products.Put("/updateproductstock", controllers.UpdateProductStock)
	products.Get("/getproductstocks", controllers.GetProductStocks)
	products.Get("/getproductcategorywisesummary", controllers.GetSubCategoryWiseSummary)
	products.Get("/getstockstatementsummary", controllers.GetStockStatementSummary)

	orders := live.Group("/v1/orders")
	orders.Get("partner/getorders", controllers.GetOrders)
	orders.Get("tenant/getorders", controllers.GetOrders)
	orders.Get("customer/getorders", controllers.GetOrders)
	orders.Get("/getorders", controllers.GetOrders)
	orders.Get("tenant/getlocationsummary", controllers.GetTenantLocationSummary)
	orders.Get("/getordersummary", controllers.GetOrderSummary)
	orders.Get("/getlocationsummary", controllers.GetlocationOrderSummary)
	orders.Get("/getorderinsight", controllers.GetOrderInsight)
	orders.Get("/getorderdetails", controllers.GetOrderDetails)

	orders.Post("/createorder", controllers.CreateOrder)
	orders.Post("/createorders", controllers.CreateOrders)
	orders.Put("/updateorder", controllers.UpdateOrder)
	orders.Put("/updatemultipleorders", controllers.UpdateMultipleOrders)

	orders.Get("/getorderbylocations", controllers.GetCustomerOrderByLocation)

	ordersv2 := live.Group("/v2/orders")
	ordersv2.Post("/createorder", controllers.CreateCustomerOrderv2)
	ordersv2.Get("/getorders", controllers.GetOrdersv2)
	ordersv2.Get("/getorderinsight", controllers.GetOrderInsightDaily)
	ordersv2.Get("/getordersummary", controllers.GetOrderSummaryDaily)
	ordersv2.Get("/getlocationsummary", controllers.GetLocationOrderSummaryDaily)

	ordersv3 := live.Group("/v3/orders")
	ordersv3.Post("/createorder", controllers.CreateOrderv3)
	ordersv3.Get("getcustomerorders", controllers.GetCustomerOrders)

	deliveries := live.Group("/v1/deliveries")
	deliveries.Post("/createdelivery", controllers.CreateDelivery)
	deliveries.Post("/createdeliveries", controllers.CreateDeliveries)

	deliveries.Post("/createdeliverylog", controllers.PublishLog)
	deliveries.Get("/getdeliverylogs", controllers.GetDeliverylogs)

	deliveries.Get("deliverysummary", controllers.GetDeliverySummary)
	deliveries.Get("/getlocationsummary", controllers.GetlocationdeliverySummary)
	deliveries.Get("/getdeliveries", controllers.GetDeliveriesV2)

	deliveries.Get("/getdeliveryqueues", controllers.GetDeliveryQueues)
	deliveries.Get("/getdeliveryqueuespicked", controllers.GetDeliveryQueuesPicked)
	deliveries.Put("/Updatedelivery", controllers.UpdateDelivery)
	deliveries.Get("/getdeliveryinsight", controllers.GetDeliveryInsight)
	deliveries.Get("/getreportsummary", controllers.GetReportSummary)
	deliveries.Get("/getreportlocationsummary", controllers.GetReportLocationSummary)
	deliveries.Get("/getriderlocationreportsummary", controllers.GetRiderLocationReportSummary)
	deliveries.Get("/getridersummary", controllers.GetRiderSummary)
	deliveries.Get("/getriderlocationsummary", controllers.GetRiderLocationSummary)
	deliveries.Get("/getriderbydelivery", controllers.GetRiderByDelivery)
	deliveries.Get("/getlastdeliverybycontact", controllers.GetLastDeliveryByContact)
	deliveries.Get("/getuserreportsummary", controllers.GetUserReportSummary)
	deliveries.Get("/getuserdeliverylogs", controllers.GetUserDeliveryLogs)

	deliveriesv2 := live.Group("/v2/deliveries")
	deliveriesv2.Post("/createdeliveries", controllers.CreateDeliveriesV2)
	deliveriesv2.Get("/getdeliveries", controllers.GetDeliveriesV2)
	deliveriesv2.Get("/getlocationsummary", controllers.GetlocationdeliverySummaryDaily)
	deliveriesv2.Get("/getdeliveryinsight", controllers.GetDeliveryInsightDaily)
	deliveriesv2.Post("/createdeliverylog", controllers.PublishLogv1)
	deliveriesv2.Get("/getdeliverylogs", controllers.GetDeliverylogsv1)
	deliveriesv2.Get("/getdeliveryqueues", controllers.GetDeliveryQueuesV1)

	deliveriesv3 := live.Group("/v3/deliveries")
	deliveriesv3.Get("/getdeliveries", controllers.GetDeliveriesV3)
	deliveriesv3.Get("/getdeliverylogs", controllers.GetDeliveryLogsv1)

	payments := live.Group("/v1/payments")
	payments.Get("requests/getpaymentrequest", controllers.GetPaymentRequests)
	payments.Post("requests/create", controllers.CreatePaymentRequest)

	admin := live.Group("/v1/admin")
	admin.Post("/login", controllers.CustomerLogin)
	admin.Get("/orders/getorders", controllers.GetOrders)

	platform := live.Group("/v1/platform")
	platform.Get("/getmodules", controllers.GetModules)
	platform.Get("/getsmsprovider", controllers.GetSmsProvider)

}

func LiveWebSetup(app *fiber.App) {

	liveweb := app.Group("/live/api/web")

	users := liveweb.Group("/v1/users")
	users.Post("/create", controllers.CreateUserV2)
	users.Get("/getallusers", controllers.GetAllUsers)
	users.Put("/update", controllers.UpdateUserV2)

	tenantweb := liveweb.Group("/v1/tenants")
	tenantweb.Put("/update", controllers.UpdateTenant)
	tenantweb.Get("/gettenantpricing", controllers.GetTenantPricing)
	tenantweb.Get("/gettenantinfo", controllers.GetTenantInfo)
	tenantweb.Get("/gettenantlocations", controllers.GetTenantLocations)
	tenantweb.Put("/updatetenantlocation", controllers.UpdateTenantLocation)

	ordersweb := liveweb.Group("/v1/orders")
	ordersweb.Get("tenant/getorders", controllers.GetOrders)
	ordersweb.Get("/getordersummary", controllers.GetOrderSummary)
	ordersweb.Get("customer/getorders", controllers.GetOrders)
	ordersweb.Get("tenant/getorders", controllers.GetOrders)

	utilweb := liveweb.Group("/v1/utils")
	utilweb.Get("/getsubcategories", controllers.GetSubcategories)
	utilweb.Get("/getapplocations", controllers.GetApplocations)
	utilweb.Get("/getapplocationconfig", controllers.GetApplocationConfig)
	utilweb.Get("/getapptypes", controllers.GetApptypes)

	customerweb := liveweb.Group("/v1/customers")
	customerweb.Get("/gettenantcustomers", controllers.GetTenantCustomers)

	partnerweb := liveweb.Group("/v1/partners")
	partnerweb.Get("/getpartners", controllers.GetPartners)
	partnerweb.Get("/getlocations", controllers.GetLocationConfig)
	partnerweb.Get("/getridershifts", controllers.GetRiderShifts)
	partnerweb.Get("/getriderpricing", controllers.GetRiderPricing)

	productsweb := liveweb.Group("v1/products")
	productsweb.Post("/create", controllers.CreateProduct)
	productsweb.Post("/createproductlocation", controllers.CreateProductLocation)
	productsweb.Put("/updateproductstock", controllers.UpdateProductStock)
	productsweb.Get("/getallproducts", controllers.GetAllProducts)
	productsweb.Get("/getproductcategories", controllers.GetProductCategory)
	productsweb.Get("/getproductsubcategories", controllers.GetProductSubCategory)
	productsweb.Get("/getproductscount", controllers.GetProductCount)
	productsweb.Get("/getproductvariants", controllers.GetProductVariants)

	deliveries := liveweb.Group("/v1/deliveries")
	deliveries.Get("/getdeliveries", controllers.GetDeliveriesV2)

	invoice := liveweb.Group("/v1/invoice")
	invoice.Get("/getinvoiceinsight", controllers.GetInvoiceInsight)
	invoice.Get("/getallinvoice", controllers.GetallInvoice)

}
