Skip to content
Snippets Groups Projects
Commit 512f9299 authored by Eline Evje's avatar Eline Evje
Browse files

refactor: ran format check

parent 82393e71
No related branches found
No related tags found
3 merge requests!66Final merge,!9Saving goal suggestion,!4Pipeline fix
Pipeline #274925 passed
<script setup lang="ts"> <script setup lang="ts">
import { ref, watch } from 'vue'; import { ref, watch } from 'vue'
import ContinueButtonComponent from '@/components/ContinueButtonComponent.vue'; import ContinueButtonComponent from '@/components/ContinueButtonComponent.vue'
import router from '@/router'; import router from '@/router'
const savingsGoal = ref(''); const savingsGoal = ref('')
const rawAmount = ref(''); const rawAmount = ref('')
const validateAmount = () => { const validateAmount = () => {
const validPattern = /^(\d+)?(,\d*)?$/; const validPattern = /^(\d+)?(,\d*)?$/
if (!validPattern.test(rawAmount.value)) { if (!validPattern.test(rawAmount.value)) {
rawAmount.value = rawAmount.value.slice(0, -1); rawAmount.value = rawAmount.value.slice(0, -1)
} else if (rawAmount.value.includes(',')) { } else if (rawAmount.value.includes(',')) {
rawAmount.value = rawAmount.value.replace(/,+/g, ','); rawAmount.value = rawAmount.value.replace(/,+/g, ',')
} }
}; }
const checkNegative = () => { const checkNegative = () => {
const numericValue = parseFloat(rawAmount.value.replace(',', '.')); const numericValue = parseFloat(rawAmount.value.replace(',', '.'))
if (numericValue < 0) { if (numericValue < 0) {
rawAmount.value = ''; rawAmount.value = ''
} }
}; }
watch(rawAmount, validateAmount); watch(rawAmount, validateAmount)
watch(() => parseFloat(rawAmount.value.replace(',', '.')), checkNegative); watch(() => parseFloat(rawAmount.value.replace(',', '.')), checkNegative)
const onButtonClick = () => { const onButtonClick = () => {
router.push('/home'); router.push('/home')
}; }
</script> </script>
<template> <template>
<div class="flex flex-col items-center justify-center min-h-screen px-4 text-center"> <div class="flex flex-col items-center justify-center min-h-screen px-4 text-center">
<div class="mb-20"> <div class="mb-20">
<div class="flex flex-col items-center justify-center bg-white shadow-md rounded-lg p-16" style="width: 400px; height: 400px;"> <div
class="flex flex-col items-center justify-center bg-white shadow-md rounded-lg p-16"
style="width: 400px; height: 400px"
>
<div class="mb-6 w-full text-left"> <div class="mb-6 w-full text-left">
<label for="savings-goal" class="block text-xl font-bold mb-2">Jeg vil spare til:</label> <label for="savings-goal" class="block text-xl font-bold mb-2"
>Jeg vil spare til:</label
>
<input <input
type="text" type="text"
id="savings-goal" id="savings-goal"
v-model="savingsGoal" v-model="savingsGoal"
:class="{'border-[var(--green)]': savingsGoal.valueOf(), 'border-gray-300': !savingsGoal.valueOf()}" :class="{
'border-[var(--green)]': savingsGoal.valueOf(),
'border-gray-300': !savingsGoal.valueOf()
}"
class="border-2 block w-full rounded-md shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50 text-xl" class="border-2 block w-full rounded-md shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50 text-xl"
placeholder=""> placeholder=""
/>
</div> </div>
<div class="mb-8 w-full flex items-center"> <div class="mb-8 w-full flex items-center">
<label for="amount" class="shrink-0 text-xl font-bold mr-2">Jeg vil spare:</label> <label for="amount" class="shrink-0 text-xl font-bold mr-2"
>Jeg vil spare:</label
>
<input <input
type="text" type="text"
id="amount" id="amount"
v-model="rawAmount" v-model="rawAmount"
:class="{'border-[var(--green)]': rawAmount.valueOf(), 'border-gray-300': !rawAmount.valueOf()}" :class="{
class="border-2 rounded-md shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50 text-xl mr-2 block w-full" 'border-[var(--green)]': rawAmount.valueOf(),
placeholder="" 'border-gray-300': !rawAmount.valueOf()
min="0"> }"
class="border-2 rounded-md shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50 text-xl mr-2 block w-full"
placeholder=""
min="0"
/>
<span class="shrink-0 text-xl font-bold">kr</span> <span class="shrink-0 text-xl font-bold">kr</span>
</div> </div>
<div class="w-full px-4 py-2"> <div class="w-full px-4 py-2">
<img src="@/assets/coins.png" alt="Savings" class="mx-auto w-36 h-32"> <img src="@/assets/coins.png" alt="Savings" class="mx-auto w-36 h-32" />
</div> </div>
</div> </div>
</div> </div>
<ContinueButtonComponent @click="onButtonClick" class="px-10 py-3 text-2xl font-bold self-end"></ContinueButtonComponent> <ContinueButtonComponent
@click="onButtonClick"
class="px-10 py-3 text-2xl font-bold self-end"
></ContinueButtonComponent>
</div> </div>
</template> </template>
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