diff --git a/src/components/Configuration/ConfigurationSteps/FirstSavingGoal.vue b/src/components/Configuration/ConfigurationSteps/FirstSavingGoal.vue index 97a2423dd702cd11fc796e02a625c345b735859c..226d395bdcc6d796fd2b579872b7c99a07f4e7f8 100644 --- a/src/components/Configuration/ConfigurationSteps/FirstSavingGoal.vue +++ b/src/components/Configuration/ConfigurationSteps/FirstSavingGoal.vue @@ -3,6 +3,7 @@ import BaseInput from '@/components/InputFields/BaseInput.vue' import { ref } from 'vue' import Button1 from '@/components/Buttons/Button1.vue' import { useRouter } from 'vue-router' +import {type CreateGoalDTO, GoalService} from "@/api"; const router = useRouter(); const emit = defineEmits(['changeRouterEvent']) @@ -13,8 +14,9 @@ const titleRef = ref<string>() let descriptionRef = ref<string>() const sumRef = ref<number>() const dateRef = ref<string>() +const errorMessage = ref("") -const handleSubmit = () => { +const handleSubmit = async () => { formRef.value.classList.add("was-validated") const form = formRef.value if (!form.checkValidity()) { @@ -22,7 +24,20 @@ const handleSubmit = () => { } // TODO integrate user creation and goal creation with backend. - + const createGoalPayload: CreateGoalDTO = { + name: titleRef.value, + description: descriptionRef.value, + targetAmount: sumRef.value, + targetDate: dateRef.value + " 00:00:00.000000000", + }; + + try { + await GoalService.createGoal({ requestBody: createGoalPayload }); + await router.push("/") + } catch (error: any) { + console.log(error.message); + errorMessage.value = error.message; + } } const getTodayDate = () => { @@ -98,6 +113,9 @@ const handleSumInputEvent = (newSum: number) => { <div class="confirm-button-container"> <button1 id="confirmButton" @click="handleSubmit" button-text="Continue"></button1> </div> + <div style="color: red"> + {{ errorMessage }} + </div> </div> </template> diff --git a/src/components/Configuration/ConfigurationSteps/SuitableChallenges.vue b/src/components/Configuration/ConfigurationSteps/SuitableChallenges.vue index 439d65333cfacdd03d81e0a281b4d31298b931af..44c9c455d7f5751ce9fabfabd0b53897567bfe3c 100644 --- a/src/components/Configuration/ConfigurationSteps/SuitableChallenges.vue +++ b/src/components/Configuration/ConfigurationSteps/SuitableChallenges.vue @@ -76,7 +76,7 @@ const signUpUser = async () => { role: response.role, }); useUserInfoStore().resetPassword() - await router.push({ name: 'home' }); + await router.push("/first-saving-goal") } catch (error) { errorMsg.value = handleUnknownError(error); @@ -89,7 +89,11 @@ const handleSubmit = () => { } useConfigurationStore().setChallenges(chosenChallenges.value) console.log(useConfigurationStore().getChallenges) - router.push("/first-saving-goal") + try { + signUpUser() + } catch (e) { + console.log(e) + } } </script> diff --git a/src/components/SavingGoalComponents/SavingGoalCreate.vue b/src/components/SavingGoalComponents/SavingGoalCreate.vue index e839cd594e127679b9ea649ee87c7a56487b9240..e5b1d5a99201c6b085e6c8e97cd3783da1dd5120 100644 --- a/src/components/SavingGoalComponents/SavingGoalCreate.vue +++ b/src/components/SavingGoalComponents/SavingGoalCreate.vue @@ -24,7 +24,6 @@ const createGoalClick = async () => { targetDate: date.value + " 00:00:00.000000000", }; - console.log(createGoalPayload) try { let response = await GoalService.createGoal({ requestBody: createGoalPayload }); @@ -85,5 +84,7 @@ const createGoalClick = async () => { .col-lg-8 { width: 63%; margin-top: 50px; + padding-right: 56px; + padding-bottom: 28px; } </style> \ No newline at end of file diff --git a/src/components/SignUp/SignUpForm.vue b/src/components/SignUp/SignUpForm.vue index 660317944e50aa68c7da4050405b8a35570fdaf8..83a5da5494869633326e780f9cc2917e5c954621 100644 --- a/src/components/SignUp/SignUpForm.vue +++ b/src/components/SignUp/SignUpForm.vue @@ -83,17 +83,19 @@ const handleSubmit = async () => { id="firstNameInput" input-id="first-name" type="text" + pattern="^[^\d]+$" label="Fornavn" placeholder="Skriv inn ditt fornavn" - invalid-message="Ugyldig fornavn"/> + invalid-message="Ugyldig fornavn, husk ingen tall"/> <BaseInput :model-value="surnameRef" @input-change-event="handleSurnameInputEvent" id="surnameInput" input-id="surname" type="text" + pattern="^[^\d]+$" label="Etternavn" placeholder="Skriv inn ditt etternavn" - invalid-message="Ugyldig etternavn"/> + invalid-message="Ugyldig etternavn, husk ingen tall"/> <BaseInput :model-value="emailRef" @input-change-event="handleEmailInputEvent" id="emailInput"