💄 Fix missing days on trip creation
This commit is contained in:
parent
abbfdd9d21
commit
2670662c9f
@ -32,10 +32,10 @@ def read_trip(
|
||||
return TripRead.serialize(db_trip)
|
||||
|
||||
|
||||
@router.post("", response_model=TripRead)
|
||||
@router.post("", response_model=TripReadBase)
|
||||
def create_trip(
|
||||
trip: TripCreate, session: SessionDep, current_user: Annotated[str, Depends(get_current_username)]
|
||||
) -> TripRead:
|
||||
) -> TripReadBase:
|
||||
new_trip = Trip(
|
||||
name=trip.name,
|
||||
user=current_user,
|
||||
@ -63,7 +63,7 @@ def create_trip(
|
||||
session.add(new_trip)
|
||||
session.commit()
|
||||
session.refresh(new_trip)
|
||||
return TripRead.serialize(new_trip)
|
||||
return TripReadBase.serialize(new_trip)
|
||||
|
||||
|
||||
@router.put("/{trip_id}", response_model=TripRead)
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
import { Component } from "@angular/core";
|
||||
import { Component, OnInit } from "@angular/core";
|
||||
import { ApiService } from "../../services/api.service";
|
||||
import { ButtonModule } from "primeng/button";
|
||||
import { SkeletonModule } from "primeng/skeleton";
|
||||
import { TripBase } from "../../types/trip";
|
||||
import { Category } from "../../types/poi";
|
||||
import { DialogService, DynamicDialogRef } from "primeng/dynamicdialog";
|
||||
import { TripCreateModalComponent } from "../../modals/trip-create-modal/trip-create-modal.component";
|
||||
import { Router } from "@angular/router";
|
||||
import { take } from "rxjs";
|
||||
|
||||
@Component({
|
||||
selector: "app-trips",
|
||||
@ -15,20 +15,20 @@ import { Router } from "@angular/router";
|
||||
templateUrl: "./trips.component.html",
|
||||
styleUrls: ["./trips.component.scss"],
|
||||
})
|
||||
export class TripsComponent {
|
||||
categories: Category[] = [];
|
||||
map: any;
|
||||
mapSettings: L.LatLng | undefined;
|
||||
markerClusterGroup: any;
|
||||
|
||||
export class TripsComponent implements OnInit {
|
||||
trips: TripBase[] = [];
|
||||
|
||||
constructor(
|
||||
private apiService: ApiService,
|
||||
private dialogService: DialogService,
|
||||
private router: Router,
|
||||
) {
|
||||
this.apiService.getTrips().subscribe({
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.apiService
|
||||
.getTrips()
|
||||
.pipe(take(1))
|
||||
.subscribe({
|
||||
next: (trips) => {
|
||||
this.trips = trips;
|
||||
this.sortTrips();
|
||||
@ -36,29 +36,19 @@ export class TripsComponent {
|
||||
});
|
||||
}
|
||||
|
||||
viewTrip(id: number) {
|
||||
this.router.navigateByUrl(`/trips/${id}`);
|
||||
}
|
||||
|
||||
sortTrips() {
|
||||
this.trips = this.trips.sort((a, b) => {
|
||||
if (!!a.archived !== !!b.archived) {
|
||||
return Number(!!a.archived) - Number(!!b.archived);
|
||||
}
|
||||
|
||||
return a.name.localeCompare(b.name);
|
||||
});
|
||||
}
|
||||
|
||||
gotoMap() {
|
||||
this.router.navigateByUrl("/");
|
||||
}
|
||||
|
||||
viewTrip(id: number) {
|
||||
this.router.navigateByUrl(`/trips/${id}`);
|
||||
}
|
||||
|
||||
addTrip() {
|
||||
const modal: DynamicDialogRef = this.dialogService.open(
|
||||
TripCreateModalComponent,
|
||||
{
|
||||
header: "Create Place",
|
||||
header: "Create Trip",
|
||||
modal: true,
|
||||
appendTo: "body",
|
||||
closable: true,
|
||||
@ -70,7 +60,7 @@ export class TripsComponent {
|
||||
},
|
||||
);
|
||||
|
||||
modal.onClose.subscribe({
|
||||
modal.onClose.pipe(take(1)).subscribe({
|
||||
next: (trip: TripBase | null) => {
|
||||
if (!trip) return;
|
||||
|
||||
@ -83,4 +73,14 @@ export class TripsComponent {
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
sortTrips() {
|
||||
this.trips = this.trips.sort((a, b) => {
|
||||
if (!!a.archived !== !!b.archived) {
|
||||
return Number(!!a.archived) - Number(!!b.archived);
|
||||
}
|
||||
|
||||
return a.name.localeCompare(b.name);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user