diff --git a/web/src/pages/Settings.vue b/web/src/pages/Settings.vue index bd5d478..6efb122 100644 --- a/web/src/pages/Settings.vue +++ b/web/src/pages/Settings.vue @@ -6,24 +6,28 @@ import { TITLE } from "../store/mutation-types" export default defineComponent({ data() { return { - transactionsFile: null, - assignmentsFile: null + transactionsFile: undefined as File | undefined, + assignmentsFile: undefined as File | undefined } }, computed: { filesIncomplete() { - return this.$data.transactionsFile == null || this.$data.assignmentsFile == null; + return this.$data.transactionsFile == undefined || this.$data.assignmentsFile == undefined; } }, mounted() { this.$store.commit(TITLE, "Settings") }, methods: { - gotAssignments(e) { - this.$data.assignmentsFile = e.target.files[0]; + gotAssignments(e : Event) { + const input = (e.target); + if(input.files != null) + this.$data.assignmentsFile = input.files[0]; }, - gotTransactions(e) { - this.$data.transactionsFile = e.target.files[0]; + gotTransactions(e : Event) { + const input = (e.target); + if(input.files != null) + this.$data.transactionsFile = input.files[0]; }, deleteBudget() { fetch("/api/v1/budget/" + this.$store.getters.CurrentBudget.ID, { @@ -47,6 +51,9 @@ export default defineComponent({ // Fix all historic negative category-balances }, ynabImport() { + if (this.$data.transactionsFile == undefined || this.$data.assignmentsFile == undefined) + return + let formData = new FormData(); formData.append("transactions", this.$data.transactionsFile); formData.append("assignments", this.$data.assignmentsFile);