Add dialog to create new user

This commit is contained in:
2024-09-10 18:50:47 +02:00
parent c9a80a0a74
commit 628d1e7bee
10 changed files with 171 additions and 62 deletions

View File

@@ -29,7 +29,7 @@ i18n.global.locale = userStore.language
<div v-if="!navRail">{{ $t('menu.shopping') }}</div> <div v-if="!navRail">{{ $t('menu.shopping') }}</div>
<div v-else></div> <div v-else></div>
</v-list-subheader> </v-list-subheader>
<v-list-item :title="$t('menu.products')" prepend-icon="mdi-store" to="/products" link /> <v-list-item :title="$t('menu.products')" prepend-icon="mdi-store" to="/" link />
<v-list-item :title="$t('menu.basket')" to="/basket" link > <v-list-item :title="$t('menu.basket')" to="/basket" link >
<template v-slot:prepend> <template v-slot:prepend>
<v-badge color="primary" :content="basketStore.itemsInBasket.length"> <v-badge color="primary" :content="basketStore.itemsInBasket.length">

View File

@@ -0,0 +1,30 @@
<script setup lang="ts">
import { ModelRef } from 'vue';
const showDialog: ModelRef<boolean> = defineModel()
defineProps({
title: String,
subtitle: String,
imageUrl: {
type: String,
default: ""
}
})
</script>
<template>
<v-dialog max-width="800" v-model="showDialog">
<v-card :title="title" >
<v-img v-if="imageUrl != ''" :src="imageUrl" max-height="300" />
<v-card-text>
<slot name="content"></slot>
</v-card-text>
<v-card-actions>
<slot name="actions"></slot>
</v-card-actions>
</v-card>
</v-dialog>
</template>

View File

@@ -36,5 +36,14 @@
"username": "Username", "username": "Username",
"password": "Password", "password": "Password",
"login": "Login", "login": "Login",
"noAccountRegister": "No Account? Register now!" "noAccountRegister": "No Account? Register now!",
"register": "Create Account",
"userInfo": {
"firstName": "First Name",
"lastName": "Family Name",
"street": "Street",
"houseNumber": "House Number",
"postalCode": "Postal Code",
"city": "City"
}
} }

View File

@@ -36,5 +36,14 @@
"username": "Username", "username": "Username",
"password": "Passwort", "password": "Passwort",
"login": "Login", "login": "Login",
"noAccountRegister": "Noch keinen Account? Jetzt anmelden!" "noAccountRegister": "Noch keinen Account? Jetzt anmelden!",
"register": "Account erstellen",
"userInfo": {
"firstName": "Vorname",
"lastName": "Nachname",
"street": "Straße",
"houseNumber": "Hausnummer",
"postalCode": "Postleitzahl",
"city": "Stadt"
}
} }

View File

@@ -0,0 +1,6 @@
<script setup lang="ts">
</script>
<template>
Help
</template>

View File

@@ -1,14 +1,19 @@
<script setup lang="ts"> <script setup lang="ts">
import LoginForm from './loginForm.vue'; import { ref } from 'vue';
import loginForm from './loginForm.vue';
import registerForm from './registerForm.vue';
const showRegisterDialog = ref(false)
</script> </script>
<template> <template>
<v-container max-width="600"> <v-container max-width="600">
<v-row> <v-row>
<v-col> <v-col>
<login-form /> <login-form v-model:show-register-dialog="showRegisterDialog" />
</v-col> </v-col>
</v-row> </v-row>
</v-container> </v-container>
<register-form v-model:show-register-dialog="showRegisterDialog" />
</template> </template>

View File

@@ -1,4 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
const showRegisterDialog = defineModel("showRegisterDialog", { type: Boolean, default: false })
</script> </script>
<template> <template>
@@ -25,14 +26,9 @@
</v-container> </v-container>
<v-card-text class="text-center"> <v-card-text class="text-center">
<a <v-btn flat append-icon="mdi-chevron-right" @click="showRegisterDialog = true">
class="text-secondary text-decoration-none" {{ $t('noAccountRegister') }}
href="#" </v-btn>
rel="noopener noreferrer"
target="_blank"
>
{{ $t('noAccountRegister') }} <v-icon icon="mdi-chevron-right"/>
</a>
</v-card-text> </v-card-text>
</v-card> </v-card>
</template> </template>

View File

