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

Commit

Permalink
feat: consider manual attendance as another source
Browse files Browse the repository at this point in the history
  • Loading branch information
Yudi committed Sep 30, 2024
1 parent 897b66e commit c870bf3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Caminhos:
interface Attendance {
time: Timestamp;
author: string; // Usuário que coletou a presença. Pode ser o próprio.
source?: 'online' | 'scanner';
source?: 'online' | 'scanner' | 'manual';
id?: string;
}
```
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import { EmojiService } from 'src/app/shared/services/emoji.service';
interface Attendance {
user: Observable<User | undefined>;
time: Timestamp;
source?: 'online' | 'scanner';
source?: 'online' | 'scanner' | 'manual';
id?: string;
}

Expand Down Expand Up @@ -247,7 +247,7 @@ export class ScannerPage implements OnInit {
onCodeResult(resultString: string) {
if (resultString.startsWith('uid:') && resultString.length === 32) {
const uid = resultString.substring(4);
this.writeUserAttendance(uid);
this.writeUserAttendance(uid, 'scanner');
} else {
this.backdropColor('invalid');
this.audioInvalid.play();
Expand Down Expand Up @@ -358,7 +358,7 @@ export class ScannerPage implements OnInit {
* Escreve um determinado UID na coleção correta
* @param uid User ID, ID do usuário
*/
writeUserAttendance(uid: string | null) {
writeUserAttendance(uid: string | null, source: 'manual' | 'scanner') {
if (!uid) {
return;
}
Expand All @@ -376,17 +376,17 @@ export class ScannerPage implements OnInit {
.pipe(take(1))
.subscribe((paid) => {
if (paid) {
this.writeUIDAttendance(uid);
this.writeUIDAttendance(uid, source);
// If it was on NP-attendance, remove.
this.removeFromNPAttendance(uid);
} else {
this.writeUIDNPAttendance(uid);
this.writeUIDNPAttendance(uid, source);
}
});
}
// Else, write on 'attendance'
else {
this.writeUIDAttendance(uid);
this.writeUIDAttendance(uid, source);
}
}
// User does not exists
Expand All @@ -401,7 +401,7 @@ export class ScannerPage implements OnInit {
* Escreve um determinado UID na coleção 'attendance'
* @param uid User ID, ID do usuário
*/
writeUIDAttendance(uid: string) {
writeUIDAttendance(uid: string, source: 'manual' | 'scanner') {
this.afs
.collection<Attendance>(`events/${this.eventID}/attendance`)
.doc(uid)
Expand All @@ -418,7 +418,7 @@ export class ScannerPage implements OnInit {
this.afs.collection(`events/${this.eventID}/attendance`).doc(uid).set({
time: serverTimestamp(),
author: this.adminID,
source: 'scanner',
source: source,
});
this.audioSuccess.play();
this.toastSucess();
Expand All @@ -432,7 +432,7 @@ export class ScannerPage implements OnInit {
* Escreve um determinado UID na coleção 'non-paying-attendance'
* @param uid User ID, ID do usuário
*/
writeUIDNPAttendance(uid: string) {
writeUIDNPAttendance(uid: string, source: 'manual' | 'scanner') {
this.afs
.collection<Attendance>(`events/${this.eventID}/non-paying-attendance`)
.doc(uid)
Expand All @@ -449,7 +449,7 @@ export class ScannerPage implements OnInit {
this.afs.collection(`events/${this.eventID}/non-paying-attendance`).doc(uid).set({
time: serverTimestamp(),
author: this.adminID,
source: 'scanner',
source: source,
});
this.audioNotPaid.play();
this.toastNotPaid();
Expand All @@ -472,7 +472,7 @@ export class ScannerPage implements OnInit {
return;
}

this.writeUserAttendance(response.data);
this.writeUserAttendance(response.data, 'manual');
}

async toastSucess() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { checkmarkCircleOutline } from 'ionicons/icons';
interface Attendance {
user: Observable<User>;
time: Timestamp;
source?: 'online' | 'scanner';
source?: 'online' | 'scanner' | 'manual';
id?: string;
}

Expand Down

0 comments on commit c870bf3

Please sign in to comment.