Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Hinzufügen eines Dashboards um die Transaktionen anzuzeigen #47

Merged
merged 3 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 34 additions & 10 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,37 @@
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="UTF-8">
<link rel="icon" href="/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Vite App</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>

<head>
<meta charset="UTF-8">
<link rel="icon" href="/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Vite App</title>
</head>

<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>

</html>
<style>
html,
body,
#app {
width: 100%;
height: 100%;
}

body,
p,
h1,
h2,
h3,
h4,
h5,
h6,
span,
a {
color: white;
}
</style>
47 changes: 47 additions & 0 deletions src/components/Dashboard.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<template>
<div class="h-full w-full flex justify-center items-center bg-black flex-col">
<h1 class="text-5xl bg-transparent mb-8">Insimodus</h1>
<h2 class="text-3xl italic mb-4">Total amount: {{ totalAmount }}</h2>
<h3 class="text-2xl italic">Transaktionen</h3>
<div class="h-3/4 py-12 w-1/2">
<div v-for="transaction in transactions" class="p-4 flex justify-between w-full"
v-bind:key="transaction.id">
<span class="">{{ transaction.title }}</span>
<span class="">{{ transaction.positiv ? "+" : "-" }}{{ transaction.amount }}</span>
</div>
<div class="mt-4 flex justify-center items-center w-full h-10 border rounded-lg border-dashed cursor-pointer"
@click="addTransaction">
<span class=" text-2xl">+</span>
</div>
</div>
</div>
</template>
<script lang="ts">
import type { Transaction } from '@/models/transaction';
import { getTransactions } from '@/service/data';

export default {
name: "InsimodusDashboard",
data() {
return {
transactions: [] as Transaction[]
}
},
beforeMount() {
this.transactions = getTransactions();
},
computed: {
totalAmount() {
let sum = 0;
this.transactions.map(transaction => sum += transaction.positiv ? transaction.amount : -transaction.amount)

return sum
}
},
methods: {
addTransaction() {
window.location.href = "/add";
}
}
}
</script>
2 changes: 2 additions & 0 deletions src/router/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import Dashboard from '@/components/Dashboard.vue'
import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes: [
{path: "", component: Dashboard}
],
})

Expand Down