From 282695ffe39066c970c143ab4caf919edb6a0f84 Mon Sep 17 00:00:00 2001 From: Robin van Dijke Date: Wed, 4 Sep 2024 20:27:14 +0200 Subject: [PATCH] refactor(dashboard/user): profile view (#320) * feat(dashboard/profile-view): started work on concept of user settings component * feat(dashboard/user): Finalized outer look of user settings card feat(dashboard/user): added change pin dialog to user settings card * refactor(dashboard/user): removed change pin component * feat(dashboard/user): added change pin form * feat(dashboard/components): added FormSection component feat(dashboard/user-profile): removed dialog for changing pin, added form section for changing pin * feat(dashboard/profile-view): created ChangePasswordForm * feat(dashboard/profile-view): added password change dialog * feat(dashboard/profile-view): added delete api key and change api key links and confirmation dialogs * feat(dashboard/profile-view): added extensive data processing logic to user settings component * feat(dashboard/profile-view): added translations * feat(dashboard/profile-view): added user info to profile view * fix(dashboard/user-profile-view): max length for pincode showing dollar sign fix(dashboard/user-profile-view): cursor not showing pointer on change api key and change password buttons * feat(common/userstore): Added fetchGewisUser method * fix(dashboard/user-profile-view): type-check errors --- apps/dashboard/.eslintrc.cjs | 1 + apps/dashboard/src/components/FormSection.vue | 77 +++++++++ apps/dashboard/src/components/InputSpan.vue | 18 +- apps/dashboard/src/locales/en.json | 31 +++- apps/dashboard/src/locales/nl.json | 31 +++- .../src/modules/user/components/ChangePin.vue | 66 ------- .../user/components/UserSettingsComponent.vue | 162 ++++++++++++++++++ .../components/forms/ChangePasswordForm.vue | 74 ++++++++ .../user/components/forms/ChangePinForm.vue | 77 +++++++++ .../modules/user/views/UserProfileView.vue | 41 ++--- apps/dashboard/src/utils/validation-schema.ts | 10 +- lib/common/src/stores/user.store.ts | 8 +- 12 files changed, 479 insertions(+), 117 deletions(-) create mode 100644 apps/dashboard/src/components/FormSection.vue delete mode 100644 apps/dashboard/src/modules/user/components/ChangePin.vue create mode 100644 apps/dashboard/src/modules/user/components/UserSettingsComponent.vue create mode 100644 apps/dashboard/src/modules/user/components/forms/ChangePasswordForm.vue create mode 100644 apps/dashboard/src/modules/user/components/forms/ChangePinForm.vue diff --git a/apps/dashboard/.eslintrc.cjs b/apps/dashboard/.eslintrc.cjs index 05c45212..263fb743 100644 --- a/apps/dashboard/.eslintrc.cjs +++ b/apps/dashboard/.eslintrc.cjs @@ -16,6 +16,7 @@ module.exports = { '@typescript-eslint/no-unused-vars': 'off', 'vue/multi-word-component-names': 'off', 'vue/no-reserved-component-names': 'off', + 'no-console': 'error', }, } ], diff --git a/apps/dashboard/src/components/FormSection.vue b/apps/dashboard/src/components/FormSection.vue new file mode 100644 index 00000000..4366efa2 --- /dev/null +++ b/apps/dashboard/src/components/FormSection.vue @@ -0,0 +1,77 @@ + + + + + diff --git a/apps/dashboard/src/components/InputSpan.vue b/apps/dashboard/src/components/InputSpan.vue index b08e1e1d..7f498fca 100644 --- a/apps/dashboard/src/components/InputSpan.vue +++ b/apps/dashboard/src/components/InputSpan.vue @@ -46,6 +46,22 @@ v-model="internalValue as number" :placeholder="placeholder" :disabled="disabled"/> + + +
@@ -105,7 +121,7 @@ const props = defineProps({ const emit = defineEmits(['update:value']); -const stringInputs = ['text', 'textarea']; +const stringInputs = ['text', 'textarea', 'pin', 'password']; const numberInputs = ['currency', 'number', 'usertype', 'percentage']; const booleanInputs = ['boolean']; diff --git a/apps/dashboard/src/locales/en.json b/apps/dashboard/src/locales/en.json index e8338cb0..e9ccf7c0 100644 --- a/apps/dashboard/src/locales/en.json +++ b/apps/dashboard/src/locales/en.json @@ -244,7 +244,8 @@ "pinChange": "Change pin code", "pinConfirm": "Confirm new pin code", "pinNew": "New pin code", - "updateInfo": "Update user information" + "updateInfo": "Update user information", + "passwordNew": "New password" }, "quickOverview": { "quickOverviewMessage": "Show this at the bar so we can help you faster", @@ -277,7 +278,12 @@ "waiveFinesSuccess": "Successfully waived fines.", "waiveFinesRejected": "Canceled waiving fines.", "canceled": "Canceled", - "userUpdated": "Successfully updated user." + "userUpdated": "Successfully updated user.", + "pinUpdated": "Successfully updated pin.", + "dataAnalysisChanged": "Successfully changed data analysis preference.", + "apiKeyChanged": "Successfully changed API key.", + "apiKeyDeleted": "Successfully deleted API key.", + "passwordUpdated": "Successfully changed password." }, "termsOfService": { "acceptFirst": "Accept the Terms of Service", @@ -329,6 +335,19 @@ "userInfoUpdated": "User information successfully updated", "userInformation": "User information" }, + "userSettings": { + "userSettings": "User settings", + "changeCredentials": "Change credentials", + "changePin": "Change pin", + "changePassword": "Change password", + "apiKeys": "API keys", + "changeApiKey": "Change API key", + "deleteApiKey": "Delete API key", + "preferences": "Preferences", + "dataAnalysis": "Extensive Data Analysis", + "confirmChangeApiKey": "Are you sure you want to change your API key? This cannot be undone!", + "confirmDeleteApiKey": "Are you sure you want to delete your API key? This cannot be undone!" + }, "contact": { "Contact": "Contact", "Main contact": "Main contact", @@ -342,7 +361,7 @@ }, "validation": { "number": { - "min": "This field must be greater than ${min}" + "min": "This field must be greater than {min}" }, "password": { "match": "Passwords must match." @@ -353,9 +372,9 @@ }, "required": "This field is required", "string": { - "exact": "This field must be exactly ${len} characters", - "max": "This field can't be greater than ${max} characters", - "min": "This field must be at least ${min} characters" + "exact": "This field must be exactly {len} characters", + "max": "This field can't be greater than {max} characters", + "min": "This field must be at least {min} characters" } }, "tooltip": { diff --git a/apps/dashboard/src/locales/nl.json b/apps/dashboard/src/locales/nl.json index a0148bd2..877b52f2 100644 --- a/apps/dashboard/src/locales/nl.json +++ b/apps/dashboard/src/locales/nl.json @@ -249,7 +249,8 @@ "pinChange": "Verander PIN code", "pinConfirm": "Bevestig nieuwe PIN code", "pinNew": "Nieuwe PIN code", - "updateInfo": "Update gebruikersinformatie" + "updateInfo": "Update gebruikersinformatie", + "passwordNew": "Nieuw wachtwoord" }, "quickOverview": { "quickOverviewMessage": "Laat dit aan de bar zien zodat we je sneller kunnen helpen.", @@ -278,7 +279,12 @@ "waiveFinesSuccess": "Boetes zijn succesvol kwijtgescholden.", "waiveFinesRejected": "Boetes zijn succesvol afgewezen.", "canceled": "Geannuleerd", - "userUpdated": "Gebruiker is succesvol geüpdatet." + "userUpdated": "Gebruiker is succesvol geüpdatet.", + "pinUpdated": "Pincode is succesvol geüpdatet.", + "dataAnalysisChanged": "Extensieve dataverwerking is succesvol gewijzigd.", + "apiKeyChanged": "API-sleutel is succesvol gewijzigd.", + "apiKeyDeleted": "API-sleutel is succesvol verwijderd.", + "passwordUpdated": "Wachtwoord is succesvol gewijzigd." }, "termsOfService": { "acceptFirst": "Accepteer de Voorwaarden", @@ -330,9 +336,22 @@ "userInfoUpdated": "Profiel is succesvol aangepast", "userInformation": "Gebruikersinformatie" }, + "userSettings": { + "userSettings": "Gebruikersinstellingen", + "changeCredentials": "Wijzig inloggegevens", + "changePin": "Wijzig pincode", + "changePassword": "Wijzig wachtwoord", + "apiKeys": "API-sleutels", + "changeApiKey": "Wijzig API-sleutel", + "deleteApiKey": "Verwijder API-sleutel", + "preferences": "Voorkeuren", + "dataAnalysis": "Uitgebreide Data Analyse", + "confirmChangeApiKey": "Weet je zeker dat je de API-sleutel wilt wijzigen? Dit kan niet ongedaan worden gemaakt!", + "confirmDeleteApiKey": "Weet je zeker dat je de API-sleutel wilt verwijderen? Dit kan niet ongedaan worden gemaakt!" + }, "validation": { "number": { - "min": "Dit veld moet groter zijn dan ${min}" + "min": "Dit veld moet groter zijn dan {min}" }, "password": { "match": "Wachtwoorden moeten overeenkomen." @@ -343,9 +362,9 @@ }, "required": "Dit veld is verplicht", "string": { - "exact": "Dit veld moet precies ${len} tekens bevatten.", - "max": "Dit veld mag maximaal ${max} tekens bevatten.", - "min": "Dit veld moet minimaal ${min} tekens bevatten." + "exact": "Dit veld moet precies {len} tekens bevatten.", + "max": "Dit veld mag maximaal {max} tekens bevatten.", + "min": "Dit veld moet minimaal {min} tekens bevatten." } }, "tooltip": { diff --git a/apps/dashboard/src/modules/user/components/ChangePin.vue b/apps/dashboard/src/modules/user/components/ChangePin.vue deleted file mode 100644 index 9185e793..00000000 --- a/apps/dashboard/src/modules/user/components/ChangePin.vue +++ /dev/null @@ -1,66 +0,0 @@ - - - - - diff --git a/apps/dashboard/src/modules/user/components/UserSettingsComponent.vue b/apps/dashboard/src/modules/user/components/UserSettingsComponent.vue new file mode 100644 index 00000000..180ea167 --- /dev/null +++ b/apps/dashboard/src/modules/user/components/UserSettingsComponent.vue @@ -0,0 +1,162 @@ + + + + + diff --git a/apps/dashboard/src/modules/user/components/forms/ChangePasswordForm.vue b/apps/dashboard/src/modules/user/components/forms/ChangePasswordForm.vue new file mode 100644 index 00000000..2297e6c0 --- /dev/null +++ b/apps/dashboard/src/modules/user/components/forms/ChangePasswordForm.vue @@ -0,0 +1,74 @@ + + + + + diff --git a/apps/dashboard/src/modules/user/components/forms/ChangePinForm.vue b/apps/dashboard/src/modules/user/components/forms/ChangePinForm.vue new file mode 100644 index 00000000..c8a64fa8 --- /dev/null +++ b/apps/dashboard/src/modules/user/components/forms/ChangePinForm.vue @@ -0,0 +1,77 @@ + + + + + diff --git a/apps/dashboard/src/modules/user/views/UserProfileView.vue b/apps/dashboard/src/modules/user/views/UserProfileView.vue index fe2f959a..b146118e 100644 --- a/apps/dashboard/src/modules/user/views/UserProfileView.vue +++ b/apps/dashboard/src/modules/user/views/UserProfileView.vue @@ -1,51 +1,31 @@