Skip to content
This repository has been archived by the owner on Oct 13, 2024. It is now read-only.

Commit

Permalink
Update timestamp import
Browse files Browse the repository at this point in the history
  • Loading branch information
Yudi committed Jun 1, 2024
1 parent 43d7477 commit 3f70f53
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { AngularFirestore, DocumentReference } from '@angular/fire/compat/firest
import { trace } from '@angular/fire/compat/performance';

import { MajorEventItem } from 'src/app/shared/services/major-event.service';
import { Timestamp } from '@firebase/firestore';
import { Timestamp } from '@angular/fire/firestore';
import { SwalComponent, SweetAlert2Module } from '@sweetalert2/ngx-sweetalert2';

import { EnrollmentTypesService } from '../../../shared/services/enrollment-types.service';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ import { trace } from '@angular/fire/compat/performance';
import { EventItem } from 'src/app/shared/services/event';
import { SwalComponent, SweetAlert2Module } from '@sweetalert2/ngx-sweetalert2';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { Timestamp as TimestampType } from '@firebase/firestore-types';
import { AuthService } from 'src/app/shared/services/auth.service';
import { serverTimestamp } from '@angular/fire/firestore';
import { serverTimestamp, Timestamp } from '@angular/fire/firestore';
import { MajorEventItem } from 'src/app/shared/services/major-event.service';
import { DateService } from 'src/app/shared/services/date.service';
import { Auth, user } from '@angular/fire/auth';
Expand Down Expand Up @@ -42,7 +41,7 @@ import { AztecScannerComponent } from '../../../shared/components/aztec-scanner/

interface Attendance {
user: Observable<User | undefined>;
time: TimestampType;
time: Timestamp;
id?: string;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { EventItem } from 'src/app/shared/services/event';
import { AngularFirestore } from '@angular/fire/compat/firestore';
import { ModalController } from '@ionic/angular/standalone';
import { FormGroup, FormBuilder, Validators, ReactiveFormsModule } from '@angular/forms';
import { Timestamp } from '@firebase/firestore';
import { Timestamp } from '@angular/fire/firestore';
import { DateService } from 'src/app/shared/services/date.service';
import { EmojiService } from '../../../../shared/services/emoji.service';
import { Component, Input, OnInit } from '@angular/core';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { CoursesService } from 'src/app/shared/services/courses.service';
import { EventItem } from 'src/app/shared/services/event';
import { User } from 'src/app/shared/services/user';
import { SwalComponent, SweetAlert2Module } from '@sweetalert2/ngx-sweetalert2';
import { Timestamp } from '@firebase/firestore-types';
import { Timestamp } from '@angular/fire/firestore';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { DateService } from 'src/app/shared/services/date.service';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { trace } from '@angular/fire/compat/performance';
import { ActivatedRoute, Router } from '@angular/router';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { SwalComponent, SweetAlert2Module } from '@sweetalert2/ngx-sweetalert2';
import { Timestamp } from '@firebase/firestore-types';
import { Timestamp } from '@angular/fire/firestore';
import { first, map, Observable } from 'rxjs';
import { EventItem } from 'src/app/shared/services/event';
import { User } from 'src/app/shared/services/user';
Expand Down Expand Up @@ -69,7 +69,7 @@ export class ListEventSubscriptionsPage {
private router: Router,
private route: ActivatedRoute,
public courses: CoursesService,
public dateService: DateService,
public dateService: DateService
) {
this.eventID = this.route.snapshot.params['eventID'];
this.afs
Expand Down Expand Up @@ -103,8 +103,8 @@ export class ListEventSubscriptionsPage {
.doc(item.id)
.get()
.pipe(map((document) => document.data())),
})),
),
}))
)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Component, inject, OnInit, ViewChild } from '@angular/core';
import { AbstractControl, FormBuilder, FormGroup, ValidationErrors, Validators } from '@angular/forms';
import { CoursesService } from 'src/app/shared/services/courses.service';
import { format, parseISO, addHours } from 'date-fns';
import { Timestamp } from '@firebase/firestore';
import { Timestamp } from '@angular/fire/firestore';

import { BehaviorSubject, Observable } from 'rxjs';
import { AngularFirestore } from '@angular/fire/compat/firestore';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { parseISO, getUnixTime } from 'date-fns';

