diff --git a/src/components/services/account.service.ts b/src/components/services/account.service.ts index 68e6ba3..07f4b42 100644 --- a/src/components/services/account.service.ts +++ b/src/components/services/account.service.ts @@ -39,6 +39,16 @@ export const AccountService = { } while(accountDocuments.total > offset); return accounts; }, + async checkIn(accountNumber: string): Promise { + const account = await this.getAccount(accountNumber); + if(!account) { + throw new Error('Account not found'); + } + const accountDocument = await database.updateDocument(ACCOUNTS_COLLECTION_ID, account.$id, { + lastCheckIn: Math.floor(+new Date() / 1000), + }); + return accountDocument; + }, async addAccount(account: IAccount): Promise { const accountDocument = await database.createDocument(ACCOUNTS_COLLECTION_ID, 'unique()', account); return accountDocument; diff --git a/src/components/services/date.service.ts b/src/components/services/date.service.ts index 15fbca5..b7542b9 100644 --- a/src/components/services/date.service.ts +++ b/src/components/services/date.service.ts @@ -28,4 +28,17 @@ export class DateService { year: 'numeric', }); } + public static toTime(date: Date | number): string { + if(typeof date === 'number') { + date = new Date(date * 1000); + } + if(!date) { + return 'n/a'; + } + return date.toLocaleTimeString('de-DE', { + hour: '2-digit', + minute: '2-digit', + second: '2-digit', + }); + } } \ No newline at end of file diff --git a/src/components/views/BankView.vue b/src/components/views/BankView.vue index 63261c8..553af13 100644 --- a/src/components/views/BankView.vue +++ b/src/components/views/BankView.vue @@ -131,10 +131,11 @@ onKeyStroke(['e', 'g', 'a'], (e) => { } }); -onKeyStroke(['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'Enter'], async (e) => { +onKeyStroke(['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'Enter'], (e) => { if(depositModalOpen.value || salaryModalOpen.value || withdrawModalOpen.value) { return; } + accountNotFound.value = false; e.preventDefault(); if(e.key === 'Enter') { accountId.value = inputBuffer.value; diff --git a/src/components/views/CheckInView.vue b/src/components/views/CheckInView.vue index 0333be3..e039400 100644 --- a/src/components/views/CheckInView.vue +++ b/src/components/views/CheckInView.vue @@ -1,10 +1,56 @@