From d6bb32a860c7e2128dfaf17099ac838163f68c8f Mon Sep 17 00:00:00 2001 From: JorisParee Date: Tue, 25 Jul 2023 20:09:52 +0200 Subject: [PATCH 01/32] Create new profile view contains one empty card for change pin --- src/components/TopNavbar.vue | 1 + src/locales/en.json | 4 ++++ src/router/index.ts | 7 +++++++ src/views/ProfileView.vue | 22 ++++++++++++++++++++++ 4 files changed, 34 insertions(+) create mode 100644 src/views/ProfileView.vue diff --git a/src/components/TopNavbar.vue b/src/components/TopNavbar.vue index 2bda1c43..7bdb3051 100644 --- a/src/components/TopNavbar.vue +++ b/src/components/TopNavbar.vue @@ -95,6 +95,7 @@ const rightItems = ref([ items: [ { label: 'Profile', + to: 'profile', }, { label: 'Sign Out' diff --git a/src/locales/en.json b/src/locales/en.json index 7e427203..097cb2ed 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -20,5 +20,9 @@ "Reset the password for": "Reset the password for {email}", "Passwords not equal": "Passwords are not equal", "Password not strong": "Password needs to be longer than 8 characters and needs a lower- and uppercase letter, number and a special character" + }, + "profile": { + "my profile": "My profile", + "change pin code": "Change pin code" } } diff --git a/src/router/index.ts b/src/router/index.ts index 8336826d..63dddc37 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -5,6 +5,7 @@ import HomeView from '../views/HomeView.vue'; import LoginView from "@/views/LoginView.vue"; import BalanceView from "@/views/BalanceView.vue"; import {useAuthStore} from "@sudosos/sudosos-frontend-common"; +import ProfileView from "@/views/ProfileView.vue"; const router = createRouter({ history: createWebHistory(), @@ -35,6 +36,12 @@ const router = createRouter({ component: BalanceView, name: 'balance', } + , + { + path: '/profile', + component: ProfileView, + name: 'profile', + } // Add other routes for authenticated users here ], }, diff --git a/src/views/ProfileView.vue b/src/views/ProfileView.vue new file mode 100644 index 00000000..19da14d3 --- /dev/null +++ b/src/views/ProfileView.vue @@ -0,0 +1,22 @@ + + + + + \ No newline at end of file From 5c2ece76365785662995a12e2fd329a8ed13f88d Mon Sep 17 00:00:00 2001 From: JorisParee Date: Wed, 26 Jul 2023 18:59:13 +0200 Subject: [PATCH 02/32] added input fields and validation for pin change --- src/components/PinComponent.vue | 14 ++++++++ src/locales/en.json | 4 ++- src/views/BalanceView.vue | 2 +- src/views/ProfileView.vue | 59 ++++++++++++++++++++++++++++++--- 4 files changed, 72 insertions(+), 7 deletions(-) create mode 100644 src/components/PinComponent.vue diff --git a/src/components/PinComponent.vue b/src/components/PinComponent.vue new file mode 100644 index 00000000..1943e640 --- /dev/null +++ b/src/components/PinComponent.vue @@ -0,0 +1,14 @@ + + + + \ No newline at end of file diff --git a/src/locales/en.json b/src/locales/en.json index 097cb2ed..2807baa5 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -23,6 +23,8 @@ }, "profile": { "my profile": "My profile", - "change pin code": "Change pin code" + "change pin code": "Change pin code", + "new pin code": "New pin code", + "confirm new pin code": "Confirm new pin code" } } diff --git a/src/views/BalanceView.vue b/src/views/BalanceView.vue index bd265162..05b4ed42 100644 --- a/src/views/BalanceView.vue +++ b/src/views/BalanceView.vue @@ -3,7 +3,7 @@
Balance
- +

It is no longer possible to increase your balance in cash during the 'borrel'

Balance increase amount:

diff --git a/src/views/ProfileView.vue b/src/views/ProfileView.vue index 19da14d3..9ae694b9 100644 --- a/src/views/ProfileView.vue +++ b/src/views/ProfileView.vue @@ -1,22 +1,71 @@ - \ No newline at end of file From 41a648eb30b69b4ec05deff96eef570a23fe10f9 Mon Sep 17 00:00:00 2001 From: JorisParee Date: Thu, 27 Jul 2023 15:37:09 +0200 Subject: [PATCH 03/32] make the update pin work --- src/locales/en.json | 4 +++- src/main.ts | 4 ++++ src/views/ProfileView.vue | 21 ++++++++++++++++++++- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/locales/en.json b/src/locales/en.json index 2807baa5..27473449 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -25,6 +25,8 @@ "my profile": "My profile", "change pin code": "Change pin code", "new pin code": "New pin code", - "confirm new pin code": "Confirm new pin code" + "confirm new pin code": "Confirm new pin code", + "pin update successful": "pin updated successful", + "success": "success" } } diff --git a/src/main.ts b/src/main.ts index 357e06a6..d60cf39c 100644 --- a/src/main.ts +++ b/src/main.ts @@ -17,8 +17,11 @@ import InputNumber from "primevue/inputnumber"; import Dialog from "primevue/dialog"; import 'primeicons/primeicons.css'; import languages from "@/locales"; +import Toast from "primevue/toast"; +import ToastService from 'primevue/toastservice' const app = createApp(App) +app.use(ToastService) const messages = Object.assign(languages); const i18n = createI18n({ @@ -38,5 +41,6 @@ app.component('Panel', Panel); app.component('DataTable', DataTable); app.component('InputNumber', InputNumber); app.component('Dialog', Dialog); +app.component('Toast', Toast); app.mount('#app') diff --git a/src/views/ProfileView.vue b/src/views/ProfileView.vue index 9ae694b9..9649a3c4 100644 --- a/src/views/ProfileView.vue +++ b/src/views/ProfileView.vue @@ -1,5 +1,7 @@ @@ -29,51 +30,44 @@ import PinComponent from "@/components/PinComponent.vue"; import {useAuthStore} from "@sudosos/sudosos-frontend-common"; import apiService from "@/services/ApiService"; import {useToast} from "primevue/usetoast"; +import { useField } from 'vee-validate'; +const { value: inputPin, errorMessage: inputPinError } = useField('inputPin', validatePin); +const { value: confirmPin, errorMessage: confirmPinError} = useField('confirmPin', validateConfirmPin); -const inputPin = ref(); -const inputPinWarning = ref(""); - -const confirmPin = ref(); -const confirmPinWarning = ref(""); //show warning message if pin is filled in and not 4 digits -watch(inputPin, (pin) => { - if (pin.length == 0) { - inputPinWarning.value = ""; - } else if (! RegExp('\\d{4}').test(pin)) { - inputPinWarning.value = "your pin needs to have 4 digits"; - } else { - inputPinWarning.value = ""; +function validatePin(checkInputPin: string){ + if (checkInputPin.length != 4 && !RegExp('\\d{4}').test(checkInputPin)) { + return "your pin needs to have 4 digits"; } -}) + return true; +} //show warning message if conformation pin does not fit pin -watch(confirmPin, (pin) => { - if (pin.length == 0){ - confirmPinWarning.value = "" - } else if (pin != inputPin.value) { - confirmPinWarning.value = "both pins need to be the same"; - } else { - confirmPinWarning.value = ""; +function validateConfirmPin(checkConfirmPin: string){ + if (checkConfirmPin != inputPin.value) { + return "both pins need to be the same"; } -}) + return true; +} const authStore = useAuthStore(); const toast = useToast(); const changePinCode = () => { - if (RegExp('\\d{4}').test(inputPin.value) && inputPin.value == confirmPin.value) { + if (inputPin.value.length == 4 && RegExp('\\d{4}').test(inputPin.value) && inputPin.value == confirmPin.value) { authStore.updateUserPin(inputPin.value, apiService).then(() => { // Succes! inputPin.value=""; confirmPin.value=""; toast.add({severity: "success", summary: "success", detail: 'pin updated successful' }) - //TODO show succes message }).catch((err) => { // Error console.error(err); }) + } else { + toast.add({severity: "error", summary: "failed", detail: 'fill in correct pin codes', life: 3000}) } } From c53d150ebc80bafa9e9392e293a02fc3bdca732c Mon Sep 17 00:00:00 2001 From: JorisParee Date: Sat, 29 Jul 2023 15:34:26 +0200 Subject: [PATCH 05/32] made the change password card --- src/main.ts | 2 ++ src/views/ProfileView.vue | 54 +++++++++++++++++++++++++++++++++++---- 2 files changed, 51 insertions(+), 5 deletions(-) diff --git a/src/main.ts b/src/main.ts index d60cf39c..34f92b8d 100644 --- a/src/main.ts +++ b/src/main.ts @@ -19,6 +19,7 @@ import 'primeicons/primeicons.css'; import languages from "@/locales"; import Toast from "primevue/toast"; import ToastService from 'primevue/toastservice' +import Password from "primevue/password"; const app = createApp(App) app.use(ToastService) @@ -42,5 +43,6 @@ app.component('DataTable', DataTable); app.component('InputNumber', InputNumber); app.component('Dialog', Dialog); app.component('Toast', Toast); +app.component('Password', Password); app.mount('#app') diff --git a/src/views/ProfileView.vue b/src/views/ProfileView.vue index 7f1a4a61..3e88d44e 100644 --- a/src/views/ProfileView.vue +++ b/src/views/ProfileView.vue @@ -19,6 +19,21 @@
+ +
+
+

Password

+ + {{inputPasswordError || ' '}} +
+
+

Confirm password

+ + {{confirmPasswordError || ' '}} +
+
+
+
@@ -32,10 +47,13 @@ import apiService from "@/services/ApiService"; import {useToast} from "primevue/usetoast"; import { useField } from 'vee-validate'; +const authStore = useAuthStore(); +const toast = useToast(); + + const { value: inputPin, errorMessage: inputPinError } = useField('inputPin', validatePin); const { value: confirmPin, errorMessage: confirmPinError} = useField('confirmPin', validateConfirmPin); - //show warning message if pin is filled in and not 4 digits function validatePin(checkInputPin: string){ if (checkInputPin.length != 4 && !RegExp('\\d{4}').test(checkInputPin)) { @@ -53,10 +71,8 @@ function validateConfirmPin(checkConfirmPin: string){ } -const authStore = useAuthStore(); -const toast = useToast(); -const changePinCode = () => { - if (inputPin.value.length == 4 && RegExp('\\d{4}').test(inputPin.value) && inputPin.value == confirmPin.value) { +function changePinCode() { + if (validatePin(inputPin.value) == true && validateConfirmPin(confirmPin.value) == true) { authStore.updateUserPin(inputPin.value, apiService).then(() => { // Succes! inputPin.value=""; @@ -71,6 +87,34 @@ const changePinCode = () => { } } +const { value: inputPassword, errorMessage: inputPasswordError} = useField('inputPassword', validatePassword); +const { value: confirmPassword, errorMessage: confirmPasswordError} = useField('confirmPassword', validateConfirmPassword); + +function validatePassword(checkPassword: string) { + if (checkPassword.length <12) { + //TODO set password requirements + return "length should be at least 12" + } + return true; +} + +function validateConfirmPassword(checkConfirmPassword: string) { + if (checkConfirmPassword != inputPassword.value) { + return "Both passwords should match" + } + return true; +} + +function changePassword() { + if (validatePassword(inputPassword.value) == true && validateConfirmPassword(confirmPassword.value) == true) { + //authStore.updateUserPassword() + } else { + toast.add({severity: "error", summary: "failed", detail: 'fill in correct passwords', life: 3000}) + } +} + + + \ No newline at end of file diff --git a/src/components/ChangePasswordComponent.vue b/src/components/ChangePasswordComponent.vue new file mode 100644 index 00000000..74175529 --- /dev/null +++ b/src/components/ChangePasswordComponent.vue @@ -0,0 +1,65 @@ + + + + + \ No newline at end of file diff --git a/src/components/ChangePinComponent.vue b/src/components/ChangePinComponent.vue new file mode 100644 index 00000000..5ec9be11 --- /dev/null +++ b/src/components/ChangePinComponent.vue @@ -0,0 +1,70 @@ + + + + + \ No newline at end of file diff --git a/src/views/ProfileView.vue b/src/views/ProfileView.vue index 3e88d44e..6de750ea 100644 --- a/src/views/ProfileView.vue +++ b/src/views/ProfileView.vue @@ -1,118 +1,24 @@ - - From 9681b1903b1a07ceb887209efabe68adffd725d3 Mon Sep 17 00:00:00 2001 From: JorisParee Date: Thu, 3 Aug 2023 00:21:53 +0200 Subject: [PATCH 07/32] put em in a grid --- src/views/ProfileView.vue | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/views/ProfileView.vue b/src/views/ProfileView.vue index 6de750ea..a6ee8e17 100644 --- a/src/views/ProfileView.vue +++ b/src/views/ProfileView.vue @@ -3,12 +3,14 @@
{{ $t('profile.my profile')}}
- +
+ - + - + +
@@ -19,6 +21,7 @@ import ChangePasswordComponent from "@/components/ChangePasswordComponent.vue"; import ChangePinComponent from "@/components/ChangePinComponent.vue"; import ChangeApiKeyComponent from "@/components/ChangeApiKeyComponent.vue"; +import CardComponent from "@/components/CardComponent.vue"; @@ -31,4 +34,14 @@ import ChangeApiKeyComponent from "@/components/ChangeApiKeyComponent.vue"; font-size: 75%; } + + +.container { + display: grid; + grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); + gap: 10px; /* Reduce the gap value to 10px */ + padding-bottom: 20px; /* Add bottom padding to prevent the last row from being cut off */ + padding-right: 50px; +} + \ No newline at end of file From f016267e23d70dad26c9cba659281dc312f19bac Mon Sep 17 00:00:00 2001 From: JorisParee Date: Tue, 17 Oct 2023 20:04:26 +0200 Subject: [PATCH 08/32] fix changes from pulling main --- src/components/ChangePinComponent.vue | 17 +++++++++-------- src/components/TopNavbar.vue | 1 + src/main.ts | 8 ++++++-- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/components/ChangePinComponent.vue b/src/components/ChangePinComponent.vue index 5ec9be11..90967aa0 100644 --- a/src/components/ChangePinComponent.vue +++ b/src/components/ChangePinComponent.vue @@ -1,16 +1,16 @@ diff --git a/src/components/ChangePasswordComponent.vue b/src/components/ChangePasswordComponent.vue index 74175529..c990e268 100644 --- a/src/components/ChangePasswordComponent.vue +++ b/src/components/ChangePasswordComponent.vue @@ -1,28 +1,36 @@