import { ModalController } from '@ionic/angular/standalone';
import { MajorEventItem } from 'src/app/shared/services/major-event.service';
import { Timestamp } from '@firebase/firestore';
import { Timestamp } from '@angular/fire/firestore';

import {
IonIcon,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ActivatedRoute, Router, RouterLink } from '@angular/router';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { SwalComponent, SweetAlert2Module } from '@sweetalert2/ngx-sweetalert2';
import { fromUnixTime } from 'date-fns';
import { Timestamp } from '@firebase/firestore-types';
import { Timestamp } from '@angular/fire/firestore';
import { map, Observable, take, forkJoin } from 'rxjs';
import { User } from 'src/app/shared/services/user';
import { CoursesService } from 'src/app/shared/services/courses.service';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { Component, inject, OnInit, ViewChild } from '@angular/core';
import { AngularFirestore, AngularFirestoreCollection } from '@angular/fire/compat/firestore';
import { ActivatedRoute } from '@angular/router';
import { Timestamp as TimestampType } from '@firebase/firestore-types';
import { Timestamp } from '@firebase/firestore-types';
import { Observable, map, take, combineLatest } from 'rxjs';
import { MajorEventItem } from 'src/app/shared/services/major-event.service';
import { User } from 'src/app/shared/services/user';
Expand Down Expand Up @@ -501,10 +501,10 @@ export class ValidateReceiptPage implements OnInit {
interface Subscription {
id: string;
userData$: Observable<User>;
time: TimestampType;
time: Timestamp;
payment: {
status: number;
time: TimestampType;
time: Timestamp;
error?: string;
price?: number;
author?: string;
Expand Down
2 changes: 1 addition & 1 deletion src/app/shared/services/certificates.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { MajorEventItem } from 'src/app/shared/services/major-event.service';
import { EventItem } from 'src/app/shared/services/event';
import { AngularFirestore } from '@angular/fire/compat/firestore';
import { DocumentReference } from '@angular/fire/firestore';
import { Timestamp } from '@firebase/firestore-types';
import { Timestamp } from '@angular/fire/firestore';
import { Observable, take, switchMap, combineLatest, map, mergeMap, forkJoin } from 'rxjs';
import { Injectable, isDevMode } from '@angular/core';
import { format as formatDate } from 'date-fns';
Expand Down
11 changes: 5 additions & 6 deletions src/app/shared/services/date.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Injectable } from '@angular/core';
import { compareAsc, fromUnixTime, isSameDay, isSameMonth, parseISO } from 'date-fns';
import { Timestamp as TimestampType } from '@firebase/firestore-types';
import { Timestamp } from '@firebase/firestore';
import { Timestamp } from '@angular/fire/firestore';

@Injectable({
providedIn: 'root',
Expand Down Expand Up @@ -35,19 +34,19 @@ export class DateService {

// Firestore Timestamp

getDateFromTimestamp(Timestamp: TimestampType): Date {
getDateFromTimestamp(Timestamp: Timestamp): Date {
return fromUnixTime(Timestamp.seconds);
}

compareDayTimestamp(date1: TimestampType, date2: TimestampType): boolean {
compareDayTimestamp(date1: Timestamp, date2: Timestamp): boolean {
return isSameDay(this.getDateFromTimestamp(date1), this.getDateFromTimestamp(date2));
}

compareMonthTimestamp(date1: TimestampType, date2: TimestampType): boolean {
compareMonthTimestamp(date1: Timestamp, date2: Timestamp): boolean {
return isSameMonth(fromUnixTime(date1.seconds), fromUnixTime(date2.seconds));
}

TimestampFromDate(date: Date): TimestampType {
TimestampFromDate(date: Date): Timestamp {
return Timestamp.fromDate(date);
}
}
2 changes: 1 addition & 1 deletion src/app/shared/services/major-event.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable } from '@angular/core';
import { AngularFirestore } from '@angular/fire/compat/firestore';
import { Timestamp } from '@firebase/firestore-types';
import { Timestamp } from '@angular/fire/firestore';
import { Observable } from 'rxjs';
import { startOfDay } from 'date-fns';

Expand Down

0 comments on commit 3f70f53

Please sign in to comment.