MMS43 changes
This commit is contained in:
@@ -24,12 +24,12 @@ import (
|
||||
)
|
||||
|
||||
type DashboardResult struct {
|
||||
Accounts []mobilityaccountsstorage.Account
|
||||
Members []mobilityaccountsstorage.Account
|
||||
Events []agendastorage.Event
|
||||
Bookings []fleetstorage.Booking
|
||||
SolidarityDrivers []mobilityaccountsstorage.Account
|
||||
OrganizedCarpoolDrivers []mobilityaccountsstorage.Account
|
||||
Accounts []mobilityaccountsstorage.Account
|
||||
Members []mobilityaccountsstorage.Account
|
||||
Events []agendastorage.Event
|
||||
Bookings []fleetstorage.Booking
|
||||
SolidarityDrivers []mobilityaccountsstorage.Account
|
||||
OrganizedCarpoolDrivers []mobilityaccountsstorage.Account
|
||||
}
|
||||
|
||||
func (h *ApplicationHandler) GetDashboardData(ctx context.Context, driverAddressGeoLayer, driverAddressGeoCode string) (*DashboardResult, error) {
|
||||
@@ -62,14 +62,7 @@ func (h *ApplicationHandler) GetDashboardData(ctx context.Context, driverAddress
|
||||
|
||||
accounts := []mobilityaccountsstorage.Account{}
|
||||
|
||||
// We only display the 5 most recent here
|
||||
count := len(resp.Accounts)
|
||||
min := count - 5
|
||||
if min < 0 {
|
||||
min = 0
|
||||
}
|
||||
|
||||
for _, account := range resp.Accounts[min:] {
|
||||
for _, account := range resp.Accounts {
|
||||
// Check if not archived
|
||||
if archived, ok := account.Data.AsMap()["archived"].(bool); !ok || !archived {
|
||||
a := account.ToStorageType()
|
||||
@@ -225,4 +218,3 @@ func (h *ApplicationHandler) GetDashboardData(ctx context.Context, driverAddress
|
||||
OrganizedCarpoolDrivers: organizedCarpoolDrivers,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -281,7 +281,7 @@ func (h *ApplicationHandler) GetVehicleDisplay(ctx context.Context, vehicleID st
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (h *ApplicationHandler) UpdateBooking(ctx context.Context, bookingID, startdate, enddate, unavailablefrom, unavailableto string) error {
|
||||
func (h *ApplicationHandler) UpdateBooking(ctx context.Context, bookingID string, startdate, enddate *time.Time, unavailablefrom, unavailableto string) error {
|
||||
booking, err := h.services.GetBooking(bookingID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get booking: %w", err)
|
||||
@@ -289,21 +289,19 @@ func (h *ApplicationHandler) UpdateBooking(ctx context.Context, bookingID, start
|
||||
|
||||
newbooking, _ := fleets.BookingFromStorageType(&booking)
|
||||
|
||||
if startdate != "" {
|
||||
newstartdate, _ := time.Parse("2006-01-02", startdate)
|
||||
newbooking.Startdate = timestamppb.New(newstartdate)
|
||||
if startdate != nil {
|
||||
newbooking.Startdate = timestamppb.New(*startdate)
|
||||
|
||||
if newstartdate.Before(newbooking.Unavailablefrom.AsTime()) {
|
||||
newbooking.Unavailablefrom = timestamppb.New(newstartdate)
|
||||
if startdate.Before(newbooking.Unavailablefrom.AsTime()) {
|
||||
newbooking.Unavailablefrom = timestamppb.New(*startdate)
|
||||
}
|
||||
}
|
||||
|
||||
if enddate != "" {
|
||||
newenddate, _ := time.Parse("2006-01-02", enddate)
|
||||
newbooking.Enddate = timestamppb.New(newenddate)
|
||||
if enddate != nil {
|
||||
newbooking.Enddate = timestamppb.New(*enddate)
|
||||
|
||||
if newenddate.After(newbooking.Unavailableto.AsTime()) || newenddate.Equal(newbooking.Unavailableto.AsTime()) {
|
||||
newbooking.Unavailableto = timestamppb.New(newenddate.Add(24 * time.Hour))
|
||||
if enddate.After(newbooking.Unavailableto.AsTime()) || enddate.Equal(newbooking.Unavailableto.AsTime()) {
|
||||
newbooking.Unavailableto = timestamppb.New(enddate.Add(24 * time.Hour))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,8 +31,8 @@ type VehiclesSearchResult struct {
|
||||
BeneficiaryDocuments []filestorage.FileInfo
|
||||
Groups map[string]any
|
||||
Searched bool
|
||||
StartDate string
|
||||
EndDate string
|
||||
StartDate time.Time
|
||||
EndDate time.Time
|
||||
VehicleType string
|
||||
Automatic bool
|
||||
MandatoryDocuments []string
|
||||
@@ -41,22 +41,13 @@ type VehiclesSearchResult struct {
|
||||
Beneficiaries []mobilityaccountsstorage.Account
|
||||
}
|
||||
|
||||
func (h *ApplicationHandler) SearchVehicles(ctx context.Context, beneficiaryID, startDateStr, endDateStr, vehicleType string, automatic bool) (*VehiclesSearchResult, error) {
|
||||
func (h *ApplicationHandler) SearchVehicles(ctx context.Context, beneficiaryID string, startdate, enddate time.Time, vehicleType string, automatic bool) (*VehiclesSearchResult, error) {
|
||||
var beneficiary mobilityaccountsstorage.Account
|
||||
beneficiarydocuments := []filestorage.FileInfo{}
|
||||
vehicles := []storage.Vehicle{}
|
||||
searched := false
|
||||
administrators := []string{}
|
||||
|
||||
startdate, err := time.Parse("2006-01-02", startDateStr)
|
||||
if err != nil {
|
||||
startdate = time.Time{}
|
||||
}
|
||||
enddate, err := time.Parse("2006-01-02", endDateStr)
|
||||
if err != nil {
|
||||
enddate = time.Time{}
|
||||
}
|
||||
|
||||
if beneficiaryID != "" && startdate.After(time.Now().Add(-24*time.Hour)) && enddate.After(startdate) {
|
||||
// Handler form
|
||||
searched = true
|
||||
@@ -165,8 +156,8 @@ func (h *ApplicationHandler) SearchVehicles(ctx context.Context, beneficiaryID,
|
||||
BeneficiaryDocuments: beneficiarydocuments,
|
||||
Groups: groups,
|
||||
Searched: searched,
|
||||
StartDate: startDateStr,
|
||||
EndDate: endDateStr,
|
||||
StartDate: startdate,
|
||||
EndDate: enddate,
|
||||
VehicleType: vehicleType,
|
||||
Automatic: automatic,
|
||||
MandatoryDocuments: mandatoryDocuments,
|
||||
@@ -180,7 +171,7 @@ type BookVehicleResult struct {
|
||||
BookingID string
|
||||
}
|
||||
|
||||
func (h *ApplicationHandler) BookVehicle(ctx context.Context, vehicleID, beneficiaryID, startDateStr, endDateStr string, documents map[string]io.Reader, documentHeaders map[string]string, existingDocs map[string]string, currentUserID string, currentUserClaims map[string]any, currentGroup any) (*BookVehicleResult, error) {
|
||||
func (h *ApplicationHandler) BookVehicle(ctx context.Context, vehicleID, beneficiaryID string, startdate, enddate time.Time, documents map[string]io.Reader, documentHeaders map[string]string, existingDocs map[string]string, currentUserID string, currentUserClaims map[string]any, currentGroup any) (*BookVehicleResult, error) {
|
||||
group := currentGroup.(groupsmanagementstorage.Group)
|
||||
|
||||
vehicle, err := h.services.GRPC.Fleets.GetVehicle(ctx, &fleets.GetVehicleRequest{
|
||||
@@ -190,15 +181,6 @@ func (h *ApplicationHandler) BookVehicle(ctx context.Context, vehicleID, benefic
|
||||
return nil, fmt.Errorf("vehicle not found: %w", err)
|
||||
}
|
||||
|
||||
startdate, err := time.Parse("2006-01-02", startDateStr)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("invalid start date: %w", err)
|
||||
}
|
||||
enddate, err := time.Parse("2006-01-02", endDateStr)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("invalid end date: %w", err)
|
||||
}
|
||||
|
||||
data := map[string]any{
|
||||
"booked_by": map[string]any{
|
||||
"user": map[string]any{
|
||||
|
||||
Reference in New Issue
Block a user