forked from Kispi/Core
feat(webapp): change wage to daily in wording, add max value for bank input and allow admin to get realtime updates in bank view again
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
d13e7f664f
commit
2430243028
7 changed files with 35 additions and 21 deletions
|
@ -2,7 +2,7 @@
|
|||
"name": "hgoe-sas",
|
||||
"private": true,
|
||||
"author": "Simon Giesel",
|
||||
"version": "1.3.2",
|
||||
"version": "1.3.6",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vue-tsc --noEmit && vite build",
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
type="number"
|
||||
class="input w-full border-primary text-right"
|
||||
:class="{
|
||||
'pr-[5.5rem]': !perHour,
|
||||
'pr-[7rem]': perHour,
|
||||
'pr-[5.5rem]': !perDay,
|
||||
'pr-[8rem]': perDay,
|
||||
'!border-error': error,
|
||||
}"
|
||||
step="1"
|
||||
|
@ -19,10 +19,10 @@
|
|||
:class="{
|
||||
'-mt-3': !suffixMargin,
|
||||
'mt-[-0.625rem]': suffixMargin,
|
||||
'ml-[-5.5rem]': !perHour,
|
||||
'ml-[-7rem]': perHour,
|
||||
'ml-[-5.5rem]': !perDay,
|
||||
'ml-[-8rem]': perDay,
|
||||
}"
|
||||
>,00 Batzen{{ perHour ? ' / h' : '' }}</span>
|
||||
>,00 Batzen{{ perDay ? ' / Tag' : '' }}</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
@ -34,7 +34,7 @@ const error = ref(false);
|
|||
|
||||
const props = withDefaults(defineProps<{
|
||||
suffixMargin?: boolean,
|
||||
perHour?: boolean,
|
||||
perDay?: boolean,
|
||||
min?: number,
|
||||
max?: number,
|
||||
value?: number,
|
||||
|
|
|
@ -89,7 +89,7 @@
|
|||
<AtomCurrencyInput
|
||||
v-model="entry.wage"
|
||||
suffix-margin
|
||||
per-hour
|
||||
per-day
|
||||
class="min-w-[11rem]"
|
||||
:min="settings.minWage / 100"
|
||||
:max="settings.maxWage / 100"
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
<AtomCurrencyInput
|
||||
v-model="amount"
|
||||
class="w-4/12"
|
||||
:max="1000"
|
||||
@keyup.esc="modal?.close()"
|
||||
/>
|
||||
</div>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<template>
|
||||
<MoleculeBankerAuthDialog
|
||||
v-if="!isBanker && !AuthService.isAdmin()"
|
||||
v-if="!isBanker"
|
||||
/>
|
||||
<div v-else>
|
||||
<div
|
||||
|
@ -201,6 +201,7 @@ function getBalance(): number {
|
|||
|
||||
async function handleDeposit(amount: string) {
|
||||
const amountNumber = parseInt(amount);
|
||||
if(amountNumber > 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<Trans
|
|||
|
||||
onMounted(async () => {
|
||||
isBanker.value = AuthService.isBanker();
|
||||
isBanker.value = AuthService.isAdmin();
|
||||
});
|
||||
|
||||
useEventBus<boolean>('isBanker').on(state => (isBanker.value = state));
|
||||
useEventBus<boolean>('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();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -77,12 +77,12 @@
|
|||
>
|
||||
<div class="stat place-items-center">
|
||||
<div class="stat-title">Aktueller Mindestlohn</div>
|
||||
<div class="stat-value">{{ CurrencyService.toString(settings.minWage, false) }} / h</div>
|
||||
<div class="stat-value">{{ CurrencyService.toString(settings.minWage, false) }} / Tag</div>
|
||||
<div class="stat-desc">Batzen</div>
|
||||
</div>
|
||||
<div class="stat place-items-center">
|
||||
<div class="stat-title">Aktueller Maximallohn</div>
|
||||
<div class="stat-value">{{ CurrencyService.toString(settings.maxWage, false) }} / h</div>
|
||||
<div class="stat-value">{{ CurrencyService.toString(settings.maxWage, false) }} / Tag</div>
|
||||
<div class="stat-desc">Batzen</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<AtomCurrencyInput
|
||||
v-model="minWage"
|
||||
class="w-2/4"
|
||||
per-hour
|
||||
per-day
|
||||
/>
|
||||
</div>
|
||||
<div class="flex place-items-center justify-between">
|
||||
|
@ -26,7 +26,7 @@
|
|||
<AtomCurrencyInput
|
||||
v-model="maxWage"
|
||||
:min="minWage"
|
||||
per-hour
|
||||
per-day
|
||||
class="w-2/4"
|
||||
/>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue