list beneficiaries
+ select beneficiary
This commit is contained in:
@@ -34,7 +34,7 @@ func (renderer *Renderer) BeneficiariesList(w http.ResponseWriter, r *http.Reque
|
||||
|
||||
state := NewState(r, renderer.ThemeConfig, beneficiariesMenu)
|
||||
state.ViewState = BeneficiariesListState{
|
||||
Count: len(accounts),
|
||||
Count: len(accounts),
|
||||
CacheId: cacheid,
|
||||
Beneficiaries: accounts,
|
||||
}
|
||||
|
||||
@@ -1,25 +1,69 @@
|
||||
package renderer
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"html/template"
|
||||
"net/http"
|
||||
|
||||
mobilityaccountsstorage "git.coopgo.io/coopgo-platform/mobility-accounts/storage"
|
||||
solidarity_service "git.coopgo.io/sbouaram/solidarity-service/servers/grpc/proto"
|
||||
)
|
||||
|
||||
const solidarityserviceMenu = "solidarity_service"
|
||||
|
||||
func (renderer *Renderer) SolidarityServiceBookingList(w http.ResponseWriter, r *http.Request, drivers *solidarity_service.DriverJourneysResponse) {
|
||||
|
||||
type SolidarityListState struct {
|
||||
Count int `json:"count"`
|
||||
CacheId string `json:"cache_id"`
|
||||
Beneficiaries []mobilityaccountsstorage.Account `json:"beneficiaries"`
|
||||
Drivers *solidarity_service.DriverJourneysResponse `json:"drivers"`
|
||||
|
||||
}
|
||||
|
||||
func (s SolidarityListState) JSON() template.JS {
|
||||
result, _ := json.Marshal(s)
|
||||
return template.JS(result)
|
||||
}
|
||||
|
||||
func (s SolidarityListState) JSONWithLimits(a int, b int) template.JS {
|
||||
if b < len(s.Beneficiaries) {
|
||||
s.Beneficiaries = s.Beneficiaries[a:b]
|
||||
}
|
||||
return s.JSON()
|
||||
}
|
||||
|
||||
func (renderer *Renderer) SolidarityService(w http.ResponseWriter, r *http.Request, drivers *solidarity_service.DriverJourneysResponse, accounts []mobilityaccountsstorage.Account, cacheid string) {
|
||||
files := renderer.ThemeConfig.GetStringSlice("views.solidarity_service.list.files")
|
||||
state := NewState(r, renderer.ThemeConfig, solidarityserviceMenu)
|
||||
state.ViewState = map[string]any{
|
||||
"drivers": drivers,
|
||||
state.ViewState = SolidarityListState {
|
||||
Count: len(accounts),
|
||||
Beneficiaries: accounts,
|
||||
CacheId: cacheid,
|
||||
Drivers: drivers,
|
||||
}
|
||||
|
||||
renderer.Render("solidarity_service", w, r, files, state)
|
||||
}
|
||||
|
||||
func (renderer *Renderer) SolidarityServiceBookingCreate(w http.ResponseWriter, r *http.Request) {
|
||||
func (renderer *Renderer) SolidarityServiceBooking(w http.ResponseWriter, r *http.Request, booking *solidarity_service.BookingSolidarityRequest) {
|
||||
files := renderer.ThemeConfig.GetStringSlice("views.solidarity_service.list.files")
|
||||
state := NewState(r, renderer.ThemeConfig, solidarityserviceMenu)
|
||||
state.ViewState = map[string]any{
|
||||
"booking": booking,
|
||||
}
|
||||
|
||||
renderer.Render("solidarity_service", w, r, files, state)
|
||||
}
|
||||
|
||||
func (renderer *Renderer) SolidarityServiceBookingListDrivers(w http.ResponseWriter, r *http.Request, drivers *solidarity_service.DriverJourneysResponse, accounts []mobilityaccountsstorage.Account, booking *solidarity_service.BookingSolidarityRequest, cacheid string) {
|
||||
files := renderer.ThemeConfig.GetStringSlice("views.solidarity_service.list.files")
|
||||
state := NewState(r, renderer.ThemeConfig, solidarityserviceMenu)
|
||||
state.ViewState = SolidarityListState {
|
||||
Count: len(accounts),
|
||||
Beneficiaries: accounts,
|
||||
CacheId: cacheid,
|
||||
Drivers: drivers,
|
||||
}
|
||||
|
||||
renderer.Render("solidarity_service", w, r, files, state)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user