diff --git a/api/task.go b/api/task.go index d339f1c..4a8f8db 100644 --- a/api/task.go +++ b/api/task.go @@ -33,13 +33,17 @@ func Task(g *gin.RouterGroup, db database.Database) { })) g.POST("/", handler("task", func(c *gin.Context) (interface{}, error) { + createdTime := time.Now() task := models.Task{} err := c.BindJSON(&task) if err != nil { return nil, slerrors.BadRequest("Invalid JSON") } - if task.EndTime != nil && task.EndTime.Before(time.Now()) { - return nil, slerrors.BadRequest("Project end time must be later than current time.") + if task.EndTime != nil && task.EndTime.Before(createdTime) { + return nil, slerrors.BadRequest("Task end time must be later than current time.") + } + if task.ItemAmount <= 0 { + return nil, slerrors.BadRequest("Item amount cannot be zero or negative.") } project, err := l.FindProject(c.Request.Context(), task.ProjectID) @@ -83,6 +87,13 @@ func Task(g *gin.RouterGroup, db database.Database) { } task.Update(update) + if task.EndTime != nil && task.EndTime.Before(task.CreatedTime) { + return nil, slerrors.BadRequest("Task end time must be later than it was created.") + } + if task.ItemAmount <= 0 { + return nil, slerrors.BadRequest("Item amount cannot be zero or negative.") + } + err = db.Tasks().Update(c.Request.Context(), task.Task) if err != nil { return nil, err diff --git a/svelte-ui/src/components/LogEntry.svelte b/svelte-ui/src/components/LogEntry.svelte index e5880fe..09bdc27 100644 --- a/svelte-ui/src/components/LogEntry.svelte +++ b/svelte-ui/src/components/LogEntry.svelte @@ -10,10 +10,12 @@ export let log: LogResult = null; let taskIconName: IconName = "question"; + let itemIconName: IconName = "question"; let mdLogEdit: ModalData; let mdLogDelete: ModalData; $: taskIconName = log.task.icon as IconName; + $: itemIconName = log.item.icon as IconName; $: mdLogEdit = {name: "log.edit", log}; $: mdLogDelete = {name: "log.delete", log}; @@ -31,7 +33,7 @@
{log.description}