feat: add global search across beneficiaries and drivers

This commit is contained in:
Arnaud Delcasse
2026-02-26 14:54:22 +01:00
parent bb525f174d
commit b79cc08b06
5 changed files with 103 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
package application
import (
"net/http"
"github.com/rs/zerolog/log"
)
func (h *Handler) GlobalSearchHTTPHandler() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
query := r.URL.Query().Get("q")
if query == "" {
http.Redirect(w, r, "/app/", http.StatusFound)
return
}
result, err := h.applicationHandler.GlobalSearch(r.Context(), query)
if err != nil {
log.Error().Err(err).Msg("error performing global search")
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
return
}
h.renderer.GlobalSearchResults(w, r, query, result.Beneficiaries, result.SolidarityDrivers, result.OrganizedCarpoolDrivers)
}
}