initial working daterange

This commit is contained in:
Collin Buelo 2025-10-19 13:58:41 -05:00
parent 4b117f0673
commit 8a5de3a6dd
3 changed files with 7 additions and 10 deletions

View File

@ -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),
);

View File

@ -12,13 +12,8 @@
@if (tripForm.get("id")?.value === -1) {
<div class="grid md:col-span-4 grid-cols-2 gap-2">
<p-floatlabel variant="in">
<p-datepicker id="from" formControlName="from" [iconDisplay]="'input'" [showIcon]="true" appendTo="body" fluid />
<label for="from">From</label>
</p-floatlabel>
<p-floatlabel variant="in">
<p-datepicker id="to" formControlName="to" [iconDisplay]="'input'" [showIcon]="true" appendTo="body" fluid />
<label for="to">To</label>
<p-datepicker id="daterange" formControlName="daterange" [iconDisplay]="'input'" [showIcon]="true" selectionMode="range" appendTo="body" fluid />
<label for="daterange">Date Range</label>
</p-floatlabel>
</div>
}

View File

@ -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;