Skip to content

Commit

Permalink
update new budget form
Browse files Browse the repository at this point in the history
  • Loading branch information
ldscavo committed Oct 6, 2024
1 parent b709610 commit 5b2a006
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 3 deletions.
67 changes: 67 additions & 0 deletions client/src/components/addBudgetV2.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<template>
<div class="container">
<div class="box new-budget" v-if="isAdding">
<form v-on:submit.prevent="addBudget">
<div class="field">
<label class="label">Name</label>
<div class="control">
<input class="input" type="text" v-model="name" placeholder="My Event" />
</div>
</div>
<div class="field">
<label class="label">Amount</label>
<div class="control">
<input class="input" type="number" step="1" v-model="amount" />
</div>
</div>
<div class="field is-grouped">
<div class="control">
<button v-on:click="toggleForm" class="button is-link is-light">
Cancel
</button>
</div>
<div class="control">
<button class="button is-link">Submit</button>
</div>
</div>
<beat-loader v-if="loading" color="#973735" />
</form>
</div>
<a v-if="!isAdding" v-on:click="toggleForm">+ Add New Budget</a>
</div>
</template>

<script>
import budgetService from '../services/budgetService';
export default {
name: 'addBudgetV2',
data: function () {
return {
isAdding: false,
name: "",
amount: 0,
loading: false
}
},
methods: {
toggleForm: function () {
this.isAdding = !this.isAdding;
},
addBudget: async function () {
this.loading = true;
let response = await budgetService.createBudget(this.name, this.amount);
this.$router.push({ path: `/budget/${response.data.data.id}` });
}
}
}
</script>

<style>
.new-budget {
max-width: 500px;
margin: 0 auto;
}
</style>
8 changes: 5 additions & 3 deletions client/src/components/budgetList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@
<budget-card v-for="budget in budgets"
v-bind:key="budget.id"
v-bind:budget="budget" />
</div>
<add-budget />
</div>
<add-budget-v2 />
</div>
</template>

<script>
import budgetService from '../services/budgetService';
import budgetCard from './budgetCard'
import addBudget from './addBudget'
import addBudgetV2 from './addBudgetV2'
export default {
name: 'budgetList',
Expand All @@ -29,7 +30,8 @@ export default {
},
components: {
budgetCard,
addBudget
addBudget,
addBudgetV2
},
mounted: async function() {
let response = await budgetService.getAllBudgets();
Expand Down

0 comments on commit 5b2a006

Please sign in to comment.