diff --git a/spec.json b/spec.json index 5cb3ddffdb672c18b8376ff8d1823378c1381155..aaf7188fa567a4aabafc50d37f247be3de855e4c 100644 --- a/spec.json +++ b/spec.json @@ -79,8 +79,8 @@ } ], "responses": { - "200": { - "description": "Friend request successfully accepted", + "404": { + "description": "Friend request not found", "content": { "*/*": { "schema": { @@ -89,8 +89,8 @@ } } }, - "404": { - "description": "Friend request not found", + "200": { + "description": "Friend request successfully accepted", "content": { "*/*": { "schema": { @@ -120,8 +120,8 @@ } ], "responses": { - "200": { - "description": "Friend successfully deleted or friend request cancelled", + "404": { + "description": "Friend or friend request not found", "content": { "*/*": { "schema": { @@ -130,8 +130,8 @@ } } }, - "404": { - "description": "Friend or friend request not found", + "200": { + "description": "Friend successfully deleted or friend request cancelled", "content": { "*/*": { "schema": { @@ -162,8 +162,8 @@ "required": true }, "responses": { - "200": { - "description": "No accounts associated with a bank user", + "404": { + "description": "Bank profile id does not exist", "content": { "*/*": { "schema": { @@ -172,8 +172,8 @@ } } }, - "404": { - "description": "Bank profile id does not exist", + "200": { + "description": "No accounts associated with a bank user", "content": { "*/*": { "schema": { @@ -204,8 +204,8 @@ "required": true }, "responses": { - "200": { - "description": "Successfully created a bank profile", + "400": { + "description": "Could not create profile", "content": { "*/*": { "schema": { @@ -214,8 +214,8 @@ } } }, - "400": { - "description": "Could not create profile", + "200": { + "description": "Successfully created a bank profile", "content": { "*/*": { "schema": { @@ -246,8 +246,8 @@ "required": true }, "responses": { - "200": { - "description": "Successfully created account", + "404": { + "description": "Provided bank profile id could not be found", "content": { "*/*": { "schema": { @@ -256,8 +256,8 @@ } } }, - "404": { - "description": "Provided bank profile id could not be found", + "200": { + "description": "Successfully created account", "content": { "*/*": { "schema": { @@ -339,11 +339,11 @@ "required": true }, "responses": { - "204": { - "description": "Password was reset successfully" - }, "403": { "description": "Invalid token" + }, + "204": { + "description": "Password was reset successfully" } }, "security": [] @@ -368,8 +368,8 @@ "required": true }, "responses": { - "200": { - "description": "Successfully updated notification", + "500": { + "description": "User is not found", "content": { "*/*": { "schema": { @@ -378,8 +378,8 @@ } } }, - "500": { - "description": "User is not found", + "200": { + "description": "Successfully updated notification", "content": { "*/*": { "schema": { @@ -411,12 +411,6 @@ } ], "responses": { - "201": { - "description": "Item purchased and added to inventory successfully", - "content": { - "application/json": {} - } - }, "403": { "description": "Insufficient points to purchase the item", "content": { @@ -426,6 +420,14 @@ } } } + }, + "201": { + "description": "Item purchased and added to inventory successfully", + "content": { + "application/json": { + + } + } } } } @@ -545,9 +547,6 @@ "required": true }, "responses": { - "200": { - "description": "Successfully updated the challenge" - }, "401": { "description": "Day is already completed or day outside of range", "content": { @@ -557,6 +556,9 @@ } } } + }, + "200": { + "description": "Successfully updated the challenge" } } } @@ -642,8 +644,8 @@ "required": true }, "responses": { - "200": { - "description": "Successfully updated budget", + "500": { + "description": "Budget is not found", "content": { "application/json": { "schema": { @@ -652,8 +654,8 @@ } } }, - "500": { - "description": "Budget is not found", + "200": { + "description": "Successfully updated budget", "content": { "application/json": { "schema": { @@ -695,8 +697,8 @@ "required": true }, "responses": { - "200": { - "description": "Successfully updated budget", + "500": { + "description": "Error updating expense", "content": { "application/json": { "schema": { @@ -705,8 +707,8 @@ } } }, - "500": { - "description": "Error updating expense", + "200": { + "description": "Successfully updated budget", "content": { "application/json": { "schema": { @@ -769,22 +771,22 @@ } ], "responses": { - "200": { - "description": "Email is valid", + "409": { + "description": "Email already exists", "content": { "*/*": { "schema": { - "type": "object" + "$ref": "#/components/schemas/ExceptionResponse" } } } }, - "409": { - "description": "Email already exists", + "200": { + "description": "Email is valid", "content": { "*/*": { "schema": { - "$ref": "#/components/schemas/ExceptionResponse" + "type": "object" } } } @@ -812,22 +814,22 @@ "required": true }, "responses": { - "201": { - "description": "Successfully signed up", + "409": { + "description": "Email already exists", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/AuthenticationResponse" + "$ref": "#/components/schemas/ExceptionResponse" } } } }, - "409": { - "description": "Email already exists", + "201": { + "description": "Successfully signed up", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/ExceptionResponse" + "$ref": "#/components/schemas/AuthenticationResponse" } } } @@ -1110,8 +1112,8 @@ } ], "responses": { - "200": { - "description": "No accounts associated with a bank user", + "404": { + "description": "Bank profile id does not exist", "content": { "*/*": { "schema": { @@ -1123,8 +1125,8 @@ } } }, - "404": { - "description": "Bank profile id does not exist", + "200": { + "description": "No accounts associated with a bank user", "content": { "*/*": { "schema": { @@ -1739,8 +1741,8 @@ } ], "responses": { - "200": { - "description": "Successfully got budget", + "500": { + "description": "Budget is not found", "content": { "application/json": { "schema": { @@ -1749,8 +1751,8 @@ } } }, - "500": { - "description": "Budget is not found", + "200": { + "description": "Successfully got budget", "content": { "application/json": { "schema": { @@ -1861,8 +1863,8 @@ } ], "responses": { - "200": { - "description": "Successfully deleted budget", + "500": { + "description": "Budget is not found", "content": { "application/json": { "schema": { @@ -1871,8 +1873,8 @@ } } }, - "500": { - "description": "Budget is not found", + "200": { + "description": "Successfully deleted budget", "content": { "application/json": { "schema": { @@ -1972,8 +1974,8 @@ } ], "responses": { - "200": { - "description": "Successfully got budget", + "500": { + "description": "Badge is not found", "content": { "application/json": { "schema": { @@ -1982,8 +1984,8 @@ } } }, - "500": { - "description": "Badge is not found", + "200": { + "description": "Successfully got budget", "content": { "application/json": { "schema": { @@ -2234,6 +2236,18 @@ } } }, + "BankAccountResponseDTO": { + "type": "object", + "properties": { + "bban": { + "type": "integer", + "format": "int64" + }, + "balance": { + "type": "number" + } + } + }, "ChallengeDTO": { "type": "object", "properties": { @@ -2346,6 +2360,19 @@ } } }, + "PointDTO": { + "type": "object", + "properties": { + "currentPoints": { + "type": "integer", + "format": "int32" + }, + "totalEarnedPoints": { + "type": "integer", + "format": "int32" + } + } + }, "ProgressDTO": { "type": "object", "properties": { @@ -2366,6 +2393,35 @@ } } }, + "StreakDTO": { + "type": "object", + "properties": { + "currentStreak": { + "type": "integer", + "format": "int32" + }, + "currentStreakCreatedAt": { + "type": "string", + "format": "date-time" + }, + "currentStreakUpdatedAt": { + "type": "string", + "format": "date-time" + }, + "highestStreak": { + "type": "integer", + "format": "int32" + }, + "highestStreakCreatedAt": { + "type": "string", + "format": "date-time" + }, + "highestStreakEndedAt": { + "type": "string", + "format": "date-time" + } + } + }, "UserDTO": { "type": "object", "properties": { @@ -2401,12 +2457,16 @@ "type": "string" }, "checkingAccountBBAN": { - "type": "integer", - "format": "int64" + "$ref": "#/components/schemas/BankAccountResponseDTO" }, "savingsAccountBBAN": { - "type": "integer", - "format": "int64" + "$ref": "#/components/schemas/BankAccountResponseDTO" + }, + "point": { + "$ref": "#/components/schemas/PointDTO" + }, + "streak": { + "$ref": "#/components/schemas/StreakDTO" } } }, @@ -2626,13 +2686,11 @@ "type": "string", "format": "date-time" }, - "totalPoints": { - "type": "integer", - "format": "int32" + "point": { + "$ref": "#/components/schemas/PointDTO" }, - "currentStreak": { - "type": "integer", - "format": "int32" + "streak": { + "$ref": "#/components/schemas/StreakDTO" } } }, diff --git a/src/api/index.ts b/src/api/index.ts index 4ab22c2112459939cb385110bf7011d567d948a2..cfeb244eadd5c15b0d35dcb2b438c22b5e9a2ab6 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -13,6 +13,7 @@ export type { AccountResponseDTO } from './models/AccountResponseDTO'; export type { AuthenticationResponse } from './models/AuthenticationResponse'; export type { BadgeDTO } from './models/BadgeDTO'; export type { BankAccountDTO } from './models/BankAccountDTO'; +export type { BankAccountResponseDTO } from './models/BankAccountResponseDTO'; export type { BankIDRequest } from './models/BankIDRequest'; export type { BankProfile } from './models/BankProfile'; export type { BankProfileDTO } from './models/BankProfileDTO'; @@ -38,9 +39,11 @@ export type { MarkChallengeDTO } from './models/MarkChallengeDTO'; export { NotificationDTO } from './models/NotificationDTO'; export type { PasswordResetDTO } from './models/PasswordResetDTO'; export type { PasswordUpdateDTO } from './models/PasswordUpdateDTO'; +export type { PointDTO } from './models/PointDTO'; export type { ProfileDTO } from './models/ProfileDTO'; export type { ProgressDTO } from './models/ProgressDTO'; export type { SignUpRequest } from './models/SignUpRequest'; +export type { StreakDTO } from './models/StreakDTO'; export type { TransactionDTO } from './models/TransactionDTO'; export type { UserDTO } from './models/UserDTO'; export type { UserUpdateDTO } from './models/UserUpdateDTO'; diff --git a/src/api/models/BankAccountResponseDTO.ts b/src/api/models/BankAccountResponseDTO.ts new file mode 100644 index 0000000000000000000000000000000000000000..ed03efb50ae0c92f6556f22171663b4ef04d0d94 --- /dev/null +++ b/src/api/models/BankAccountResponseDTO.ts @@ -0,0 +1,9 @@ +/* generated using openapi-typescript-codegen -- do not edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export type BankAccountResponseDTO = { + bban?: number; + balance?: number; +}; + diff --git a/src/api/models/PointDTO.ts b/src/api/models/PointDTO.ts new file mode 100644 index 0000000000000000000000000000000000000000..a122a85f12c3ade9a3d68966565295ce1ddd8d38 --- /dev/null +++ b/src/api/models/PointDTO.ts @@ -0,0 +1,9 @@ +/* generated using openapi-typescript-codegen -- do not edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export type PointDTO = { + currentPoints?: number; + totalEarnedPoints?: number; +}; + diff --git a/src/api/models/ProfileDTO.ts b/src/api/models/ProfileDTO.ts index f3ae4cb44568b5ceba6bd9fe2e611db7a7b42eea..7a621da3b05b3203bfb202cb74aa4ff9e95d954c 100644 --- a/src/api/models/ProfileDTO.ts +++ b/src/api/models/ProfileDTO.ts @@ -2,6 +2,8 @@ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import type { PointDTO } from './PointDTO'; +import type { StreakDTO } from './StreakDTO'; export type ProfileDTO = { id?: number; firstName?: string; @@ -9,7 +11,7 @@ export type ProfileDTO = { profileImage?: number; bannerImage?: number; createdAt?: string; - totalPoints?: number; - currentStreak?: number; + point?: PointDTO; + streak?: StreakDTO; }; diff --git a/src/api/models/StreakDTO.ts b/src/api/models/StreakDTO.ts new file mode 100644 index 0000000000000000000000000000000000000000..07822694f7855d8d7dd631accaa57c71723ee7f9 --- /dev/null +++ b/src/api/models/StreakDTO.ts @@ -0,0 +1,13 @@ +/* generated using openapi-typescript-codegen -- do not edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export type StreakDTO = { + currentStreak?: number; + currentStreakCreatedAt?: string; + currentStreakUpdatedAt?: string; + highestStreak?: number; + highestStreakCreatedAt?: string; + highestStreakEndedAt?: string; +}; + diff --git a/src/api/models/UserDTO.ts b/src/api/models/UserDTO.ts index c7278e15f4e19c8ed1ce3e836fe3840419268bec..f3426ff96a2e26940a922007b6ddfea0e5b9042c 100644 --- a/src/api/models/UserDTO.ts +++ b/src/api/models/UserDTO.ts @@ -2,6 +2,9 @@ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import type { BankAccountResponseDTO } from './BankAccountResponseDTO'; +import type { PointDTO } from './PointDTO'; +import type { StreakDTO } from './StreakDTO'; export type UserDTO = { id?: number; firstName?: string; @@ -12,7 +15,9 @@ export type UserDTO = { createdAt?: string; role?: string; subscriptionLevel?: string; - checkingAccountBBAN?: number; - savingsAccountBBAN?: number; + checkingAccountBBAN?: BankAccountResponseDTO; + savingsAccountBBAN?: BankAccountResponseDTO; + point?: PointDTO; + streak?: StreakDTO; }; diff --git a/src/components/Shop/ItemShop.vue b/src/components/Shop/ItemShop.vue index 15f17c636da19d0e18deb7e1f627027ff310a7ac..da198f45b152a166fe6c70d2c1457d39eb1f1869 100644 --- a/src/components/Shop/ItemShop.vue +++ b/src/components/Shop/ItemShop.vue @@ -3,6 +3,9 @@ <br> <div id="dropdownContainer"> <h1 class="box">Butikk</h1> + <div> + <p class="mb-1 h2" data-cy="points">{{points}}<img src="@/assets/items/pigcoin.png" style="width: 4rem"></p> + </div> </div> <div class="container d-flex justify-content-center"> <div class="row col-md-10"> @@ -83,19 +86,32 @@ import { useUserInfoStore } from '@/stores/UserStore'; import { ItemService } from '@/api'; const products = ref([] as any); +const points = ref(); const getStore = async () => { - const response = await ItemService.getStore(); - products.value = response; - console.log(response); + try { + const response = await ItemService.getStore(); + products.value = response; + } catch (error) { + console.log(error); + } +} + +const getPoints = async () => { + try { + const response = await UserService.getUser(); + points.value = response.point?.currentPoints; + } catch (error) { + console.log(error); + } } const buyItem = async (itemId: number) => { try { const response = await ItemService.buyItem({ itemId: itemId }); console.log(response); - const responseStore = await ItemService.getStore(); - products.value = responseStore; + getStore(); + getPoints(); } catch (error) { console.log(error); } @@ -125,6 +141,7 @@ const buyNoAds = async () => { onMounted(() => { getStore(); + getPoints(); }) </script> @@ -164,6 +181,7 @@ onMounted(() => { justify-content: center; align-items: center; margin-bottom: 2rem; + flex-direction: column; } #background {