diff --git a/budgit.client/src/components/AddTransaction.vue b/budgit.client/src/components/AddTransaction.vue index c2ad728..4c7a5ef 100644 --- a/budgit.client/src/components/AddTransaction.vue +++ b/budgit.client/src/components/AddTransaction.vue @@ -1,7 +1,7 @@ @@ -44,31 +44,51 @@ import { computed, reactive, onMounted, ref, watchEffect } from "vue"; export default { // TODO there's probably something wrong with this... props: { - transaction: { - type: Object, - required: true - }, categories: { type: Object, required: true } }, setup(props){ - // create editable object and use watchEffect - const transData = ref({}) - watchEffect(() => { - transData.value = props.transaction - // whatever this doesn't work because WHYNOT - // transData.dollars = props.transaction.amount / 100 - }) + // // create editable object and use watchEffect + // const transData = ref({}) + // watchEffect(() => { + // transData.value = props.transaction + // // whatever this doesn't work because WHYNOT + // // transData.dollars = props.transaction.amount / 100 + // }) return { - transData, - async update() { - // console.log(props.transaction) - // send off request to update transaction + transData: { + date: new Date().toISOString().slice(0,10), + amount: 0, + payee: '', + categoryId: '', + comment: '' + }, + // async update() { + // // console.log(props.transaction) + // // send off request to update transaction + // try { + // // use the editable object instead + // await transactionsService.update(transData.value) + // } catch (error) { + // console.log(error) + // } + // } + async create() { + console.log('create triggered') try { - // use the editable object instead - await transactionsService.update(transData.value) + // TODO WHY is it creating twice? (FIXED) + // TODO certain requests are 400 errors - sanitize + await transactionsService.create(this.transData) + // TODO empty after creation (not working) + this.transData = { + date: new Date().toISOString().slice(0,10), + amount: 0, + payee: '', + categoryId: '', + comment: '' + } } catch (error) { console.log(error) } diff --git a/budgit.client/src/components/Transaction.vue b/budgit.client/src/components/Transaction.vue index 327692f..4017f00 100644 --- a/budgit.client/src/components/Transaction.vue +++ b/budgit.client/src/components/Transaction.vue @@ -81,6 +81,11 @@ export default { async remove() { // TODO need to write CRUD method for this // probably good to write an Are-you-sure Modal too... + try { + await transactionsService.remove(props.transaction._id) + } catch (error) { + console.log(error) + } } } } diff --git a/budgit.client/src/pages/TransactionsPage.vue b/budgit.client/src/pages/TransactionsPage.vue index 3c96416..a577e41 100644 --- a/budgit.client/src/pages/TransactionsPage.vue +++ b/budgit.client/src/pages/TransactionsPage.vue @@ -1,6 +1,7 @@