Fix number-input not returning numbers

This commit is contained in:
Jan Bader 2022-04-08 18:23:29 +00:00
parent 249aa534c8
commit 3ca7bfeade
3 changed files with 18 additions and 8 deletions

View File

@ -11,7 +11,7 @@ import (
)
type SetCategoryAssignmentRequest struct {
Assigned string
Assigned float64
}
func (h *Handler) setCategoryAssignment(c *gin.Context) {

View File

@ -1,17 +1,27 @@
<script lang="ts" setup>
const props = defineProps<{
modelValue?: number | string
modelValue?: number | string,
type: string,
}>();
const emits = defineEmits<{
(e: "update:modelValue", value: number | string): void
}>();
function valueChanged(e: Event) {
const target = <HTMLInputElement>e.target;
switch (props.type) {
case "number":
emits('update:modelValue', target.valueAsNumber);
break;
default:
console.log("STR-INPUT", props.type)
emits('update:modelValue', target.value)
break;
}
}
</script>
<template>
<input
:value="modelValue"
class="dark:bg-slate-900"
@input="emits('update:modelValue', ($event.target as HTMLInputElement)?.value)"
>
<input :value="modelValue" :type="type" class="dark:bg-slate-900" @input="valueChanged" />
</template>

View File

@ -61,7 +61,7 @@ export const useAccountStore = defineStore("budget/account", {
return (category: Category): number => {
return (
category.AvailableLastMonth +
Number(category.Assigned) +
category.Assigned +
category.Activity
);
};