2024-03-02 02:38:26 +01:00
|
|
|
package handlers
|
|
|
|
|
|
|
|
import (
|
|
|
|
"ttime/internal/database"
|
|
|
|
|
|
|
|
"github.com/gofiber/fiber/v2"
|
|
|
|
)
|
|
|
|
|
|
|
|
// The actual interface that we will use
|
|
|
|
type GlobalState interface {
|
2024-03-14 21:25:14 +01:00
|
|
|
Register(c *fiber.Ctx) error // To register a new user
|
|
|
|
UserDelete(c *fiber.Ctx) error // To delete a user
|
|
|
|
Login(c *fiber.Ctx) error // To get the token
|
|
|
|
LoginRenew(c *fiber.Ctx) error // To renew the token
|
|
|
|
CreateProject(c *fiber.Ctx) error // To create a new project
|
|
|
|
GetUserProjects(c *fiber.Ctx) error // To get all projects
|
2024-03-16 22:47:19 +01:00
|
|
|
SubmitWeeklyReport(c *fiber.Ctx) error
|
2024-03-17 18:05:54 +01:00
|
|
|
GetWeeklyReport(c *fiber.Ctx) error
|
2024-03-17 23:31:52 +01:00
|
|
|
SignReport(c *fiber.Ctx) error
|
2024-03-18 16:42:35 +01:00
|
|
|
GetProject(c *fiber.Ctx) error
|
2024-03-18 14:47:15 +01:00
|
|
|
AddUserToProjectHandler(c *fiber.Ctx) error
|
|
|
|
PromoteToAdmin(c *fiber.Ctx) error
|
2024-03-19 19:04:45 +01:00
|
|
|
GetWeeklyReportsUserHandler(c *fiber.Ctx) error
|
2024-03-19 19:30:01 +01:00
|
|
|
IsProjectManagerHandler(c *fiber.Ctx) error
|
2024-03-20 10:41:16 +01:00
|
|
|
// UpdateProject(c *fiber.Ctx) error // To update a project // WIP
|
2024-03-20 11:23:24 +01:00
|
|
|
DeleteProject(c *fiber.Ctx) error // To delete a project // WIP
|
2024-03-20 10:41:16 +01:00
|
|
|
// CreateTask(c *fiber.Ctx) error // To create a new task // WIP
|
|
|
|
// GetTasks(c *fiber.Ctx) error // To get all tasks // WIP
|
|
|
|
// GetTask(c *fiber.Ctx) error // To get a specific task // WIP
|
|
|
|
// UpdateTask(c *fiber.Ctx) error // To update a task // WIP
|
|
|
|
// DeleteTask(c *fiber.Ctx) error // To delete a task // WIP
|
|
|
|
// CreateCollection(c *fiber.Ctx) error // To create a new collection // WIP
|
|
|
|
// GetCollections(c *fiber.Ctx) error // To get all collections // WIP
|
|
|
|
// GetCollection(c *fiber.Ctx) error // To get a specific collection // WIP
|
|
|
|
// UpdateCollection(c *fiber.Ctx) error // To update a collection // WIP
|
|
|
|
// DeleteCollection(c *fiber.Ctx) error // To delete a collection // WIP
|
|
|
|
// SignCollection(c *fiber.Ctx) error // To sign a collection // WIP
|
2024-03-18 20:56:00 +01:00
|
|
|
ListAllUsers(c *fiber.Ctx) error // To get a list of all users in the application database
|
|
|
|
ListAllUsersProject(c *fiber.Ctx) error // To get a list of all users for a specific project
|
|
|
|
ProjectRoleChange(c *fiber.Ctx) error // To change a users role in a project
|
2024-03-20 12:50:04 +01:00
|
|
|
ChangeUserName(c *fiber.Ctx) error // WIP
|
2024-03-02 02:38:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// "Constructor"
|
|
|
|
func NewGlobalState(db database.Database) GlobalState {
|
2024-03-18 20:56:00 +01:00
|
|
|
return &GState{Db: db}
|
2024-03-02 02:38:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// The global state, which implements all the handlers
|
|
|
|
type GState struct {
|
2024-03-18 20:56:00 +01:00
|
|
|
Db database.Database
|
2024-03-06 09:41:36 +01:00
|
|
|
}
|