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",
|
"name": "hgoe-sas",
|
||||||
"private": true,
|
"private": true,
|
||||||
"author": "Simon Giesel",
|
"author": "Simon Giesel",
|
||||||
"version": "1.3.2",
|
"version": "1.3.6",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"build": "vue-tsc --noEmit && vite build",
|
"build": "vue-tsc --noEmit && vite build",
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
type="number"
|
type="number"
|
||||||
class="input w-full border-primary text-right"
|
class="input w-full border-primary text-right"
|
||||||
:class="{
|
:class="{
|
||||||
'pr-[5.5rem]': !perHour,
|
'pr-[5.5rem]': !perDay,
|
||||||
'pr-[7rem]': perHour,
|
'pr-[8rem]': perDay,
|
||||||
'!border-error': error,
|
'!border-error': error,
|
||||||
}"
|
}"
|
||||||
step="1"
|
step="1"
|
||||||
|
@ -19,10 +19,10 @@
|
||||||
:class="{
|
:class="{
|
||||||
'-mt-3': !suffixMargin,
|
'-mt-3': !suffixMargin,
|
||||||
'mt-[-0.625rem]': suffixMargin,
|
'mt-[-0.625rem]': suffixMargin,
|
||||||
'ml-[-5.5rem]': !perHour,
|
'ml-[-5.5rem]': !perDay,
|
||||||
'ml-[-7rem]': perHour,
|
'ml-[-8rem]': perDay,
|
||||||
}"
|
}"
|
||||||
>,00 Batzen{{ perHour ? ' / h' : '' }}</span>
|
>,00 Batzen{{ perDay ? ' / Tag' : '' }}</span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ const error = ref(false);
|
||||||
|
|
||||||
const props = withDefaults(defineProps<{
|
const props = withDefaults(defineProps<{
|
||||||
suffixMargin?: boolean,
|
suffixMargin?: boolean,
|
||||||
perHour?: boolean,
|
perDay?: boolean,
|
||||||
min?: number,
|
min?: number,
|
||||||
max?: number,
|
max?: number,
|
||||||
value?: number,
|
value?: number,
|
||||||
|
|
|
@ -89,7 +89,7 @@
|
||||||
<AtomCurrencyInput
|
<AtomCurrencyInput
|
||||||
v-model="entry.wage"
|
v-model="entry.wage"
|
||||||
suffix-margin
|
suffix-margin
|
||||||
per-hour
|
per-day
|
||||||
class="min-w-[11rem]"
|
class="min-w-[11rem]"
|
||||||
:min="settings.minWage / 100"
|
:min="settings.minWage / 100"
|
||||||
:max="settings.maxWage / 100"
|
:max="settings.maxWage / 100"
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
<AtomCurrencyInput
|
<AtomCurrencyInput
|
||||||
v-model="amount"
|
v-model="amount"
|
||||||
class="w-4/12"
|
class="w-4/12"
|
||||||
|
:max="1000"
|
||||||
@keyup.esc="modal?.close()"
|
@keyup.esc="modal?.close()"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<MoleculeBankerAuthDialog
|
<MoleculeBankerAuthDialog
|
||||||
v-if="!isBanker && !AuthService.isAdmin()"
|
v-if="!isBanker"
|
||||||
/>
|
/>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
<div
|
<div
|
||||||
|
@ -201,6 +201,7 @@ function getBalance(): number {
|
||||||
|
|
||||||
async function handleDeposit(amount: string) {
|
async function handleDeposit(amount: string) {
|
||||||
const amountNumber = parseInt(amount);
|
const amountNumber = parseInt(amount);
|
||||||
|
if(amountNumber > 1000) { return; }
|
||||||
if(!isNaN(amountNumber) && account.value) {
|
if(!isNaN(amountNumber) && account.value) {
|
||||||
await BankService.addTransaction(account.value.id, amountNumber, TransactionType.DEPOSIT);
|
await BankService.addTransaction(account.value.id, amountNumber, TransactionType.DEPOSIT);
|
||||||
} else if(!isNaN(amountNumber) && company.value) {
|
} else if(!isNaN(amountNumber) && company.value) {
|
||||||
|
@ -210,7 +211,8 @@ async function handleDeposit(amount: string) {
|
||||||
|
|
||||||
async function handleWithdraw(amount: string) {
|
async function handleWithdraw(amount: string) {
|
||||||
const amountNumber = parseInt(amount);
|
const amountNumber = parseInt(amount);
|
||||||
if(parseInt(amount) * 100 <= getBalance()) {
|
if(amountNumber > 1000) { return; }
|
||||||
|
if(amountNumber * 100 <= getBalance()) {
|
||||||
if(!isNaN(amountNumber) && account.value) {
|
if(!isNaN(amountNumber) && account.value) {
|
||||||
// TODO: add max amount to input field and display custom error message
|
// TODO: add max amount to input field and display custom error message
|
||||||
await BankService.addTransaction(account.value.id, -amountNumber, TransactionType.WITHDRAW);
|
await BankService.addTransaction(account.value.id, -amountNumber, TransactionType.WITHDRAW);
|
||||||
|
@ -252,23 +254,34 @@ function handleRealtimeUpdates(transactionSubscription: RecordSubscription<Trans
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
isBanker.value = AuthService.isBanker();
|
isBanker.value = AuthService.isBanker();
|
||||||
|
isBanker.value = AuthService.isAdmin();
|
||||||
});
|
});
|
||||||
|
|
||||||
useEventBus<boolean>('isBanker').on(state => (isBanker.value = state));
|
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?.();
|
subscription.value?.();
|
||||||
companySubscription.value?.();
|
companySubscription.value?.();
|
||||||
});
|
}
|
||||||
|
|
||||||
watch(isBanker, async (newValue) => {
|
watch(isBanker, async (newValue) => {
|
||||||
if(newValue) {
|
if(newValue) {
|
||||||
subscription.value = await BankService.subscribeToTransactionChanges(handleRealtimeUpdates);
|
await init();
|
||||||
companySubscription.value = await BankService.subscribeToCompanyTransactionChanges(handleRealtimeUpdates);
|
|
||||||
settings.value = await SettingsService.getSettings();
|
|
||||||
} else {
|
} else {
|
||||||
subscription.value?.();
|
destroyRealtime();
|
||||||
companySubscription.value?.();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -77,12 +77,12 @@
|
||||||
>
|
>
|
||||||
<div class="stat place-items-center">
|
<div class="stat place-items-center">
|
||||||
<div class="stat-title">Aktueller Mindestlohn</div>
|
<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 class="stat-desc">Batzen</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="stat place-items-center">
|
<div class="stat place-items-center">
|
||||||
<div class="stat-title">Aktueller Maximallohn</div>
|
<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 class="stat-desc">Batzen</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
<AtomCurrencyInput
|
<AtomCurrencyInput
|
||||||
v-model="minWage"
|
v-model="minWage"
|
||||||
class="w-2/4"
|
class="w-2/4"
|
||||||
per-hour
|
per-day
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex place-items-center justify-between">
|
<div class="flex place-items-center justify-between">
|
||||||
|
@ -26,7 +26,7 @@
|
||||||
<AtomCurrencyInput
|
<AtomCurrencyInput
|
||||||
v-model="maxWage"
|
v-model="maxWage"
|
||||||
:min="minWage"
|
:min="minWage"
|
||||||
per-hour
|
per-day
|
||||||
class="w-2/4"
|
class="w-2/4"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue