From 8a5de3a6dd33983064aa056e0115ccf1bba76bdb Mon Sep 17 00:00:00 2001 From: Collin Buelo Date: Sun, 19 Oct 2025 13:58:41 -0500 Subject: [PATCH 1/3] initial working daterange --- src/src/app/components/trips/trips.component.ts | 5 ++++- .../trip-create-modal/trip-create-modal.component.html | 9 ++------- .../trip-create-modal/trip-create-modal.component.ts | 3 +-- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/src/app/components/trips/trips.component.ts b/src/src/app/components/trips/trips.component.ts index 3989062..0c9b05f 100644 --- a/src/src/app/components/trips/trips.component.ts +++ b/src/src/app/components/trips/trips.component.ts @@ -11,6 +11,7 @@ import { DatePipe } from '@angular/common'; import { DialogModule } from 'primeng/dialog'; interface TripBaseWithDates extends TripBase { + daterange?: Date[]; from?: Date; to?: Date; } @@ -81,7 +82,9 @@ export class TripsComponent implements OnInit { next: (new_trip: TripBase) => { let dayCount = 0; - if (trip.from && trip.to) { + if (trip.daterange && trip.daterange.length === 2) { + trip.to = new Date(trip.daterange[1]); + trip.from = new Date(trip.daterange[0]); const obs$ = this.generateDaysLabel(trip.from!, trip.to!).map((label) => this.apiService.postTripDay({ id: -1, label: label, items: [] }, new_trip.id), ); diff --git a/src/src/app/modals/trip-create-modal/trip-create-modal.component.html b/src/src/app/modals/trip-create-modal/trip-create-modal.component.html index 0cb0338..2386a7a 100644 --- a/src/src/app/modals/trip-create-modal/trip-create-modal.component.html +++ b/src/src/app/modals/trip-create-modal/trip-create-modal.component.html @@ -12,13 +12,8 @@ @if (tripForm.get("id")?.value === -1) {
- - - - - - - + +
} diff --git a/src/src/app/modals/trip-create-modal/trip-create-modal.component.ts b/src/src/app/modals/trip-create-modal/trip-create-modal.component.ts index 623ce41..1eacd57 100644 --- a/src/src/app/modals/trip-create-modal/trip-create-modal.component.ts +++ b/src/src/app/modals/trip-create-modal/trip-create-modal.component.ts @@ -33,8 +33,7 @@ export class TripCreateModalComponent { image: '', currency: null, image_id: null, - from: null, - to: null, + daterange: null, }); const patchValue = this.config.data?.trip; From 98c0bb2cd586e4a05d1faca2d234fdd267d451c7 Mon Sep 17 00:00:00 2001 From: Collin Buelo Date: Sun, 19 Oct 2025 14:01:33 -0500 Subject: [PATCH 2/3] simplified --- src/src/app/components/trips/trips.component.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/src/app/components/trips/trips.component.ts b/src/src/app/components/trips/trips.component.ts index 0c9b05f..e689a8e 100644 --- a/src/src/app/components/trips/trips.component.ts +++ b/src/src/app/components/trips/trips.component.ts @@ -12,8 +12,6 @@ import { DialogModule } from 'primeng/dialog'; interface TripBaseWithDates extends TripBase { daterange?: Date[]; - from?: Date; - to?: Date; } @Component({ @@ -83,9 +81,7 @@ export class TripsComponent implements OnInit { let dayCount = 0; if (trip.daterange && trip.daterange.length === 2) { - trip.to = new Date(trip.daterange[1]); - trip.from = new Date(trip.daterange[0]); - const obs$ = this.generateDaysLabel(trip.from!, trip.to!).map((label) => + const obs$ = this.generateDaysLabel(trip.daterange).map((label) => this.apiService.postTripDay({ id: -1, label: label, items: [] }, new_trip.id), ); dayCount = obs$.length; @@ -110,7 +106,9 @@ export class TripsComponent implements OnInit { }); } - generateDaysLabel(from: Date, to: Date): string[] { + generateDaysLabel(daterange: Date[]): string[] { + const from = daterange[0]; + const to = daterange[1]; const labels: string[] = []; const sameMonth = from.getFullYear() === to.getFullYear() && from.getMonth() === to.getMonth(); From 4f6ad08ee192d2322ca8e6893a9c06be73f6ab1c Mon Sep 17 00:00:00 2001 From: Kovacs <36224223+itskovacs@users.noreply.github.com> Date: Mon, 20 Oct 2025 12:56:10 +0200 Subject: [PATCH 3/3] Refine classes --- .../modals/trip-create-modal/trip-create-modal.component.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/src/app/modals/trip-create-modal/trip-create-modal.component.html b/src/src/app/modals/trip-create-modal/trip-create-modal.component.html index 2386a7a..dd31ff7 100644 --- a/src/src/app/modals/trip-create-modal/trip-create-modal.component.html +++ b/src/src/app/modals/trip-create-modal/trip-create-modal.component.html @@ -10,7 +10,7 @@ @if (tripForm.get("id")?.value === -1) { -
+
@@ -56,4 +56,4 @@
{{ tripForm.get("id")?.value !== -1 ? "Update" : "Create" }} -
\ No newline at end of file +