diff --git a/spec.json b/spec.json index aaf7188fa567a4aabafc50d37f247be3de855e4c..6dc6c6b15a1e598c69d554aa2b7cd9f12e07c8c3 100644 --- a/spec.json +++ b/spec.json @@ -411,21 +411,21 @@ } ], "responses": { - "403": { - "description": "Insufficient points to purchase the item", + "201": { + "description": "Item purchased and added to inventory successfully", "content": { "application/json": { - "schema": { - "type": "string" - } + } } }, - "201": { - "description": "Item purchased and added to inventory successfully", + "403": { + "description": "Insufficient points to purchase the item", "content": { "application/json": { - + "schema": { + "type": "string" + } } } } @@ -867,8 +867,8 @@ } } }, - "401": { - "description": "Invalid credentials", + "404": { + "description": "User not found", "content": { "application/json": { "schema": { @@ -877,8 +877,8 @@ } } }, - "404": { - "description": "User not found", + "401": { + "description": "Invalid credentials", "content": { "application/json": { "schema": { @@ -1590,23 +1590,23 @@ } ], "responses": { - "200": { - "description": "Successfully retrieved the image", + "404": { + "description": "Image not found", "content": { "*/*": { "schema": { - "type": "string", - "format": "binary" + "$ref": "#/components/schemas/ExceptionResponse" } } } }, - "404": { - "description": "Image not found", + "200": { + "description": "Successfully retrieved the image", "content": { "*/*": { "schema": { - "$ref": "#/components/schemas/ExceptionResponse" + "type": "string", + "format": "binary" } } } @@ -2456,10 +2456,10 @@ "subscriptionLevel": { "type": "string" }, - "checkingAccountBBAN": { + "checkingAccount": { "$ref": "#/components/schemas/BankAccountResponseDTO" }, - "savingsAccountBBAN": { + "savingsAccount": { "$ref": "#/components/schemas/BankAccountResponseDTO" }, "point": { diff --git a/src/api/models/UserDTO.ts b/src/api/models/UserDTO.ts index f3426ff96a2e26940a922007b6ddfea0e5b9042c..5d036f873750a6e1dc8ec600620eb6c54ff937a2 100644 --- a/src/api/models/UserDTO.ts +++ b/src/api/models/UserDTO.ts @@ -15,8 +15,8 @@ export type UserDTO = { createdAt?: string; role?: string; subscriptionLevel?: string; - checkingAccountBBAN?: BankAccountResponseDTO; - savingsAccountBBAN?: BankAccountResponseDTO; + checkingAccount?: BankAccountResponseDTO; + savingsAccount?: BankAccountResponseDTO; point?: PointDTO; streak?: StreakDTO; }; diff --git a/src/components/SavingGoal/SavingGoal.vue b/src/components/SavingGoal/SavingGoal.vue index 73b63403e45151d2dce1b24f6da6b60340f1d81e..54cba56fcae6f3c3b0068aaa03a78fd9e06914a6 100644 --- a/src/components/SavingGoal/SavingGoal.vue +++ b/src/components/SavingGoal/SavingGoal.vue @@ -5,6 +5,7 @@ import SavingGoalCreate from "@/components/SavingGoal/SavingGoalCreate.vue"; import SavingGoalDefault from "@/components/SavingGoal/SavingGoalDefault.vue"; import type {GoalDTO} from "@/api"; import {GoalService} from "@/api"; +import {useUserInfoStore} from "@/stores/UserStore"; export default { components: {SavingGoalDefault, SavingGoalCreate, SavingGoalRoadmap, SavingGoalList}, @@ -23,6 +24,7 @@ export default { this.calculateBluePanelMaxHeight(); }, methods: { + useUserInfoStore, calculateBluePanelMaxHeight() { // Query the timeline element const timelineElement = document.querySelector('.timeline'); @@ -73,7 +75,12 @@ export default { </div> <saving-goal-list :key="keyForList" @goToSavingGoal="goToSavingGoal"></saving-goal-list> </div> - <div class="spacer"/> + <div class="spacer"> + <div v-if="!useUserInfoStore().isPremium && !useUserInfoStore().isNoAds" v-for="(challenge, index) in 5" :key="index"> + <img v-if="index % 2 === 0" src="https://www.codefuel.com/wp-content/uploads/2022/10/image1-1.png"> + <img v-else src="https://www.vaultnetworks.com/wp-content/uploads/2012/11/PROMO-BLOG-AD-YELLOW-VERTICAL.png"> + </div> + </div> <saving-goal-create @createGoalClicked="handleCreateGoalClicked" v-if="createClicked"></saving-goal-create> <saving-goal-roadmap :key="key" :selected-goal="selectedGoal" v-else-if="savingGoalClicked"></saving-goal-roadmap> <saving-goal-default v-else></saving-goal-default> @@ -99,8 +106,14 @@ export default { } .spacer { + padding-top: 16px; width: 10%; background-color: transparent; + margin-bottom: 12px; +} + +.spacer img { + width: 100%; } h2 { diff --git a/src/components/SavingGoal/SavingGoalDefault.vue b/src/components/SavingGoal/SavingGoalDefault.vue index 788e7e44ad896fdc1d6c9a0ee879cebdbe0136e3..683d5647eae83ab34e4ce366f31e97adc6b15c12 100644 --- a/src/components/SavingGoal/SavingGoalDefault.vue +++ b/src/components/SavingGoal/SavingGoalDefault.vue @@ -7,9 +7,8 @@ <div class="col-lg-8"> <div class="container text-center"> <div class="d-flex flex-column justify-content-center align-items-center"> - <h1 class="">Velkommen til <span>SpareSti</span></h1> - <br> - <p class="">Kom i økonomisk form: Ta på deg våre spareutfordringer!<br></p> + <h1>Velkommen til <span>SpareSti</span></h1> + <p style="margin-top: 32px">Kom i økonomisk form: Ta på deg våre spareutfordringer!<br></p> <img src="../../assets/savingPigRun.png" alt="SpareSti-logo"> </div> </div> diff --git a/src/components/SavingGoal/SavingGoalRoadmap.vue b/src/components/SavingGoal/SavingGoalRoadmap.vue index 54a8ffd8fdf1e8652fbe69791511e41a52441ae4..fe1a241977253da06dda6547cf78a0b8d0b27077 100644 --- a/src/components/SavingGoal/SavingGoalRoadmap.vue +++ b/src/components/SavingGoal/SavingGoalRoadmap.vue @@ -1,7 +1,14 @@ <script lang="ts"> import {CategoryScale, Chart as ChartJS, Legend, LinearScale, LineElement, PointElement, Title, Tooltip} from 'chart.js' import {Line} from 'vue-chartjs' -import type {ChallengeDTO, CreateGoalDTO, GoalDTO, MarkChallengeDTO} from "@/api"; +import { + type ChallengeDTO, + type CreateGoalDTO, + type GoalDTO, + type MarkChallengeDTO, + TransactionControllerService, type TransactionDTO, + UserService +} from "@/api"; import {GoalService} from '@/api' import {useUserInfoStore} from "@/stores/UserStore"; @@ -171,6 +178,7 @@ export default { } this.addDataToChart(amount, dateString); + await this.transferMoney(amount) this.calculateSavedSoFar(); } catch (error: any) { console.log(error.message); @@ -334,8 +342,18 @@ export default { } }, - transferMoney(amount: number) { - //need users bank accounts + async transferMoney(amount: number) { + let response = await UserService.getUser() + let spendingAccount = response.checkingAccount?.bban + let savingAccount = response.savingsAccount?.bban + + const transactionPayload: TransactionDTO = { + debtorBBAN: spendingAccount, + creditorBBAN: savingAccount, + amount: amount, + } + + await TransactionControllerService.transferToSelf({requestBody: transactionPayload}) }, }, }; diff --git a/src/components/Settings/SettingsBank.vue b/src/components/Settings/SettingsBank.vue index d5142d2130fd5ae83927cd8d2da5fce6bca311bb..dfcc04ff941a34ce32c3d2c0271b0c11580343e8 100644 --- a/src/components/Settings/SettingsBank.vue +++ b/src/components/Settings/SettingsBank.vue @@ -27,22 +27,38 @@ </form> <hr> <div class="form-group mb-0"> - <label class="d-block">Betalingshistorikk</label> - <div class="border border-gray-500 bg-gray-200 p-3 text-center font-size-sm">Du har ikke foretatt noen betaling.</div> + <label class="d-block">Saldo oversikt</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"> + <div class="card-box tilebox-one"><i class="icon-rocket float-right text-muted"></i> + <h6 class="text-muted text-uppercase mt-0">Brukskonto</h6> + <h2 class="">{{spendingAccountBalance}} Kr</h2></div> + </div> + <div class="col-sm-6"> + <div class="card-box tilebox-one"><i class="icon-rocket float-right text-muted"></i> + <h6 class="text-muted text-uppercase mt-0">Sparekonto</h6> + <h2 class="">{{savingsAccountBalance}} Kr</h2></div> + </div> + </div> + </div> </div> </div> </template> <script setup lang="ts"> -import { ref } from 'vue'; +import { ref, onMounted } from 'vue'; import BaseInput from '@/components/BaseComponents/Input/BaseInput.vue'; import type { BankAccountDTO } 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 handleSpendingInputEvent = (newValue: any) => { @@ -66,7 +82,7 @@ const handleSavingSubmit = async () => { try { UserService.selectBankAccount({ requestBody: updateSaving }) } catch (err) { - console.error(err) + handleUnknownError(err) } } @@ -80,7 +96,18 @@ const handleSpendingSubmit = async () => { try { UserService.selectBankAccount({ requestBody: updateSaving }) } catch (err) { - console.error(err) + handleUnknownError(err) } } + +onMounted(getAccountInfo) +async function getAccountInfo() { + try { + let response = await UserService.getUser() + savingsAccountBalance.value = response.savingsAccount?.balance + spendingAccountBalance.value = response.checkingAccount?.balance + } catch (err) { + handleUnknownError(err) + } +} </script> \ No newline at end of file