forked from bradtraversy/vue-expense-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6121cf9
commit 525a9f8
Showing
4 changed files
with
52 additions
and
8 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,48 @@ | ||
<template> | ||
<h3>Add new transaction</h3> | ||
<form id="form"> | ||
<form id="form" @submit.prevent="onSubmit"> | ||
<div class="form-control"> | ||
<label for="text">Text</label> | ||
<input type="text" id="text" placeholder="Enter text..." /> | ||
<input type="text" id="text" placeholder="Enter text..." v-model="text" /> | ||
</div> | ||
<div class="form-control"> | ||
<label for="amount" | ||
>Amount <br /> | ||
(negative - expense, positive - income)</label | ||
> | ||
<input type="text" id="amount" placeholder="Enter amount..." /> | ||
<input | ||
type="text" | ||
id="amount" | ||
placeholder="Enter amount..." | ||
v-model="amount" | ||
/> | ||
</div> | ||
<button class="btn">Add transaction</button> | ||
</form> | ||
</template> | ||
|
||
<script setup> | ||
import { useToast } from 'vue-toastification'; | ||
import { ref } from 'vue'; | ||
const text = ref(''); | ||
const amount = ref(''); | ||
// Get toast interface | ||
const toast = useToast(); | ||
const onSubmit = () => { | ||
if (!text.value || !amount.value) { | ||
// Display a toast error message if either field is empty | ||
toast.error('Both fields must be filled.'); | ||
return; | ||
} | ||
// Proceed with form submission logic here... | ||
console.log('Form submitted:', text.value, amount.value); | ||
// Clear form fields | ||
text.value = ''; | ||
amount.value = ''; | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
import './assets/style.css'; | ||
|
||
import { createApp } from 'vue'; | ||
import Toast from 'vue-toastification'; | ||
import 'vue-toastification/dist/index.css'; | ||
import './assets/style.css'; | ||
import App from './App.vue'; | ||
|
||
createApp(App).mount('#app'); | ||
const app = createApp(App); | ||
app.use(Toast); | ||
app.mount('#app'); |