@@ -0,0 +1,54 @@
<script setup lang="ts">
import actionDialog from '@/components/actionDialog.vue';
const showRegisterDialog = defineModel("showRegisterDialog", { type: Boolean, required: true })
</script>
<template>
<action-dialog v-model="showRegisterDialog" :title="$t('register')">
<template #content>
<v-row>
<v-col>
<v-text-field :label="$t('username')" prepend-icon="mdi-account" clearable />
</v-col>
<v-col>
<v-text-field :label="$t('password')" prepend-icon="mdi-key" type="password" clearable />
</v-col>
</v-row>
<v-row>
<v-col>
<v-text-field :label="$t('userInfo.firstName')" prepend-icon="mdi-card-account-details" clearable />
</v-col>
<v-col>
<v-text-field :label="$t('userInfo.lastName')" clearable />
</v-col>
</v-row>
<v-row>
<v-col>
<v-text-field :label="$t('userInfo.street')" prepend-icon="mdi-numeric" clearable />
</v-col>
<v-col cols="4">
<v-text-field :label="$t('userInfo.houseNumber')" clearable />
</v-col>
</v-row>
<v-row>
<v-col cols="4">
<v-text-field :label="$t('userInfo.postalCode')" prepend-icon="mdi-city" clearable />
</v-col>
<v-col>
<v-text-field :label="$t('userInfo.city')" clearable />
</v-col>
</v-row>
</template>
<template #actions>
<v-btn prepend-icon="mdi-account-plus" color="primary" variant="outlined">{{ $t('register') }}</v-btn>
</template>
</action-dialog>
</template>

View File

@@ -5,6 +5,7 @@ import { CategoryModel } from '@/data/models/categoryModel';
import { ModelRef, ref } from 'vue'; import { ModelRef, ref } from 'vue';
import { useBasketStore } from '@/data/stores/basketStore'; import { useBasketStore } from '@/data/stores/basketStore';
import { calcProductPrice, productToBasketItem } from '@/scripts/productScripts'; import { calcProductPrice, productToBasketItem } from '@/scripts/productScripts';
import ActionDialog from '@/components/actionDialog.vue'
const showDialog: ModelRef<boolean> = defineModel() const showDialog: ModelRef<boolean> = defineModel()
const nrOfArticles = ref(1) const nrOfArticles = ref(1)
@@ -23,54 +24,51 @@ function addProductToBasket() {
</script> </script>
<template> <template>
<v-dialog max-width="800" v-model="showDialog"> <action-dialog
<v-card :title="product.name" :subtitle="product.brand" > :title="product.name"
<v-img :src="'http://127.0.0.1:3000/static/' + product.imageUrl" max-height="300" /> :subtitle="product.brand"
:image-url="'http://127.0.0.1:3000/static/' + product.imageUrl"
v-model="showDialog"
>
<template #content>
<v-row>
<v-col>
<v-icon :icon="productCategory.icon" />
{{ productCategory.name }}
</v-col>
</v-row>
<v-row>
<v-col>
{{ product.description }}
</v-col>
</v-row>
<v-row>
<v-col>
<v-number-input
:reverse="false"
controlVariant="default"
:label="$t('quantity')"
:hideInput="false"
:inset="false"
v-model="nrOfArticles"
:min="1"
:max="10"
density="comfortable"
/>
</v-col>
<v-card-text> <v-spacer />
<v-row>
<v-col>
<v-icon :icon="productCategory.icon" />
{{ productCategory.name }}
</v-col>
</v-row>
<v-row>
<v-col>
{{ product.description }}
</v-col>
</v-row>
<v-row>
<v-col>
<v-number-input
:reverse="false"
controlVariant="default"
:label="$t('quantity')"
:hideInput="false"
:inset="false"
v-model="nrOfArticles"
:min="1"
:max="10"
density="comfortable"
/>
</v-col>
<v-spacer /> <v-col cols="2" class="justify-center d-flex">
{{ calcProductPrice(product, nrOfArticles) }}
</v-col>
</v-row>
</template>
<v-col cols="2" class="justify-center d-flex"> <template #actions>
{{ calcProductPrice(product, nrOfArticles) }} <v-btn prepend-icon="mdi-cart-plus" @click="addProductToBasket" color="primary" variant="outlined">
</v-col> {{ $t('addToBasket') }}
</v-row> </v-btn>
</v-card-text> </template>
</action-dialog>
<v-card-actions>
<v-btn
prepend-icon="mdi-cart-plus"
@click="addProductToBasket"
>
{{ $t('addToBasket') }}
</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</template> </template>

View File

@@ -4,14 +4,16 @@ import PreferencesPage from "@/pages/preferencesPage/index.vue";
import ProductsPage from "@/pages/productsPage/index.vue"; import ProductsPage from "@/pages/productsPage/index.vue";
import LoginPage from "@/pages/loginPage/index.vue" import LoginPage from "@/pages/loginPage/index.vue"
import BasketPage from "@/pages/basketPage/index.vue" import BasketPage from "@/pages/basketPage/index.vue"
import HelpPage from "@/pages/helpPage/index.vue"
const routes = [ const routes = [
{ path: '/products', component: ProductsPage }, { path: '/', component: ProductsPage },
{ path: '/account', component: AccountPage }, { path: '/account', component: AccountPage },
{ path: '/orders', component: OrdersPage }, { path: '/orders', component: OrdersPage },
{ path: '/preferences', component: PreferencesPage }, { path: '/preferences', component: PreferencesPage },
{ path: '/login', component: LoginPage }, { path: '/login', component: LoginPage },
{ path: '/basket', component: BasketPage } { path: '/basket', component: BasketPage },
{ path: '/help', component: HelpPage }
] ]
export default routes export default routes