Skip to content
Snippets Groups Projects
Commit 60a9a18b authored by VIktorGrev's avatar VIktorGrev
Browse files

Merge branch 'feat/profile-and-settings-improvements' of...

Merge branch 'feat/profile-and-settings-improvements' of https://gitlab.stud.idi.ntnu.no/idatt2106-2024-07/frontend into feat/profile-and-settings-improvements
parents 5f6a3a67 043399a3
No related branches found
No related tags found
1 merge request!106Feat/profile and settings improvements
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="m438-240 226-226-58-58-169 169-84-84-57 57 142 142ZM240-80q-33 0-56.5-23.5T160-160v-640q0-33 23.5-56.5T240-880h320l240 240v480q0 33-23.5 56.5T720-80H240Zm280-520v-200H240v640h480v-440H520ZM240-800v200-200 640-640Z"/></svg>
\ No newline at end of file
<script setup lang="ts">
import { onMounted, ref } from 'vue'
import { type FeedbackResponseDTO, UserService } from '@/api'
import handleUnknownError from '@/components/Exceptions/unkownErrorHandler'
const feedbacks = ref<FeedbackResponseDTO[]>([]);
onMounted(async () => {
try {
feedbacks.value = await UserService.getFeedback();
console.log(feedbacks.value)
} catch (error) {
handleUnknownError(error);
}
})
const formattedDate = (dateStr?: string): string => {
if (!dateStr) return '';
return new Date(dateStr).toLocaleString();
};
</script>
<template>
<div class="feedback-container">
<h1>Feedback List</h1>
<div class="feedback-list">
<!-- Loop through feedback items -->
<div class="feedback-item" v-for="feedback in feedbacks" :key="feedback.id">
<div class="email">{{ feedback.email }}</div>
<div class="message">{{ feedback.message }}</div>
<div class="created-at">{{ formattedDate(feedback.createdAt) }}</div>
</div>
</div>
</div>
</template>
<style scoped>
.feedback-container {
max-width: 800px;
margin: auto;
padding: 20px;
}
.feedback-list {
margin-top: 20px;
border-top: 1px solid #ccc;
}
.feedback-item {
padding: 10px;
border-bottom: 1px solid #ccc;
}
.email, .message, .created-at {
padding: 5px 0;
}
.email {
font-weight: bold;
color: #333;
}
.message {
margin: 5px 0;
line-height: 1.5;
color: #666;
}
.created-at {
font-size: 0.8rem;
color: #999;
}
</style>
\ No newline at end of file
...@@ -122,7 +122,7 @@ ...@@ -122,7 +122,7 @@
<li> <li>
<router-link data-cy="admin" <router-link data-cy="admin"
class="dropdown-item dropdown-username-link" class="dropdown-item dropdown-username-link"
:to="toSetting()" :to="toAdmin()"
exact-active-class="active-link" exact-active-class="active-link"
@click="toggleDropdown"> @click="toggleDropdown">
<img src="@/assets/icons/admin.svg">Admin <img src="@/assets/icons/admin.svg">Admin
...@@ -313,6 +313,15 @@ function toFeedback(): string { ...@@ -313,6 +313,15 @@ function toFeedback(): string {
return '/feedback'; return '/feedback';
} }
/**
* Redirects to the admin page.
*
* @returns {string} The URL for the admin page.
*/
function toAdmin(): string {
return '/admin';
}
/** /**
* Redirects to the friends page. * Redirects to the friends page.
* *
......
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, onMounted } from 'vue'; import { ref, onMounted } from 'vue';
import BaseInput from '@/components/BaseComponents/Input/BaseInput.vue'; import BaseInput from '@/components/BaseComponents/Input/BaseInput.vue';
import type { UserUpdateDTO } from '@/api' import { AccountControllerService, type BalanceDTO, BankProfileControllerService, type UserUpdateDTO } from '@/api'
import { UserService } from '@/api'; import { UserService } from '@/api';
import handleUnknownError from '@/components/Exceptions/unkownErrorHandler' import handleUnknownError from '@/components/Exceptions/unkownErrorHandler'
...@@ -128,13 +128,16 @@ async function getAccountInfo() { ...@@ -128,13 +128,16 @@ async function getAccountInfo() {
try { try {
let response = await UserService.getUser(); let response = await UserService.getUser();
savingsAccount.value = response.savingsAccountBBAN; savingsAccount.value = response.savingsAccountBBAN;
/*if (response.savingsAccount?.balance) { let bban1: any = response.savingsAccountBBAN;
savingsAccountBalance.value = response.savingsAccount?.balance AccountControllerService.getAccountsByBban({bban: bban1}).then((balance: BalanceDTO) => {
}*/ savingsAccountBalance.value = balance.balance;
})
spendingAccount.value = response.checkingAccountBBAN; spendingAccount.value = response.checkingAccountBBAN;
/*if (response.checkingAccount?.balance) { let bban2: any = response.checkingAccountBBAN;
spendingAccountBalance.value = response.checkingAccountBBAN?.balance AccountControllerService.getAccountsByBban({bban: bban2}).then((balance: BalanceDTO) => {
}*/ spendingAccountBalance.value = balance.balance;
})
} catch (err) { } catch (err) {
handleUnknownError(err) handleUnknownError(err)
} }
......
...@@ -28,6 +28,12 @@ const routes = [ ...@@ -28,6 +28,12 @@ const routes = [
name: 'profile', name: 'profile',
component: () => import('@/views/User/MyProfileView.vue'), component: () => import('@/views/User/MyProfileView.vue'),
}, },
{
path: 'admin',
name: 'admin',
component: () => import('@/views/Admin/AdminDashboardView.vue'),
meta: { requiresAdmin: true }
},
{ {
path: '/settings', path: '/settings',
name: 'settings', name: 'settings',
...@@ -186,7 +192,7 @@ router.beforeEach((to, from, next) => { ...@@ -186,7 +192,7 @@ router.beforeEach((to, from, next) => {
if (requiresAuth && !isAuthenticated) { if (requiresAuth && !isAuthenticated) {
next({ name: 'login', query: { redirect: to.fullPath } }); next({ name: 'login', query: { redirect: to.fullPath } });
} else if (requiresAdmin && userRole !== 'admin') { } else if (requiresAdmin && userRole !== 'ADMIN') {
next({ name: 'unauthorized' }); next({ name: 'unauthorized' });
} else if (requiresPremium && userSubscription !== 'PREMIUM') { } else if (requiresPremium && userSubscription !== 'PREMIUM') {
next({ name: 'home' }); next({ name: 'home' });
......
<script setup lang="ts">
import AddminFeedback from "@/components/Admin/AdminFeedback.vue";
</script>
<template>
<AddminFeedback></AddminFeedback>
</template>
<style scoped>
</style>
\ No newline at end of file
...@@ -2,15 +2,25 @@ ...@@ -2,15 +2,25 @@
<main> <main>
<div class="wrapper"> <div class="wrapper">
<div id="formFrame"> <div id="formFrame">
<h1>TIlbakemelding</h1> <h1>Tilbakemelding</h1>
<form @submit.prevent="submitForm"> <form ref="formRef" id="loginForm" @submit.prevent="submitForm" novalidate>
<BaseInput v-model="email" label="Email" type="email" placeholder="Enter your email" inputId="email" required /> <BaseInput :model-value="emailRef"
@input-change-event="handleEmailInputEvent"
id="emailInput"
input-id="email"
type="email"
label="E-post"
placeholder="Skriv inn din e-post"
invalid-message="Ugyldig e-post"
/>
<br> <br>
<label for="feedback">Din tilbakemelding:</label> <label for="feedback">Din tilbakemelding:</label>
<textarea v-model="message" placeholder="Write here" rows="5" name="comment[text]" id="comment_text" cols="33" <textarea v-model="messageRef" placeholder="Skriv meldingen din her" rows="5" name="comment[text]" id="comment_text" cols="33"
required></textarea> required></textarea>
<BaseButton button-text="Send" @click="submitForm">Send inn</BaseButton> <p data-cy="change-email-msg-error" class="text-danger">{{ errorMsg }}</p>
<p v-if="submissionStatus">{{ submissionStatus }}</p> <BaseButton button-text="Send" @click="submitForm" style="padding: 10px 30px; font-size: 18px; font-weight: normal;">Send inn</BaseButton>
<p data-cy="change-email-msg-confirm" class="text-success">{{ confirmationMsg }}</p>
</form> </form>
</div> </div>
</div> </div>
...@@ -21,13 +31,33 @@ ...@@ -21,13 +31,33 @@
import { ref } from 'vue'; import { ref } from 'vue';
import BaseInput from '@/components/BaseComponents/Input/BaseInput.vue'; import BaseInput from '@/components/BaseComponents/Input/BaseInput.vue';
import BaseButton from '@/components/BaseComponents/Buttons/BaseButton.vue'; import BaseButton from '@/components/BaseComponents/Buttons/BaseButton.vue';
import { type FeedbackRequestDTO, UserService } from '@/api'
import handleUnknownError from '@/components/Exceptions/unkownErrorHandler'
const emailRef = ref("");
const messageRef = ref("");
const errorMsg = ref('')
const confirmationMsg = ref('')
const email = ref(""); const handleEmailInputEvent = (newValue: any) => {
const message = ref(""); emailRef.value = newValue
const submissionStatus = ref(""); }
const submitForm = async () => { const submitForm = async () => {
try {
const feedbackRequest: FeedbackRequestDTO = {
email: emailRef.value,
message: messageRef.value
};
console.log("feedbackRequest", feedbackRequest);
UserService.sendFeedback({ requestBody: feedbackRequest });
messageRef.value = ''
errorMsg.value = ''
confirmationMsg.value = 'Tilbakemeldingen ble sendt!'
} catch (err) {
errorMsg.value = handleUnknownError(err);
confirmationMsg.value = ''
}
}; };
</script> </script>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment