Add abilty to switch to edit mode

This commit is contained in:
2022-02-25 20:37:31 +00:00
parent 1e80ba6ca8
commit 97be5abc8c
2 changed files with 67 additions and 4 deletions

View File

@@ -0,0 +1,59 @@
<script lang="ts" setup>
import { computed, ref } from "vue";
import Autocomplete, { Suggestion } from './Autocomplete.vue'
import { Transaction, useAccountStore } from '../stores/budget-account'
const props = defineProps<{
transaction: Transaction
}>()
const TransactionDate = ref(props.transaction.Date.substring(0, 10));
const Payee = ref<Suggestion | undefined>({ID: "", Name: props.transaction.Payee});
const Category = ref<Suggestion | undefined>({ID: "", Name: props.transaction.Category});
const Memo = ref(props.transaction.Memo);
const Amount = ref(props.transaction.Amount);
const payload = computed(() => JSON.stringify({
date: TransactionDate.value,
payee: Payee.value,
category: Category.value,
memo: Memo.value,
amount: Amount.value,
state: "Uncleared"
}));
const accountStore = useAccountStore();
function saveTransaction(e: MouseEvent) {
e.preventDefault();
console.log(props.transaction);
//accountStore.saveTransaction(payload.value);
}
</script>
<template>
<tr>
<td style="width: 90px;" class="text-sm">
<input class="border-b-2 border-black" type="date" v-model="TransactionDate" />
</td>
<td style="max-width: 150px;">
<Autocomplete v-model="Payee" type="payees" />
</td>
<td style="max-width: 200px;">
<Autocomplete v-model="Category" type="categories" />
</td>
<td>
<input class="block w-full border-b-2 border-black" type="text" v-model="Memo" />
</td>
<td style="width: 80px;" class="text-right">
<input
class="text-right block w-full border-b-2 border-black"
type="currency"
v-model="Amount"
/>
</td>
<td style="width: 20px;">
<input type="submit" @click="saveTransaction" value="Save" />
</td>
<td style="width: 20px;"></td>
</tr>
</template>