diff --git a/spec.json b/spec.json index 1ca2502ef0cfab946bf2ed05dc8941862d2ff8ce..e6566e8325cdbf7dd17a2bb0286b7fe42273b085 100644 --- a/spec.json +++ b/spec.json @@ -23,6 +23,38 @@ } ], "paths": { + "/api/users/subscription/{subscriptionLevel}": { + "put": { + "tags": [ + "User" + ], + "summary": "Update User Subscription Level", + "description": "Updates the subscription level of the current user", + "operationId": "updateSubscriptionLevel", + "parameters": [ + { + "name": "subscriptionLevel", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Subscription level updated successfully", + "content": { + "*/*": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, "/api/friends/{friendId}": { "put": { "tags": [ @@ -126,8 +158,8 @@ "required": true }, "responses": { - "200": { - "description": "No accounts associated with a bank user", + "404": { + "description": "Bank profile id does not exist", "content": { "*/*": { "schema": { @@ -136,8 +168,8 @@ } } }, - "404": { - "description": "Bank profile id does not exist", + "200": { + "description": "No accounts associated with a bank user", "content": { "*/*": { "schema": { @@ -168,8 +200,8 @@ "required": true }, "responses": { - "200": { - "description": "Successfully created a bank profile", + "400": { + "description": "Could not create profile", "content": { "*/*": { "schema": { @@ -178,8 +210,8 @@ } } }, - "400": { - "description": "Could not create profile", + "200": { + "description": "Successfully created a bank profile", "content": { "*/*": { "schema": { @@ -210,8 +242,8 @@ "required": true }, "responses": { - "200": { - "description": "Successfully created account", + "404": { + "description": "Provided bank profile id could not be found", "content": { "*/*": { "schema": { @@ -220,8 +252,8 @@ } } }, - "404": { - "description": "Provided bank profile id could not be found", + "200": { + "description": "Successfully created account", "content": { "*/*": { "schema": { @@ -233,6 +265,31 @@ } } }, + "/api/users/send-feedback": { + "post": { + "tags": [ + "User" + ], + "summary": "Send feedback", + "description": "Send feedback from an email.", + "operationId": "sendFeedback", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/FeedbackRequestDTO" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Success" + } + } + } + }, "/api/users/reset-password": { "post": { "tags": [ @@ -278,17 +335,17 @@ "required": true }, "responses": { - "204": { - "description": "Password was reset successfully" - }, "403": { "description": "Invalid token" + }, + "204": { + "description": "Password was reset successfully" } }, "security": [] } }, - "/api/image/upload": { + "/api/images": { "post": { "tags": [ "Image" @@ -298,7 +355,7 @@ "operationId": "uploadImage", "requestBody": { "content": { - "application/json": { + "multipart/form-data": { "schema": { "required": [ "file" @@ -315,19 +372,8 @@ } }, "responses": { - "200": { - "description": "Successfully uploaded the image", - "content": { - "*/*": { - "schema": { - "type": "integer", - "format": "int64" - } - } - } - }, "201": { - "description": "Created", + "description": "Successfully uploaded the image", "content": { "*/*": { "schema": { @@ -426,8 +472,8 @@ "required": true }, "responses": { - "200": { - "description": "Successfully updated budget", + "500": { + "description": "Budget is not found", "content": { "application/json": { "schema": { @@ -436,8 +482,8 @@ } } }, - "500": { - "description": "Budget is not found", + "200": { + "description": "Successfully updated budget", "content": { "application/json": { "schema": { @@ -479,8 +525,8 @@ "required": true }, "responses": { - "200": { - "description": "Successfully updated budget", + "500": { + "description": "Error updating expense", "content": { "application/json": { "schema": { @@ -489,8 +535,8 @@ } } }, - "500": { - "description": "Error updating expense", + "200": { + "description": "Successfully updated budget", "content": { "application/json": { "schema": { @@ -737,6 +783,38 @@ } } }, + "/api/users/password": { + "patch": { + "tags": [ + "User" + ], + "summary": "Update a password", + "description": "Update the password of the authenticated user", + "operationId": "updatePassword", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PasswordUpdateDTO" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Successfully updated password", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/UserDTO" + } + } + } + } + } + } + }, "/bank/v1/account/accounts/ssn/{ssn}": { "get": { "tags": [ @@ -806,8 +884,8 @@ } ], "responses": { - "200": { - "description": "No accounts associated with a bank user", + "404": { + "description": "Bank profile id does not exist", "content": { "*/*": { "schema": { @@ -819,8 +897,8 @@ } } }, - "404": { - "description": "Bank profile id does not exist", + "200": { + "description": "No accounts associated with a bank user", "content": { "*/*": { "schema": { @@ -911,6 +989,50 @@ } } }, + "/api/users/search/random/{amount}/{filter}": { + "get": { + "tags": [ + "User" + ], + "summary": "Get X amount of random users", + "description": "Get X amount of random users that fit the filter", + "operationId": "getRandomUsers", + "parameters": [ + { + "name": "amount", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int32" + } + }, + { + "name": "filter", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successfully retrieved list of users", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/UserDTO" + } + } + } + } + } + } + } + }, "/api/users/me": { "get": { "tags": [ @@ -933,6 +1055,31 @@ } } }, + "/api/users/get-feedback": { + "get": { + "tags": [ + "User" + ], + "summary": "Send feedback", + "description": "Send feedback from a user.", + "operationId": "getFeedback", + "responses": { + "200": { + "description": "Success", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/FeedbackResponseDTO" + } + } + } + } + } + } + } + }, "/api/leaderboard": { "get": { "tags": [ @@ -1029,7 +1176,7 @@ } } }, - "/api/image/{id}": { + "/api/images/{id}": { "get": { "tags": [ "Image" @@ -1064,16 +1211,14 @@ "content": { "*/*": { "schema": { - "type": "array", - "items": { - "type": "string", - "format": "byte" - } + "type": "string", + "format": "binary" } } } } - } + }, + "security": [] } }, "/api/goal/getGoals": { @@ -1214,8 +1359,8 @@ } ], "responses": { - "200": { - "description": "Successfully got budget", + "500": { + "description": "Budget is not found", "content": { "application/json": { "schema": { @@ -1224,8 +1369,8 @@ } } }, - "500": { - "description": "Budget is not found", + "200": { + "description": "Successfully got budget", "content": { "application/json": { "schema": { @@ -1336,8 +1481,8 @@ } ], "responses": { - "200": { - "description": "Successfully deleted budget", + "500": { + "description": "Budget is not found", "content": { "application/json": { "schema": { @@ -1346,8 +1491,8 @@ } } }, - "500": { - "description": "Budget is not found", + "200": { + "description": "Successfully deleted budget", "content": { "application/json": { "schema": { @@ -1500,6 +1645,17 @@ } } }, + "FeedbackRequestDTO": { + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "message": { + "type": "string" + } + } + }, "PasswordResetDTO": { "required": [ "token" @@ -1740,6 +1896,14 @@ "lastName": { "type": "string" }, + "userId": { + "type": "integer", + "format": "int64" + }, + "profileImage": { + "type": "integer", + "format": "int64" + }, "role": { "type": "string" }, @@ -1774,8 +1938,9 @@ "email": { "type": "string" }, - "password": { - "type": "string" + "profileImage": { + "type": "integer", + "format": "int64" }, "configuration": { "$ref": "#/components/schemas/ConfigurationDTO" @@ -1795,6 +1960,10 @@ "lastName": { "type": "string" }, + "profileImage": { + "type": "integer", + "format": "int64" + }, "email": { "type": "string" }, @@ -1822,6 +1991,17 @@ } } }, + "PasswordUpdateDTO": { + "type": "object", + "properties": { + "oldPassword": { + "type": "string" + }, + "newPassword": { + "type": "string" + } + } + }, "ProfileDTO": { "type": "object", "properties": { @@ -1835,6 +2015,28 @@ "lastName": { "type": "string" }, + "profileImage": { + "type": "integer", + "format": "int64" + }, + "createdAt": { + "type": "string", + "format": "date-time" + } + } + }, + "FeedbackResponseDTO": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "email": { + "type": "string" + }, + "message": { + "type": "string" + }, "createdAt": { "type": "string", "format": "date-time" diff --git a/src/api/index.ts b/src/api/index.ts index d86adbf0fe3bd391b7cd8c97b974dfdb9f74f97f..0a46cc0e4ddd97a94230ae6cffde43965f222b93 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -24,6 +24,8 @@ export type { DailyChallengeProgressDTO } from './models/DailyChallengeProgressD export type { ExceptionResponse } from './models/ExceptionResponse'; export type { ExpenseRequestDTO } from './models/ExpenseRequestDTO'; export type { ExpenseResponseDTO } from './models/ExpenseResponseDTO'; +export type { FeedbackRequestDTO } from './models/FeedbackRequestDTO'; +export type { FeedbackResponseDTO } from './models/FeedbackResponseDTO'; export type { GoalDTO } from './models/GoalDTO'; export type { LeaderboardDTO } from './models/LeaderboardDTO'; export type { LeaderboardEntryDTO } from './models/LeaderboardEntryDTO'; diff --git a/src/api/models/AuthenticationResponse.ts b/src/api/models/AuthenticationResponse.ts index d6785f617996241509d3c5a02058c70cde76c90f..3cbef78cec18fdd088dc5349ec155fdfc9ae8b02 100644 --- a/src/api/models/AuthenticationResponse.ts +++ b/src/api/models/AuthenticationResponse.ts @@ -5,6 +5,8 @@ export type AuthenticationResponse = { firstName?: string; lastName?: string; + userId?: number; + profileImage?: number; role?: string; subscriptionLevel?: string; token?: string; diff --git a/src/api/models/FeedbackRequestDTO.ts b/src/api/models/FeedbackRequestDTO.ts new file mode 100644 index 0000000000000000000000000000000000000000..174e9eff582bc5a724980e15fcb6341a50d4acaa --- /dev/null +++ b/src/api/models/FeedbackRequestDTO.ts @@ -0,0 +1,9 @@ +/* generated using openapi-typescript-codegen -- do not edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export type FeedbackRequestDTO = { + email?: string; + message?: string; +}; + diff --git a/src/api/models/FeedbackResponseDTO.ts b/src/api/models/FeedbackResponseDTO.ts new file mode 100644 index 0000000000000000000000000000000000000000..7b249002ad1e5b596541e138c7ac6e34eef093f0 --- /dev/null +++ b/src/api/models/FeedbackResponseDTO.ts @@ -0,0 +1,11 @@ +/* generated using openapi-typescript-codegen -- do not edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export type FeedbackResponseDTO = { + id?: string; + email?: string; + message?: string; + createdAt?: string; +}; + diff --git a/src/api/services/UserService.ts b/src/api/services/UserService.ts index 93cd7cea1dd29a31a0dcfc46ab19d53a0edbbc0f..593418a27bb5f5beb68aa4d7d017da91be1df7a3 100644 --- a/src/api/services/UserService.ts +++ b/src/api/services/UserService.ts @@ -8,6 +8,8 @@ import type { BudgetRequestDTO } from '../models/BudgetRequestDTO'; import type { BudgetResponseDTO } from '../models/BudgetResponseDTO'; import type { ExpenseRequestDTO } from '../models/ExpenseRequestDTO'; import type { ExpenseResponseDTO } from '../models/ExpenseResponseDTO'; +import type { FeedbackRequestDTO } from '../models/FeedbackRequestDTO'; +import type { FeedbackResponseDTO } from '../models/FeedbackResponseDTO'; import type { PasswordResetDTO } from '../models/PasswordResetDTO'; import type { PasswordUpdateDTO } from '../models/PasswordUpdateDTO'; import type { ProfileDTO } from '../models/ProfileDTO'; @@ -17,6 +19,43 @@ import type { CancelablePromise } from '../core/CancelablePromise'; import { OpenAPI } from '../core/OpenAPI'; import { request as __request } from '../core/request'; export class UserService { + /** + * Update User Subscription Level + * Updates the subscription level of the current user + * @returns any Subscription level updated successfully + * @throws ApiError + */ + public static updateSubscriptionLevel({ + subscriptionLevel, + }: { + subscriptionLevel: string, + }): CancelablePromise<Record<string, any>> { + return __request(OpenAPI, { + method: 'PUT', + url: '/api/users/subscription/{subscriptionLevel}', + path: { + 'subscriptionLevel': subscriptionLevel, + }, + }); + } + /** + * Send feedback + * Send feedback from an email. + * @returns any Success + * @throws ApiError + */ + public static sendFeedback({ + requestBody, + }: { + requestBody: FeedbackRequestDTO, + }): CancelablePromise<any> { + return __request(OpenAPI, { + method: 'POST', + url: '/api/users/send-feedback', + body: requestBody, + mediaType: 'application/json', + }); + } /** * Initiate a password reset * Send a password reset mail to the user with the specified email @@ -221,6 +260,28 @@ export class UserService { }, }); } + /** + * Get X amount of random users + * Get X amount of random users that fit the filter + * @returns UserDTO Successfully retrieved list of users + * @throws ApiError + */ + public static getRandomUsers({ + amount, + filter, + }: { + amount: number, + filter: string, + }): CancelablePromise<Array<UserDTO>> { + return __request(OpenAPI, { + method: 'GET', + url: '/api/users/search/random/{amount}/{filter}', + path: { + 'amount': amount, + 'filter': filter, + }, + }); + } /** * Get the authenticated user * Get all user information for the authenticated user @@ -233,6 +294,18 @@ export class UserService { url: '/api/users/me', }); } + /** + * Send feedback + * Send feedback from a user. + * @returns FeedbackResponseDTO Success + * @throws ApiError + */ + public static getFeedback(): CancelablePromise<Array<FeedbackResponseDTO>> { + return __request(OpenAPI, { + method: 'GET', + url: '/api/users/get-feedback', + }); + } /** * Get the list of budgets * Get all budgets related to the authenticated user diff --git a/src/components/BaseComponents/Menu.vue b/src/components/BaseComponents/Menu.vue index e63381b53b205198b75871d62f1bd48828d25819..684401a0f7cbaa18876f98aa8270f79b392311f5 100644 --- a/src/components/BaseComponents/Menu.vue +++ b/src/components/BaseComponents/Menu.vue @@ -1,7 +1,7 @@ <template> <nav id="navBar" class="navbar navbar-expand-xl"> <div class="container-fluid"> - <router-link class="navbar-brand" id="home" :to="toSavingGoals()"> + <router-link class="navbar-brand" id="home" :to="toSavingGoals()"> <img id="logoImg" src="/src/assets/Sparesti-logo.png" alt="Sparesti-logo" width="60"> <span id="logo" class="text-white">Sparesti</span> </router-link> @@ -13,40 +13,45 @@ <div class="collapse navbar-collapse" id="navbarSupportedContent"> <ul class="navbar-nav ms-auto mb-2 mb-lg-0 ui-menu"> <li class="nav-item"> - <router-link class="nav-link text-white" :to="toSavingGoals()"><img + <router-link class="nav-link text-white" :to="toSavingGoals()"><img src="@/assets/icons/saving.svg">Saving goals</router-link> </li> <li class="nav-item"> - <router-link class="nav-link text-white" :to="toLeaderboard()"><img + <router-link class="nav-link text-white" :to="toLeaderboard()"><img src="@/assets/icons/leaderboard.svg">Leaderboard</router-link> </li> <li class="nav-item"> - <router-link class="nav-link text-white" :to="toNews()"><img - src="@/assets/icons/newsletter.svg">News</router-link> + <router-link class="nav-link text-white" :to="toNews()"><img + src="@/assets/icons/newsletter.svg">News</router-link> </li> <li class="nav-item"> - <router-link class="nav-link text-white" :to="toStore()"><img - src="@/assets/icons/storefront.svg">Store</router-link> + <router-link class="nav-link text-white" :to="toStore()"><img + src="@/assets/icons/storefront.svg">Store</router-link> </li> <li v-if="userStore.isLoggedIn" class="nav-item dropdown"> <a class="nav-link dropdown-toggle username-text text-white " href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false"> - <img src="@/assets/icons/person.svg">{{ useUserInfoStore().firstname}} + <img :src="useUserInfoStore().profileImage ? 'http://localhost:8080/api/images/' + useUserInfoStore().profileImage : 'src/assets/userprofile.png'" + style="width: 50px; border: 2px solid black; border-radius: 50%">{{ + useUserInfoStore().firstname }} </a> <ul class="dropdown-menu dropdown-username-content"> - <li><router-link class="dropdown-item text-white dropdown-username-link" :to="toUserProfile()"><img - src="@/assets/icons/person.svg">User Profile</router-link></li> - <li><router-link class="dropdown-item text-white dropdown-username-link" :to="toBudget()"><img>Budget</router-link></li> - <li><router-link class="dropdown-item text-white dropdown-username-link" :to="toFriends()"><img - src="@/assets/icons/friends.svg">Friends</router-link></li> - <li><router-link class="dropdown-item text-white dropdown-username-link" :to="toSetting()"><img - src="@/assets/icons/settings.svg">Settings</router-link></li> - <li><router-link class="dropdown-item text-white dropdown-username-link" :to="toFeedback()"><img - src="@/assets/icons/feedback.svg">Feedback</router-link></li> - <li><router-link class="dropdown-item text-white dropdown-username-link" :to="toSetting()"><img - src="@/assets/icons/admin.svg">Admin</router-link></li> - <li><a data-testid="logout" class="dropdown-item text-white dropdown-username-link" ref="#" @click="toLogout()"><img - src="@/assets/icons/logout.svg">Log out</a></li> + <li><router-link class="dropdown-item text-white dropdown-username-link" + :to="toUserProfile()"><img src="@/assets/icons/person.svg">User + Profile</router-link></li> + <li><router-link class="dropdown-item text-white dropdown-username-link" + :to="toBudget()"><img>Budget</router-link></li> + <li><router-link class="dropdown-item text-white dropdown-username-link" + :to="toFriends()"><img src="@/assets/icons/friends.svg">Friends</router-link></li> + <li><router-link class="dropdown-item text-white dropdown-username-link" + :to="toSetting()"><img src="@/assets/icons/settings.svg">Settings</router-link></li> + <li><router-link class="dropdown-item text-white dropdown-username-link" + :to="toFeedback()"><img src="@/assets/icons/feedback.svg">Feedback</router-link> + </li> + <li><router-link class="dropdown-item text-white dropdown-username-link" + :to="toSetting()"><img src="@/assets/icons/admin.svg">Admin</router-link></li> + <li><a data-testid="logout" class="dropdown-item text-white dropdown-username-link" ref="#" + @click="toLogout()"><img src="@/assets/icons/logout.svg">Log out</a></li> </ul> </li> <li v-else class="nav-item"> @@ -58,19 +63,28 @@ </nav> </template> <script setup lang="ts"> +import { ref } from 'vue'; import { useRouter } from "vue-router"; import { useUserInfoStore } from '@/stores/UserStore'; const router = useRouter(); -const userStore : any = useUserInfoStore(); +const userStore: any = useUserInfoStore(); + +let profileImage: any = ref(''); + +if (useUserInfoStore().profileImage !== 0) { + profileImage = 'http://localhost:8080/api/images/' + useUserInfoStore().profileImage; +} else { + profileImage = 'src/assets/userprofile.png'; +} function toHome() { return '/' } function toBudget() { - return '/budget-overview' + return '/budget-overview' } function toSavingGoals() { @@ -102,7 +116,7 @@ function toFriends() { } function toUserProfile() { - return '/profile' + return '/profile' } function toLogout() { diff --git a/src/components/LeaderboardComponents/Leaderboard.vue b/src/components/LeaderboardComponents/Leaderboard.vue index 7c036fc636865182d21961835072d210b2185118..845622ac297fc49fac64f058cef23a6189fff184 100644 --- a/src/components/LeaderboardComponents/Leaderboard.vue +++ b/src/components/LeaderboardComponents/Leaderboard.vue @@ -3,7 +3,7 @@ <div class="ribbon"></div> <table> <tbody> - <tr v-for="(entry, index) in leaderboard" :key="entry.user?.id" :class="{ 'is-user-5': entry.user?.firstName === 'User' }"> + <tr v-for="(entry, index) in leaderboard" :key="entry.user?.id" :class="{ 'is-user-5': entry.user?.id === userStore.id }"> <td class="number">{{ entry.rank }}</td> <td class="name" @click="navigateToUserProfile(entry.user?.id ?? 0)">{{ entry.user?.firstName }}</td> <td class="points" v-if="index === 0"> @@ -20,7 +20,7 @@ <tbody id="line">`</tbody> <tbody v-if="!userInLeaderboard"> <tr></tr> - <tr v-for="(entry, index) in leaderboardExtra" :key="entry.user?.id" :class="{ 'is-user-5': entry.user?.firstName === userStore.firstname }"> + <tr v-for="(entry, index) in leaderboardExtra" :key="entry.user?.id" :class="{ 'is-user-5': entry.user?.id === userStore.id }"> <td class="number">{{ entry.rank }}</td> <td class="name" @click="navigateToUserProfile(entry.user?.id ?? 0)">{{ entry.user?.firstName }}</td> <td class="points">{{ entry.score }}</td> diff --git a/src/components/Login/LoginForm.vue b/src/components/Login/LoginForm.vue index 9e58d96f32ddd9d57fdbf9d65d75b439aa56ace0..0ef2798aab894ad01405e13392ac9ccc1b3a3ec4 100644 --- a/src/components/Login/LoginForm.vue +++ b/src/components/Login/LoginForm.vue @@ -56,11 +56,13 @@ const handleSubmit = async () => { OpenAPI.TOKEN = response.token; userStore.setUserInfo({ + id: response.userId, accessToken: response.token, firstname: response.firstName, lastname: response.lastName, email: emailRef.value, role: response.role, + profileImage: response.profileImage }); console.log() diff --git a/src/stores/UserStore.ts b/src/stores/UserStore.ts index 9d00eaceb29a5882d3865ef3f6c4ca67069e96fb..fb8e369b7d49f34a5932c4c8f7f622d9319a0acd 100644 --- a/src/stores/UserStore.ts +++ b/src/stores/UserStore.ts @@ -29,22 +29,26 @@ const cookiesStorage: Storage = { }; export type UserStoreInfo = { + id?: number; email?: string; firstname?: string; lastname?: string; password?: string; accessToken?: string; role?: string; + profileImage?: number; }; //todo Fix if there is time export const useUserInfoStore = defineStore('UserInfoStore', { state: () => ({ + id: 0, email: '', firstname: '', lastname: '', password: '', accessToken: '', role: '', + profileImage: 0, }), persist: { storage: cookiesStorage, @@ -57,19 +61,23 @@ export const useUserInfoStore = defineStore('UserInfoStore', { this.password = '' }, setUserInfo(userinfo: UserStoreInfo) { + userinfo.id && (this.$state.id = userinfo.id); userinfo.email && (this.$state.email = userinfo.email); userinfo.firstname && (this.$state.firstname = userinfo.firstname); userinfo.lastname && (this.$state.lastname = userinfo.lastname); userinfo.accessToken && (this.$state.accessToken = userinfo.accessToken); userinfo.accessToken && (OpenAPI.TOKEN = this.$state.accessToken); userinfo.role && (this.$state.role = userinfo.role); + userinfo.profileImage && (this.$state.profileImage = userinfo.profileImage); }, clearUserInfo() { + this.$state.id = 0; this.$state.email = ''; this.$state.firstname = ''; this.$state.lastname = ''; this.$state.accessToken = ''; this.$state.role = ''; + this.$state.profileImage = 0; OpenAPI.TOKEN = undefined; }, }, diff --git a/src/views/Settings/SettingsProfileView.vue b/src/views/Settings/SettingsProfileView.vue index dcba9e73ada6cab265f09828914f5d02f2064b3d..8f88d2622e62974bdb547f7a3bbb99baa62dc538 100644 --- a/src/views/Settings/SettingsProfileView.vue +++ b/src/views/Settings/SettingsProfileView.vue @@ -46,6 +46,9 @@ const uploadImage = async (file: any) => { profileImage: response, }; UserService.update({ requestBody: updateUserPayload }) + useUserInfoStore().setUserInfo({ + profileImage: response, + }) } catch (error) { console.error('Failed to upload image:', error); } @@ -61,7 +64,11 @@ async function setupForm() { surnameRef.value = response.lastName; } console.log(response.profileImage) - iconSrc.value = "http://localhost:8080/api/images/" + response.profileImage; + if(response.profileImage != null){ + iconSrc.value = "http://localhost:8080/api/images/" + response.profileImage; + } else { + iconSrc.value = "../src/assets/userprofile.png"; + } } catch (err) { console.error(err) } diff --git a/src/views/User/UserFriendsView.vue b/src/views/User/UserFriendsView.vue index 7cd60ebc235650474548eb74427d14078cb558e6..b6b3ed3c46805bed9cd0dbb7e507ef83796bebce 100644 --- a/src/views/User/UserFriendsView.vue +++ b/src/views/User/UserFriendsView.vue @@ -152,8 +152,13 @@ const searchProfile = async (searchTerm: string) => { }; const addNewFriends = async () => { + const userPayload = { + amount: 6 as number, + filter: 'NON_FRIENDS' as string, + }; try { - //const response = await FriendService.(); + const response = await UserService.getRandomUsers(userPayload); + searchedUsers.value = response; showAddFriend.value = true; } catch (error) { console.error('Failed to add friend', error);