1000) { return; }
if(!isNaN(amountNumber) && account.value) {
await BankService.addTransaction(account.value.id, amountNumber, TransactionType.DEPOSIT);
} else if(!isNaN(amountNumber) && company.value) {
@@ -210,7 +211,8 @@ async function handleDeposit(amount: string) {
async function handleWithdraw(amount: string) {
const amountNumber = parseInt(amount);
- if(parseInt(amount) * 100 <= getBalance()) {
+ if(amountNumber > 1000) { return; }
+ if(amountNumber * 100 <= getBalance()) {
if(!isNaN(amountNumber) && account.value) {
// TODO: add max amount to input field and display custom error message
await BankService.addTransaction(account.value.id, -amountNumber, TransactionType.WITHDRAW);
@@ -252,23 +254,34 @@ function handleRealtimeUpdates(transactionSubscription: RecordSubscription
{
isBanker.value = AuthService.isBanker();
+ isBanker.value = AuthService.isAdmin();
});
useEventBus('isBanker').on(state => (isBanker.value = state));
+useEventBus('isAdmin').on(state => (isBanker.value = state));
-onUnmounted(() => {
+onUnmounted(destroyRealtime);
+
+async function init() {
+ if(!subscription.value) {
+ subscription.value = await BankService.subscribeToTransactionChanges(handleRealtimeUpdates);
+ }
+ if(!companySubscription.value) {
+ companySubscription.value = await BankService.subscribeToCompanyTransactionChanges(handleRealtimeUpdates);
+ }
+ settings.value = await SettingsService.getSettings();
+}
+
+function destroyRealtime() {
subscription.value?.();
companySubscription.value?.();
-});
+}
watch(isBanker, async (newValue) => {
if(newValue) {
- subscription.value = await BankService.subscribeToTransactionChanges(handleRealtimeUpdates);
- companySubscription.value = await BankService.subscribeToCompanyTransactionChanges(handleRealtimeUpdates);
- settings.value = await SettingsService.getSettings();
+ await init();
} else {
- subscription.value?.();
- companySubscription.value?.();
+ destroyRealtime();
}
});
diff --git a/webapp/src/components/views/ViewEmployer.vue b/webapp/src/components/views/ViewEmployer.vue
index e2c1b1b..c6fb62c 100644
--- a/webapp/src/components/views/ViewEmployer.vue
+++ b/webapp/src/components/views/ViewEmployer.vue
@@ -77,12 +77,12 @@
>
Aktueller Mindestlohn
-
{{ CurrencyService.toString(settings.minWage, false) }} / h
+
{{ CurrencyService.toString(settings.minWage, false) }} / Tag
Batzen
Aktueller Maximallohn
-
{{ CurrencyService.toString(settings.maxWage, false) }} / h
+
{{ CurrencyService.toString(settings.maxWage, false) }} / Tag
Batzen
diff --git a/webapp/src/components/views/ViewStatePortal.vue b/webapp/src/components/views/ViewStatePortal.vue
index 237ac08..6a57a47 100644
--- a/webapp/src/components/views/ViewStatePortal.vue
+++ b/webapp/src/components/views/ViewStatePortal.vue
@@ -11,7 +11,7 @@