2024-08-18 04:29:25 +00:00
|
|
|
package pages
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/Cameron-Reed1/todo-web/db"
|
|
|
|
"github.com/Cameron-Reed1/todo-web/pages/templates"
|
|
|
|
)
|
|
|
|
|
|
|
|
func OverdueFragment(w http.ResponseWriter, r *http.Request) {
|
|
|
|
items, err := db.GetOverdueTodos()
|
|
|
|
if err != nil {
|
|
|
|
w.WriteHeader(http.StatusInternalServerError)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2024-08-19 22:02:45 +00:00
|
|
|
templates.TodoList("No overdue items", items).Render(r.Context(), w)
|
2024-08-18 04:29:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TodayFragment(w http.ResponseWriter, r *http.Request) {
|
|
|
|
items, err := db.GetTodayTodos()
|
|
|
|
if err != nil {
|
|
|
|
w.WriteHeader(http.StatusInternalServerError)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2024-08-19 22:02:45 +00:00
|
|
|
templates.TodoList("No items for today", items).Render(r.Context(), w)
|
2024-08-18 04:29:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func UpcomingFragment(w http.ResponseWriter, r *http.Request) {
|
|
|
|
items, err := db.GetUpcomingTodos()
|
|
|
|
if err != nil {
|
|
|
|
w.WriteHeader(http.StatusInternalServerError)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2024-08-19 22:02:45 +00:00
|
|
|
templates.TodoList("No upcoming items", items).Render(r.Context(), w)
|
2024-08-18 04:29:25 +00:00
|
|
|
}
|