|
@@ -1,15 +1,16 @@
|
|
|
import { Injectable } from '@nestjs/common';
|
|
import { Injectable } from '@nestjs/common';
|
|
|
|
|
+import { SocketGateway } from 'src/gateway/socket.gateway';
|
|
|
import { AttendancePayload, PaymentPayload } from 'src/interface/interface';
|
|
import { AttendancePayload, PaymentPayload } from 'src/interface/interface';
|
|
|
|
|
|
|
|
@Injectable()
|
|
@Injectable()
|
|
|
export class PaymentService {
|
|
export class PaymentService {
|
|
|
paymentRecord: PaymentPayload[] = []
|
|
paymentRecord: PaymentPayload[] = []
|
|
|
- constructor() {
|
|
|
|
|
- // need to pipe the socket obs here so that the value can be updated to UI in real time
|
|
|
|
|
|
|
+ constructor(private socket: SocketGateway) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public emit(payment: PaymentPayload) {
|
|
public emit(payment: PaymentPayload) {
|
|
|
console.log(`Processing payment for ${payment.name} at ${payment.date}`)
|
|
console.log(`Processing payment for ${payment.name} at ${payment.date}`)
|
|
|
this.paymentRecord.push(payment)
|
|
this.paymentRecord.push(payment)
|
|
|
|
|
+ this.socket.emit({ action: `Payment`, name: payment.name, time: payment.date })
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|