blocked dates page and warning for special-cake orders

Add blocked_date table (migration 5), model, and store CRUD methods.
Add management page at /blocked with add/delete functionality.
Add nav link 'Terminy zablokowane' with event_busy icon.
Pass blocked dates to order form as JSON data attribute.
On form submit, if the order has special cakes and the date is
blocked, show a confirm() dialog warning the user.
This commit is contained in:
bronkuu 2026-06-15 18:54:48 +02:00
parent 5a5372b831
commit 5f156ab6a0
13 changed files with 175 additions and 16 deletions

View file

@ -142,6 +142,29 @@ func safeStr(s []string, i int) string {
return ""
}
func (h *Server) postBlocked(r *http.Request) (templ.Component, int, error) {
if err := r.ParseForm(); err != nil {
return nil, http.StatusBadRequest, err
}
if err := h.s.AddBlockedDate(r.FormValue("date")); err != nil {
return nil, http.StatusInternalServerError, err
}
dates, _ := h.s.GetBlockedDates()
return templates.BlockedMain(dates), http.StatusOK, nil
}
func (h *Server) deleteBlocked(r *http.Request) (templ.Component, int, error) {
id, err := strconv.Atoi(r.PathValue("id"))
if err != nil {
return nil, http.StatusBadRequest, err
}
if err := h.s.RemoveBlockedDate(id); err != nil {
return nil, http.StatusInternalServerError, err
}
dates, _ := h.s.GetBlockedDates()
return templates.BlockedMain(dates), http.StatusOK, nil
}
func (h *Server) updateStatus(r *http.Request) (templ.Component, int, error) {
id, err := strconv.Atoi(r.PathValue("id"))
if err != nil {