-
-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support creation of transactions in SPA prototype
- Loading branch information
1 parent
d0c069f
commit bd0e731
Showing
5 changed files
with
108 additions
and
1 deletion.
There are no files selected for viewing
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
59 changes: 59 additions & 0 deletions
59
resources/assets/js/prototype/screens/Transactions/Create.vue
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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<script setup> | ||
import axios from 'axios'; | ||
import { ref } from 'vue'; | ||
import Navigation from '../../components/Navigation.vue'; | ||
const type = ref('earning'); | ||
const happened_on = ref('2023-11-02'); | ||
const description = ref(''); | ||
const amount = ref(10.00); | ||
const create = () => { | ||
axios.post('/api/transactions', { | ||
type: type.value, | ||
happened_on: happened_on.value, | ||
description: description.value, | ||
amount: amount.value, | ||
}, { | ||
headers: { | ||
'api-key': localStorage.getItem('api_key'), | ||
}, | ||
}) | ||
.then(() => { | ||
alert('wtf, dat werkte'); | ||
}) | ||
.catch(() => { | ||
alert('Something went wrong'); | ||
}); | ||
}; | ||
</script> | ||
|
||
<template> | ||
<div> | ||
<Navigation /> | ||
<div class="max-w-sm mx-auto my-10 space-y-5"> | ||
<div class="flex space-x-3"> | ||
<button class="px-4 py-2 text-sm border border-gray-200 rounded-md" :class="{ 'bg-gray-100': type === 'earning' }" @click="type = 'earning'">Earning</button> | ||
<button class="px-4 py-2 text-sm border border-gray-200 rounded-md" :class="{ 'bg-gray-100': type === 'spending' }" @click="type = 'spending'">Spending</button> | ||
</div> | ||
<div v-if="type === 'spending'"> | ||
<label class="mb-1 block text-sm">Tag</label> | ||
<input class="w-full px-3 py-2 text-sm border rounded-md" type="text" value="Coming soon" disabled /> | ||
</div> | ||
<div> | ||
<label class="mb-1 block text-sm">Date</label> | ||
<input class="w-full px-3 py-2 text-sm border rounded-md" type="text" v-model="happened_on" /> | ||
</div> | ||
<div> | ||
<label class="mb-1 block text-sm">Description</label> | ||
<input class="w-full px-3 py-2 text-sm border rounded-md" type="text" :placeholder="type === 'earning' ? 'Paycheck February' : 'Birthday present for Angela'" v-model="description" /> | ||
</div> | ||
<div> | ||
<label class="mb-1 block text-sm">Amount</label> | ||
<input class="w-full px-3 py-2 text-sm border rounded-md" type="text" v-model="amount" /> | ||
</div> | ||
<button class="px-4 py-2 text-sm border border-gray-200 rounded-md" @click="create()">Create</button> | ||
</div> | ||
</div> | ||
</template> |
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