diff --git a/src/components/BaseComponents/NavBar.vue b/src/components/BaseComponents/NavBar.vue index 4e997eea3c0d0a65ede97fea1f7054fb52f0049d..d03b9bd8818a5661d6bd0b0053d286d280df7f43 100644 --- a/src/components/BaseComponents/NavBar.vue +++ b/src/components/BaseComponents/NavBar.vue @@ -405,6 +405,7 @@ onMounted(() => { .container-fluid { font-size: 1.7rem; + margin: 0 140px; } #logo { diff --git a/src/components/Exceptions/unkownErrorHandler.ts b/src/components/Exceptions/unkownErrorHandler.ts index e15b5b45d824f51ffc23c860ac394b80b598950f..bcb29854fbea2b0d15c4a5cb9dc32f6b367461bf 100644 --- a/src/components/Exceptions/unkownErrorHandler.ts +++ b/src/components/Exceptions/unkownErrorHandler.ts @@ -1,6 +1,7 @@ import { ApiError as BackendApiError } from '@/api'; import { AxiosError } from 'axios'; import router from '@/router' +import { useUserInfoStore } from '@/stores/UserStore' /** * Finds the correct error message for the given error @@ -14,6 +15,7 @@ const handleUnknownError = (error: any): string => { } else if (error instanceof BackendApiError) { if (error.body.status == 403) { router.push("/login"); + useUserInfoStore().clearUserInfo(); } else if (error.body.status == 401) { router.push("/roadmap"); } diff --git a/src/components/Settings/SettingsAccount.vue b/src/components/Settings/SettingsAccount.vue index e34e19a34e831e861049734f4e4a85aedbf1cd73..f29d2d5b8e8f6c6df65eee2241a48c95565ac1c7 100644 --- a/src/components/Settings/SettingsAccount.vue +++ b/src/components/Settings/SettingsAccount.vue @@ -5,10 +5,12 @@ import { useUserInfoStore } from "@/stores/UserStore"; import { UserService } from '@/api'; import type { UserUpdateDTO } from '@/api'; import handleUnknownError from '@/components/Exceptions/unkownErrorHandler'; +import router from '@/router' const emailRef = ref('') const errorMsg = ref('') const confirmationMsg = ref('') +const errorMsg2 = ref('') const handleEmailInputEvent = (newValue: any) => { emailRef.value = newValue @@ -23,14 +25,12 @@ async function setupForm() { confirmationMsg.value = ''; errorMsg.value = ''; } catch (err) { - handleUnknownError(err); - errorMsg.value = 'Error fetching email, try again!' + errorMsg.value = handleUnknownError(err); confirmationMsg.value = '' } } const handleSubmit = async () => { - console.log('Yoooo') const updateUserPayload: UserUpdateDTO = { email: emailRef.value, }; @@ -47,6 +47,18 @@ const handleSubmit = async () => { confirmationMsg.value = '' } } + +const handleSubmit2 = async () => { + try { + console.log("test") + UserService.deleteUser(); + console.log("test") + useUserInfoStore().clearUserInfo(); + await router.push("/login"); + } catch (err) { + errorMsg2.value = handleUnknownError(err); + } +} onMounted(() => { setupForm() }) @@ -54,9 +66,9 @@ onMounted(() => { <template> <div class="tab-pane active" id="account"> - <h6>KONTO INNSTILLINGER</h6> + <h6>KONTO</h6> <hr> - <form @submit.prevent="handleSubmit"> + <form @submit.prevent="handleSubmit"> <div class="form-group"> <BaseInput data-cy="email-input" :model-value="emailRef" @input-change-event="handleEmailInputEvent" id="emailInput-change" @@ -68,12 +80,14 @@ onMounted(() => { <br> <button data-cy="change-email-btn" type="submit" class="btn btn-primary classyButton">Endre Informasjon</button> - <hr> - <div class="form-group"> - <label class="d-block text-danger">Slett Bruker</label> - <p class="text-muted font-size-sm">Når du først har slettet kontoen din, er det ingen vei tilbake. Vennligst vær sikker.</p> - </div> - <button class="btn btn-danger" type="button">Slett Bruker</button> + </form> + <form @submit.prevent="handleSubmit2" style="margin-top: 20px;"> + <div class="form-group"> + <label class="d-block text-danger">Slett Bruker</label> + <p class="text-muted font-size-sm">Obs: Når du først har slettet kontoen din, er det ingen vei tilbake.</p> + </div> + <p data-cy="delete-user-msg-error" class="text-danger">{{ errorMsg2 }}</p> + <button class="btn btn-danger" type="submit">Slett Bruker</button> </form> </div> </template> diff --git a/src/components/Settings/SettingsBank.vue b/src/components/Settings/SettingsBank.vue index 481c0227bb8ffcfab6376be406514028832cae02..285ca9b9c511c2cbe1e813af2f622615dc6ae545 100644 --- a/src/components/Settings/SettingsBank.vue +++ b/src/components/Settings/SettingsBank.vue @@ -1,8 +1,8 @@ <template> <div class="tab-pane active" id="billing"> - <h6>BANKKONTO INNSTILLINGER</h6> + <h6>BANK</h6> <hr> - <form @submit.prevent="handleSpendingSubmit"> + <form @submit.prevent="handleSpendingSubmit" novalidate> <div class="form-group"> <BaseInput data-cy="spending-account-input" :model-value="spendingAccount" @input-change-event="handleSpendingInputEvent" id="firstNameInputChange" input-id="first-name-new" @@ -10,6 +10,8 @@ invalid-message="Vennligst skriv inn din brukskonto" /> </div> <br> + <p data-cy="change-email-msg-error" class="text-danger">{{ errorMsg }}</p> + <p data-cy="change-email-msg-confirm" class="text-success">{{ confirmationMsg }}</p> <button data-cy="update-spending-btn" type="submit" class="btn btn-primary classyButton">Oppdater brukskonto</button> </form> @@ -27,7 +29,7 @@ </form> <hr> <div class="form-group mb-0"> - <label class="d-block">Saldo oversikt</label> + <label class="d-block">Saldooversikt</label> <div class="border border-gray-500 bg-gray-200 p-3 text-center font-size-sm"> <div class="row"> <div class="col-sm-6"> @@ -50,62 +52,69 @@ <script setup lang="ts"> import { ref, onMounted } from 'vue'; import BaseInput from '@/components/BaseComponents/Input/BaseInput.vue'; -import type { BankAccountDTO } from '@/api'; +import type { UserUpdateDTO } from '@/api' import { UserService } from '@/api'; import handleUnknownError from '@/components/Exceptions/unkownErrorHandler' const spendingAccount = ref() const savingsAccount = ref() -const spendingAccountBalance = ref() -const savingsAccountBalance = ref() +const spendingAccountBalance = ref(0 as any) +const savingsAccountBalance = ref(0 as any) +const errorMsg = ref('') +const confirmationMsg = ref('') const handleSpendingInputEvent = (newValue: any) => { - console.log(newValue); spendingAccount.value = newValue } const handleSavingInputEvent = (newValue: any) => { - console.log(newValue); savingsAccount.value = newValue } const handleSavingSubmit = async () => { - - const updateSaving: BankAccountDTO = { - bban: savingsAccount.value, - bankAccountType: "SAVING_ACCOUNT", - }; try { - UserService.selectBankAccount({ requestBody: updateSaving }) + const updateUserPayload: UserUpdateDTO = { + savingsAccountBBAN: savingsAccount.value + }; + UserService.update({ requestBody: updateUserPayload }) + errorMsg.value = '' + confirmationMsg.value = 'Kontonummer ble oppdatert' } catch (err) { - handleUnknownError(err) + errorMsg.value = handleUnknownError(err); + confirmationMsg.value = '' } } const handleSpendingSubmit = async () => { - console.log(savingsAccount.value) - - const updateSaving: BankAccountDTO = { - bban: spendingAccount.value, - bankAccountType: "CHECKING_ACCOUNT", - }; try { - UserService.selectBankAccount({ requestBody: updateSaving }) + const updateUserPayload: UserUpdateDTO = { + checkingAccountBBAN: spendingAccount.value + }; + UserService.update({ requestBody: updateUserPayload }) + errorMsg.value = '' + confirmationMsg.value = 'Kontonummer ble oppdatert' } catch (err) { - handleUnknownError(err) + errorMsg.value = handleUnknownError(err); + confirmationMsg.value = '' } } onMounted(getAccountInfo) async function getAccountInfo() { try { - let response = await UserService.getUser() - savingsAccountBalance.value = response.savingsAccount?.balance - spendingAccountBalance.value = response.checkingAccount?.balance + let response = await UserService.getUser(); + savingsAccount.value = response.savingsAccountBBAN; + /*if (response.savingsAccount?.balance) { + savingsAccountBalance.value = response.savingsAccount?.balance + }*/ + spendingAccount.value = response.checkingAccountBBAN; + /*if (response.checkingAccount?.balance) { + spendingAccountBalance.value = response.checkingAccountBBAN?.balance + }*/ } catch (err) { handleUnknownError(err) } diff --git a/src/components/Settings/SettingsNotification.vue b/src/components/Settings/SettingsNotification.vue deleted file mode 100644 index f33417a59c8ff18f82595b1a28ac500805581c9d..0000000000000000000000000000000000000000 --- a/src/components/Settings/SettingsNotification.vue +++ /dev/null @@ -1,62 +0,0 @@ -<template> - <div class="tab-pane active" id="notification"> - <h6>VARSLINGSINNSTILLINGER</h6> - <hr> - <form> - <div class="form-group"> - <label class="d-block mb-0">Sikkerhetsvarsler</label> - <div class="small text-muted mb-3">Motta sikkerhetsvarselvarsler via e-post</div> - <div class="custom-control custom-checkbox"> - <input type="checkbox" class="custom-control-input" id="customCheck1"> - <label class="custom-control-label" for="customCheck1">E-post hver gang en - sårbarhet blir funnet</label> - </div> - <div class="custom-control custom-checkbox"> - <input type="checkbox" class="custom-control-input" id="customCheck2"> - <label class="custom-control-label" for="customCheck2">E-post et sammendrag av - sårbarhet</label> - </div> - </div> - <div class="form-group mb-0"> - <label class="d-block">SMS-varsler</label> - <ul class="list-group list-group-sm"> - <li class="list-group-item has-icon"> - Kommentarer - <div class="custom-control custom-control-nolabel custom-switch ml-auto"> - <input type="checkbox" class="custom-control-input" id="customSwitch1"> - <label class="custom-control-label" for="customSwitch1"></label> - </div> - </li> - <li class="list-group-item has-icon"> - Oppdateringer fra personer - <div class="custom-control custom-control-nolabel custom-switch ml-auto"> - <input type="checkbox" class="custom-control-input" id="customSwitch2"> - <label class="custom-control-label" for="customSwitch2"></label> - </div> - </li> - <li class="list-group-item has-icon"> - Påminnelser - <div class="custom-control custom-control-nolabel custom-switch ml-auto"> - <input type="checkbox" class="custom-control-input" id="customSwitch3"> - <label class="custom-control-label" for="customSwitch3"></label> - </div> - </li> - <li class="list-group-item has-icon"> - Hendelser - <div class="custom-control custom-control-nolabel custom-switch ml-auto"> - <input type="checkbox" class="custom-control-input" id="customSwitch4"> - <label class="custom-control-label" for="customSwitch4"></label> - </div> - </li> - <li class="list-group-item has-icon"> - Sider du følger - <div class="custom-control custom-control-nolabel custom-switch ml-auto"> - <input type="checkbox" class="custom-control-input" id="customSwitch5"> - <label class="custom-control-label" for="customSwitch5"></label> - </div> - </li> - </ul> - </div> - </form> - </div> -</template> diff --git a/src/components/Settings/SettingsSecurity.vue b/src/components/Settings/SettingsSecurity.vue index 98ec8d13419531eaa97eaaf217df51db16cec0fc..22519a0078f42c7e99062ea3428ba90d4c70ac73 100644 --- a/src/components/Settings/SettingsSecurity.vue +++ b/src/components/Settings/SettingsSecurity.vue @@ -1,10 +1,10 @@ <template> <div class="tab-pane active" id="security"> - <h6>SIKKERHETSINNSTILLINGER</h6> + <h6>SIKKERHET</h6> <hr> - <form @submit.prevent="handleSubmit" novalidate> + <form @submit.prevent="handleSubmit" > <div class="form-group"> - <label class="d-block">Endre passord</label> + <h5 class="d-block">Endre passord</h5> <BaseInput data-cy="old-password-input" :model-value="oldPasswordRef" @input-change-event="handleOldPasswordInputEvent" id="passwordInput-change" input-id="password-old" type="password" @@ -23,10 +23,9 @@ pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{4,16}" label="Bekreft nytt passord" placeholder="Skriv inn passord" invalid-message="Passordet må være mellom 4 og 16 tegn og inneholde en stor bokstav, en liten bokstav og et tall" /> </div> + <p class="text-danger" data-cy="error">{{ errorMsg }}</p> <button data-cy="update-password-btn" type="submit" class="btn btn-primary classyButton">Oppdater passord</button> - <button data-cy="reset-fields-btn" type="reset" class="btn btn-light">Tilbakestill - endringer</button> </form> <hr> </div> @@ -42,7 +41,7 @@ const oldPasswordRef = ref(''); const newPasswordRef = ref(''); const confirmPasswordRef = ref(''); - + let errorMsg = ref(''); const handleOldPasswordInputEvent = (newValue: any) => { oldPasswordRef.value = newValue @@ -57,23 +56,22 @@ } const handleSubmit = async () => { - if (newPasswordRef.value !== confirmPasswordRef.value) { - console.error('Passwords do not match') + if (newPasswordRef.value.length === 0 || newPasswordRef.value !== confirmPasswordRef.value) { + errorMsg.value = "Passordene er ikke identiske"; return } + errorMsg.value = ''; - const updateUserPayload: PasswordUpdateDTO = { + try { + const updateUserPayload: PasswordUpdateDTO = { oldPassword: oldPasswordRef.value, newPassword: newPasswordRef.value, - }; - - try { - const response = UserService.updatePassword({ requestBody: updateUserPayload }) - console.log(response) - } catch (err) { - handleUnknownError(err); - console.error(err) + }; + await UserService.updatePassword({ requestBody: updateUserPayload }); + errorMsg.value = ''; + } catch (err: any) { + errorMsg.value = err.body.message; } } </script> @@ -93,4 +91,8 @@ const handleSubmit = async () => { background-color: #003b58d6; border: #003A58; } + + #passwordInput-change { + margin-bottom: 15px; + } </style> \ No newline at end of file diff --git a/src/router/index.ts b/src/router/index.ts index 9c15ed459254e04ad1d80d1421619fe622ccf8c8..2d1284aa1da81f104b6d9a22c238228ccdf5d568 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -48,11 +48,6 @@ const routes = [ name: 'security', component: () => import('@/components/Settings/SettingsSecurity.vue'), }, - { - path: '/settings/notification', - name: 'notification', - component: () => import('@/components/Settings/SettingsNotification.vue'), - }, { path: '/settings/bank', name: 'bank', diff --git a/src/views/BasePageView.vue b/src/views/BasePageView.vue index f7907b39ced3e3c370f50f2d91faeba4f78afe75..78e96a6d1707e650b91b86c2f0db53eef83fd8ce 100644 --- a/src/views/BasePageView.vue +++ b/src/views/BasePageView.vue @@ -16,5 +16,6 @@ import { useUserInfoStore } from '@/stores/UserStore'; <style scoped> #minHeight { min-height: 700px; + margin: 0 140px; } </style> \ No newline at end of file diff --git a/src/views/User/UserSettingsView.vue b/src/views/User/UserSettingsView.vue index bd11bcc03a46c6c0739d948eb178efa782ffe0eb..5f2dc15fbeb8c0e7e8f35d32c4d6455b2a4ff933 100644 --- a/src/views/User/UserSettingsView.vue +++ b/src/views/User/UserSettingsView.vue @@ -80,16 +80,6 @@ function toBilling() { Sikkerhet </a> - - <a @click.prevent="setActive('/settings/notification')" @click="toNotification" - :class="['nav-item nav-link has-icon', { 'nav-link-faded': useRoute().path !== '/settings/notification', 'active': useRoute().path === '/settings/notification' }]"> - <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" - fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" - stroke-linejoin="round" class="feather feather-bell mr-2"> - <path d="M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"></path> - <path d="M13.73 21a2 2 0 0 1-3.46 0"></path> - </svg>Varsel - </a> <a> <a @click.prevent="setActive('/settings/bank')" @click="toBilling" :class="['nav-item nav-link has-icon', { 'nav-link-faded': useRoute().path !== '/settings/bank', 'active': useRoute().path === '/settings/bank' }]"> @@ -103,8 +93,6 @@ function toBilling() { </a> </a> - - </nav> </div> </div> @@ -209,12 +197,17 @@ function toBilling() { border-radius: .25rem; } + .card-body { flex: 1 1 auto; min-height: 1px; padding: 1rem; } +.nav-pills { + cursor: pointer; +} + .gutters-sm { margin-right: -8px; margin-left: -8px;