date filtering, and squashed migrations
This commit is contained in:
parent
7b21ee837d
commit
67807992bc
12 changed files with 128 additions and 180 deletions
|
|
@ -12,14 +12,26 @@ import (
|
|||
|
||||
func (h *Server) orders(r *http.Request) (any, int, error) {
|
||||
//r.URL.Query().Get()
|
||||
data, err := h.s.GetTopOrders(time.Now(), time.Now().Add(time.Hour*24))
|
||||
orders, err := h.s.GetTopOrders(time.Now(), time.Now().Add(time.Hour*24))
|
||||
data := struct {
|
||||
Today string
|
||||
Orders []models.Order
|
||||
}{Today: time.Now().Format("2006-01-02"), Orders: orders}
|
||||
return data, http.StatusOK, err
|
||||
}
|
||||
|
||||
func (h *Server) ordersSearch(r *http.Request) (any, int, error) {
|
||||
q := r.URL.Query().Get("q")
|
||||
fmt.Println(q)
|
||||
data, err := h.s.GetFilteredOrder(q, time.Time{}, time.Time{})
|
||||
from, err := time.Parse("2006-01-02", r.URL.Query().Get("from"))
|
||||
if err != nil {
|
||||
from = time.Time{}
|
||||
}
|
||||
to, err := time.Parse("2006-01-02", r.URL.Query().Get("to"))
|
||||
if err != nil {
|
||||
to = time.Time{}
|
||||
}
|
||||
fmt.Println(from, to)
|
||||
data, err := h.s.GetFilteredOrder(q, from, to)
|
||||
return data, http.StatusOK, err
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,25 +4,22 @@
|
|||
{{end}}
|
||||
{{define "main"}}
|
||||
<main>
|
||||
<div class="search-container">
|
||||
<input
|
||||
type="search"
|
||||
name="q"
|
||||
hx-get="/orders/search"
|
||||
hx-trigger="keyup changed delay:500ms"
|
||||
hx-target="#results-table"
|
||||
hx-push-url="true"
|
||||
placeholder="Search orders..."
|
||||
>
|
||||
<form class="search-container" hx-get="/orders/search" hx-target="#results-table", hx-trigger="keyup delay:500ms, change">
|
||||
<input type="search" name="q" placeholder="Search orders...">
|
||||
|
||||
<label for="from">form</label>
|
||||
<input type="date" value="{{.Today}}" id="from" name="from">
|
||||
<label for="from">to</label>
|
||||
<input type="date" value="{{.Today}}" id="to" name="to">
|
||||
|
||||
<div class="htmx-indicator">
|
||||
Searching...
|
||||
</div>
|
||||
|
||||
<div id="results-table">
|
||||
{{template "orders-table" .}}
|
||||
{{template "orders-table" .Orders}}
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</main>
|
||||
{{end}}
|
||||
|
||||
|
|
@ -35,7 +32,6 @@
|
|||
<th>Phone</th>
|
||||
<th>Location</th>
|
||||
<th>Date</th>
|
||||
<th>Accepted</th>
|
||||
<th>Status</th>
|
||||
<th>Total</th>
|
||||
</tr>
|
||||
|
|
@ -47,7 +43,6 @@
|
|||
<th>{{.Phone}}</th>
|
||||
<th>{{.Location}}</th>
|
||||
<th>{{.Date.Format "2006-01-02"}}</th>
|
||||
<th>{{.Accepted.Format "2006-01-02"}}</th>
|
||||
<th>{{.Status}}</th>
|
||||
<th>{{.Total}}</th>
|
||||
</tr>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue