Confirm dialog, fix language change bug, add bank accout information to users

This commit is contained in:
2024-09-22 20:57:28 +02:00
parent 98cc551f76
commit a55248ecef
16 changed files with 222 additions and 32 deletions

View File

@@ -9,7 +9,9 @@
"postalCode": 30449, "postalCode": 30449,
"city": "Hannover", "city": "Hannover",
"firstName": "Laurin", "firstName": "Laurin",
"lastName": "Hagemeister" "lastName": "Hagemeister",
"bankName": "Deutsche Bank",
"iban": "DE92500105175721645777"
}, },
{ {
"id": 1, "id": 1,
@@ -20,7 +22,9 @@
"postalCode": 30167, "postalCode": 30167,
"city": "Hannover", "city": "Hannover",
"firstName": "Katja", "firstName": "Katja",
"lastName": "Stoiber" "lastName": "Stoiber",
"bankName": "DZ Bank",
"iban": "DE12500105179557939114"
}, },
{ {
"id": 2, "id": 2,
@@ -31,7 +35,9 @@
"postalCode": 30625, "postalCode": 30625,
"city": "Hannover", "city": "Hannover",
"firstName": "Luna", "firstName": "Luna",
"lastName": "Oeter" "lastName": "Oeter",
"bankName": "Commerzbank",
"iban": "DE31500105175417833272"
}, },
{ {
"id": 3, "id": 3,
@@ -42,7 +48,9 @@
"postalCode": 30171, "postalCode": 30171,
"city": "Hannover", "city": "Hannover",
"firstName": "Jürgen", "firstName": "Jürgen",
"lastName": "Durand" "lastName": "Durand",
"bankName": "ING",
"iban": "DE41500105172184936679"
}, },
{ {
"id": 4, "id": 4,
@@ -53,7 +61,9 @@
"postalCode": 30163, "postalCode": 30163,
"city": "Hannover", "city": "Hannover",
"firstName": "Frederik", "firstName": "Frederik",
"lastName": "Furtwängler" "lastName": "Furtwängler",
"bankName": "Sparkasse Hannover",
"iban": "DE85500105172283979774"
}, },
{ {
"id": 5, "id": 5,
@@ -64,7 +74,9 @@
"postalCode": 30851, "postalCode": 30851,
"city": "Langenhagen", "city": "Langenhagen",
"firstName": "Mareike", "firstName": "Mareike",
"lastName": "Herbst" "lastName": "Herbst",
"bankName": "Postbank",
"iban": "DE45500105178862417577"
}, },
{ {
"id": 6, "id": 6,
@@ -75,7 +87,9 @@
"postalCode": 30880, "postalCode": 30880,
"city": "Laatzen", "city": "Laatzen",
"firstName": "Janna", "firstName": "Janna",
"lastName": "Seibert" "lastName": "Seibert",
"bankName": "Sparkasse Hannover",
"iban": "DE51500105177526222196"
} }
] ]
} }

View File

@@ -28,6 +28,12 @@ export class Account extends Model {
@Column @Column
city: string city: string
@Column
bankName: string
@Column
iban: string
// Relations // Relations
@HasMany(() => Order) @HasMany(() => Order)
orders: Order[] orders: Order[]

View File

@@ -2,7 +2,7 @@
import { useTheme } from 'vuetify/lib/framework.mjs'; import { useTheme } from 'vuetify/lib/framework.mjs';
import { useUserStore } from './data/stores/userStore'; import { useUserStore } from './data/stores/userStore';
import { i18n } from './plugins/i18n'; import { i18n } from './plugins/i18n';
import { ref } from 'vue'; import { ref, watch } from 'vue';
import vuetify from './plugins/vuetify'; import vuetify from './plugins/vuetify';
import navigationItems from './components/navigationItems.vue'; import navigationItems from './components/navigationItems.vue';
import { useProductStore } from './data/stores/productStore'; import { useProductStore } from './data/stores/productStore';
@@ -15,10 +15,14 @@ const theme = useTheme()
const navRail = ref(vuetify.display.mobile) const navRail = ref(vuetify.display.mobile)
theme.global.name.value = userStore.theme theme.global.name.value = userStore.theme
i18n.global.locale = userStore.language
productStore.fetchAllProducts() productStore.fetchAllProducts()
categoryStore.fetchAllCategories() categoryStore.fetchAllCategories()
// Global watcher
watch(() => userStore.language, () => {
i18n.global.locale = userStore.language
}, { immediate: true })
</script> </script>
<template> <template>

View File

@@ -0,0 +1,51 @@
<script setup lang="ts">
import { ModelRef } from 'vue';
import actionDialog from './actionDialog.vue';
const showDialog: ModelRef<boolean> = defineModel()
const props = defineProps({
title: String,
description: String,
onConfirm: Function
})
function confirmPressed() {
props.onConfirm()
showDialog.value = false
}
</script>
<template>
<action-dialog
:title="title"
max-width="400"
v-model="showDialog"
>
<v-container>
<v-row>
<v-col>
{{ description }}
</v-col>
</v-row>
</v-container>
<template #actions>
<v-btn
@click="showDialog = false"
color="green"
variant="outlined"
>
{{ $t("dialog.cancel") }}
</v-btn>
<v-btn
@click="confirmPressed"
color="red"
variant="outlined"
>
{{ $t("dialog.confirm") }}
</v-btn>
</template>
</action-dialog>
</template>

View File

@@ -10,4 +10,6 @@ export class AccountModel {
lastName: string = "" lastName: string = ""
createdAt: string = "" createdAt: string = ""
updatedAt: string = "" updatedAt: string = ""
bankName: string = ""
iban: string = ""
} }

View File

@@ -53,14 +53,18 @@
"street": "Straße", "street": "Straße",
"houseNumber": "Hausnummer", "houseNumber": "Hausnummer",
"postalCode": "Postleitzahl", "postalCode": "Postleitzahl",
"city": "Stadt" "city": "Stadt",
"bankName": "Name der Bank",
"iban": "IBAN"
}, },
"account": { "account": {
"username": "Username", "username": "Username",
"password": "Passwort", "password": "Passwort",
"noAccountRegister": "Neuen Account erstellen!", "noAccountRegister": "Neuen Account erstellen!",
"register": "Account erstellen", "register": "Account erstellen",
"backToLogin": "Zurück zum Login" "backToLogin": "Zurück zum Login",
"delete": "Account löschen",
"managingAccount": "Account verwalten"
}, },
"bannerMessages": { "bannerMessages": {
"loginSuccessful": "Login erfolgreich!", "loginSuccessful": "Login erfolgreich!",
@@ -86,5 +90,17 @@
"oclock": "Uhr", "oclock": "Uhr",
"ordering": { "ordering": {
"ordering": "Bestellabschluss" "ordering": "Bestellabschluss"
},
"dialog": {
"cancel": "Abbrechen",
"confirm": "Bestätigen",
"deleteAccount": {
"title": "Account löschen?",
"description": "Soll der Account wirklich gelöscht werden? Dieser kann nicht mehr wiederhergestellt werden!"
},
"resetConfirm": {
"title": "Datenbank zurücksetzen?",
"description": "Soll die Datenbank des Servers wirklich zurückgesetzt werden? Dies kann nicht rückgänig gemacht werden!"
}
} }
} }

View File

@@ -53,14 +53,18 @@
"street": "Street", "street": "Street",
"houseNumber": "House Number", "houseNumber": "House Number",
"postalCode": "Postal Code", "postalCode": "Postal Code",
"city": "City" "city": "City",
"bankName": "Bank name",
"iban": "IBAN"
}, },
"account": { "account": {
"backToLogin": "Back to Login", "backToLogin": "Back to Login",
"username": "Username", "username": "Username",
"password": "Password", "password": "Password",
"noAccountRegister": "Create new Account!", "noAccountRegister": "Create new Account!",
"register": "Create Account" "register": "Create Account",
"delete": "Delete Account",
"managingAccount": "Managing Account"
}, },
"bannerMessages": { "bannerMessages": {
"loginSuccessful": "Login erfolgreich!", "loginSuccessful": "Login erfolgreich!",
@@ -86,5 +90,17 @@
"oclock": "o'clock", "oclock": "o'clock",
"ordering": { "ordering": {
"ordering": "Finish order" "ordering": "Finish order"
},
"dialog": {
"cancel": "Cancel",
"confirm": "Bestätigen",
"deleteAccount": {
"title": "Delete account?",
"description": "Do you really want to delete the account? This can't be undone!"
},
"resetConfirm": {
"title": "Reset database?",
"description": "Do you really want to reset the server database? This can't be undone!"
}
} }
} }

View File

@@ -69,6 +69,21 @@ const userStore = useUserStore()
/> />
</v-col> </v-col>
</v-row> </v-row>
<v-row>
<v-col>
<v-text-field
:label="$t('userInfo.bankName')"
v-model="userStore.userAccount.bankName"
/>
</v-col>
<v-col>
<v-text-field
:label="$t('userInfo.iban')"
v-model="userStore.userAccount.iban"
/>
</v-col>
</v-row>
</v-container> </v-container>
<template #actions> <template #actions>

View File

@@ -0,0 +1,37 @@
<script setup lang="ts">
import cardView from '@/components/cardView.vue';
import confirmDialog from '@/components/confirmDialog.vue';
import { ref } from 'vue';
const showConfirmDialog = ref(false)
function deleteAccount() {
// todo
}
</script>
<template>
<card-view :title="$t('account.managingAccount')">
<v-container>
<v-row>
<v-col class="d-flex justify-center align-center">
<v-btn
prepend-icon="mdi-delete"
variant="outlined"
color="red"
@click="showConfirmDialog = true"
>
{{ $t("account.delete") }}
</v-btn>
</v-col>
</v-row>
</v-container>
</card-view>
<confirm-dialog
v-model="showConfirmDialog"
:title="$t('dialog.deleteAccount.title')"
:description="$t('dialog.deleteAccount.description')"
:onConfirm="deleteAccount"
/>
</template>

View File

@@ -1,6 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import alertBanner from '@/components/alertBanner.vue'; import alertBanner from '@/components/alertBanner.vue';
import accountDataCard from './accountDataCard.vue'; import accountDataCard from './accountDataCard.vue';
import accountManagingCard from './accountManagingCard.vue';
</script> </script>
<template> <template>
@@ -16,5 +17,11 @@ import accountDataCard from './accountDataCard.vue';
<account-data-card /> <account-data-card />
</v-col> </v-col>
</v-row> </v-row>
<v-row>
<v-col>
<account-managing-card />
</v-col>
</v-row>
</v-container> </v-container>
</template> </template>

View File

@@ -3,8 +3,13 @@ import { useBasketStore } from '@/data/stores/basketStore';
import productsTable from './productsTable.vue'; import productsTable from './productsTable.vue';
import alertBanner from '@/components/alertBanner.vue'; import alertBanner from '@/components/alertBanner.vue';
import cardView from '@/components/cardView.vue'; import cardView from '@/components/cardView.vue';
import { useUserStore } from '@/data/stores/userStore';
import orderingDialog from './orderingDialog.vue';
import { ref } from 'vue';
const basketStore = useBasketStore() const basketStore = useBasketStore()
const userStore = useUserStore()
const showOrderingDialog = ref()
</script> </script>
<template> <template>
@@ -41,9 +46,10 @@ const basketStore = useBasketStore()
<template #actions> <template #actions>
<v-btn <v-btn
prepend-icon="mdi-basket-check" prepend-icon="mdi-basket-check"
:disabled="basketStore.itemsInBasket.length == 0" :disabled="basketStore.itemsInBasket.length == 0 || userStore.userAccount.id == null"
variant="outlined" variant="outlined"
color="green" color="green"
@click="showOrderingDialog = true"
> >
{{ $t('orderNow') }} {{ $t('orderNow') }}
</v-btn> </v-btn>
@@ -52,4 +58,6 @@ const basketStore = useBasketStore()
</v-col> </v-col>
</v-row> </v-row>
</v-container> </v-container>
<ordering-dialog v-model="showOrderingDialog" />
</template> </template>

View File

@@ -1,8 +1,9 @@
<script setup lang="ts"> <script setup lang="ts">
import actionDialog from '@/components/actionDialog.vue';
</script> </script>
<template> <template>
<v-dialog :title="$t('ordering.ordering')"> <action-dialog
:title="$t('ordering.ordering')"
</v-dialog> />
</template> </template>

View File

@@ -1,7 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { BasketItemModel } from '@/data/models/basketItemModel'; import { BasketItemModel } from '@/data/models/basketItemModel';
import { useBasketStore } from '@/data/stores/basketStore'; import { useBasketStore } from '@/data/stores/basketStore';
import { calcPrice, calcProductPrice } from '@/scripts/productScripts'; import { calcPrice } from '@/scripts/productScripts';
const basketStore = useBasketStore() const basketStore = useBasketStore()
@@ -84,7 +84,13 @@ function editQuantity(basketItem: BasketItemModel) {
</td> </td>
<td> <td>
<v-btn icon="mdi-delete" flat @click="removeFromBasket(basketItem)" color="red" variant="text"/> <v-btn
icon="mdi-delete"
@click="removeFromBasket(basketItem)"
color="red"
variant="text"
flat
/>
</td> </td>
</tr> </tr>
</tbody> </tbody>

View File

@@ -1,5 +1,4 @@
<script setup lang="ts"> <script setup lang="ts">
import { Ref, ref } from 'vue';
import pageSetup from './pageSetup.vue'; import pageSetup from './pageSetup.vue';
import systemSetup from './systemSetup.vue'; import systemSetup from './systemSetup.vue';
import alertBanner from '@/components/alertBanner.vue'; import alertBanner from '@/components/alertBanner.vue';

View File

@@ -5,9 +5,10 @@ import axios from 'axios';
import cardView from '@/components/cardView.vue'; import cardView from '@/components/cardView.vue';
import actionDialog from '@/components/actionDialog.vue'; import actionDialog from '@/components/actionDialog.vue';
import { ref } from 'vue'; import { ref } from 'vue';
import confirmDialog from '@/components/confirmDialog.vue';
const feedbackStore = useFeedbackStore() const feedbackStore = useFeedbackStore()
const confirmDialog = ref(false) const showConfirmDialog = ref(false)
function resetDb() { function resetDb() {
axios.get("http://127.0.0.1:3000/api/resetdatabase") axios.get("http://127.0.0.1:3000/api/resetdatabase")
@@ -31,12 +32,22 @@ function resetSettings() {
<v-container> <v-container>
<v-row> <v-row>
<v-col class="d-flex justify-center align-center"> <v-col class="d-flex justify-center align-center">
<v-btn @click="confirmDialog = true" color="primary" prepend-icon="mdi-database-refresh"> <v-btn
@click="showConfirmDialog = true"
prepend-icon="mdi-database-refresh"
color="red"
variant="outlined"
>
{{ $t('preferences.resetDatabase') }} {{ $t('preferences.resetDatabase') }}
</v-btn> </v-btn>
</v-col> </v-col>
<v-col class="d-flex justify-center align-center"> <v-col class="d-flex justify-center align-center">
<v-btn @click="resetDb" color="primary" prepend-icon="mdi-cog-counterclockwise"> <v-btn
@click="resetDb"
prepend-icon="mdi-cog-counterclockwise"
color="primary"
variant="outlined"
>
{{ $t('preferences.resetPreferences') }} {{ $t('preferences.resetPreferences') }}
</v-btn> </v-btn>
</v-col> </v-col>
@@ -44,12 +55,9 @@ function resetSettings() {
</v-container> </v-container>
</card-view> </card-view>
<action-dialog :title="$t('preferences.resetConfirm')" v-model="confirmDialog" width="600"> <confirm-dialog
<template #actions> :title="$t('dialog.resetConfirm.title')"
<v-btn variant="outlined" @click="resetDb" color="red"> :description="$t('dialog.resetConfirm.description')"
{{ $t('preferences.resetDatabase') }} v-model="showConfirmDialog"
</v-btn> />
</template>
</action-dialog>
</template> </template>

View File

@@ -5,7 +5,7 @@ import english from './../locales/en.json'
type MessageSchema = typeof german type MessageSchema = typeof german
export const i18n = createI18n<[MessageSchema], 'de' | 'en'>({ export const i18n = createI18n<[MessageSchema], 'de' | 'en'>({
legacy: false, legacy: true,
locale: 'de', locale: 'de',
messages: { messages: {
'de': german, 'de': german,