Skip to content
Snippets Groups Projects
Commit 17f456ea authored by heikkkk's avatar heikkkk
Browse files

fix: bank account

parent e8e628be
Branches errorFix
No related tags found
2 merge requests!101fix: bank account,!99fix: new OpenAPI spec
Pipeline #284971 failed
......@@ -4,11 +4,13 @@ import BaseButton from '@/components/BaseComponents/Buttons/BaseButton.vue'
import { ref } from 'vue'
import BaseInput from '@/components/BaseComponents/Input/BaseInput.vue'
import { useConfigurationStore } from '@/stores/ConfigurationStore'
import { AccountControllerService } from '@/api'
import handleUnknownError from '@/components/Exceptions/unkownErrorHandler'
const router = useRouter();
const formRef = ref();
const spendingAccount = ref<string>('');
const checkingAccount = ref<string>('');
const savingsAccount = ref<string>('');
let errorMsg = ref('');
......@@ -17,19 +19,25 @@ const emit = defineEmits(['changeRouterEvent'])
emit('changeRouterEvent', '/bank-account')
const handleSpendingInputEvent = (newValue: any) => {
spendingAccount.value = newValue
checkingAccount.value = newValue
}
const handleSavingInputEvent = (newValue: any) => {
savingsAccount.value = newValue
}
const handleSubmit = () => {
const handleSubmit = async () => {
formRef.value.classList.add("was-validated")
const form = formRef.value;
if (form.checkValidity()) {
useConfigurationStore().setSpendingAccount(Number(spendingAccount.value))
useConfigurationStore().setSavingsAccount(Number(savingsAccount.value))
router.push("/commitment")
try {
await AccountControllerService.getAccountsByBban({bban: Number(checkingAccount.value)})
await AccountControllerService.getAccountsByBban({bban: Number(savingsAccount.value)})
useConfigurationStore().setChekingAccountBBAN(Number(checkingAccount.value))
useConfigurationStore().setSavingsAccountBBAN(Number(savingsAccount.value))
await router.push("/commitment")
} catch (error) {
errorMsg.value = handleUnknownError(error)
}
}
}
</script>
......@@ -41,7 +49,7 @@ const handleSubmit = () => {
</h3>
<form ref="formRef">
<BaseInput data-cy="spending-account-input"
:model-value="spendingAccount"
:model-value="checkingAccount"
@input-change-event="handleSpendingInputEvent"
id="spending-account-base-input"
input-id="spending-account-input"
......
......@@ -5,7 +5,7 @@ import BaseButton from '@/components/BaseComponents/Buttons/BaseButton.vue'
import { ref } from 'vue'
import { useConfigurationStore } from '@/stores/ConfigurationStore'
import { useUserInfoStore } from '@/stores/UserStore'
import { AuthenticationService, type BankAccountDTO, OpenAPI, type SignUpRequest, UserService } from '@/api'
import { AuthenticationService, OpenAPI, type SignUpRequest, UserService } from '@/api'
import handleUnknownError from '@/components/Exceptions/unkownErrorHandler'
const router = useRouter();
......@@ -61,7 +61,9 @@ const signUpUser = async () => {
commitment: useConfigurationStore().getCommitment,
experience: useConfigurationStore().getExperience,
challengeTypes: useConfigurationStore().getChallenges
}
},
checkingAccountBBAN: useConfigurationStore().getCheckingAccountBBAN,
savingsAccountBBAN: useConfigurationStore().getSavingsAccountBBAN,
};
console.log(signUpPayLoad)
......@@ -78,22 +80,6 @@ const signUpUser = async () => {
});
}
const updateBankAccounts = async () => {
const spendingRequest: BankAccountDTO = {
bban: useConfigurationStore().getSpendingAccount,
bankAccountType: "CHECKING_ACCOUNT"
}
const savingRequest: BankAccountDTO = {
bban: useConfigurationStore().getSavingsAccount,
bankAccountType: "SAVING_ACCOUNT"
}
await UserService.selectBankAccount({requestBody: spendingRequest})
await UserService.selectBankAccount({requestBody: savingRequest})
}
const handleSubmit = async () => {
if (chosenChallenges.value.length === 0) {
chosenChallenges.value = challenges
......@@ -102,7 +88,6 @@ const handleSubmit = async () => {
try {
await signUpUser();
await updateBankAccounts();
useUserInfoStore().resetPassword()
await router.push("/first-saving-goal")
......
......@@ -347,8 +347,8 @@ export default {
async transferMoney(amount: number) {
let response = await UserService.getUser()
let spendingAccount = response.checkingAccount?.bban
let savingAccount = response.savingsAccount?.bban
let spendingAccount = response.checkingAccountBBAN
let savingAccount = response.savingsAccountBBAN
const transactionPayload: TransactionDTO = {
debtorBBAN: spendingAccount,
......
import { defineStore } from 'pinia'
export const useConfigurationStore = defineStore('ConfigurationStore', {
state: () => ({
spendingAccount: 0,
savingsAccount: 0,
chekingAccountBBAN: 0,
savingsAccountBBAN: 0,
commitment: '',
experience: '',
challenges: [] as Array<string>,
}),
actions: {
setSpendingAccount(newValue: number) {
this.spendingAccount = newValue;
setChekingAccountBBAN(newValue: number) {
this.chekingAccountBBAN = newValue;
},
setSavingsAccount(newValue: number) {
this.savingsAccount = newValue
setSavingsAccountBBAN(newValue: number) {
this.savingsAccountBBAN = newValue
},
setCommitment(commitment: string) {
this.commitment = commitment
......@@ -30,11 +30,11 @@ export const useConfigurationStore = defineStore('ConfigurationStore', {
}
},
getters: {
getSpendingAccount(): number {
return this.spendingAccount
getCheckingAccountBBAN(): number {
return this.chekingAccountBBAN
},
getSavingsAccount(): number {
return this.savingsAccount
getSavingsAccountBBAN(): number {
return this.savingsAccountBBAN
},
getCommitment(): string {
return this.commitment
......
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