This commit is contained in:
eneller
2026-03-06 19:07:22 +01:00
parent 0dabdaa136
commit 8525b7c074
8 changed files with 26 additions and 26 deletions

View File

@@ -27,7 +27,7 @@
<i class="bi bi-person-fill fs-4 text-secondary"></i> <i class="bi bi-person-fill fs-4 text-secondary"></i>
</div> </div>
<div class="text-start"> <div class="text-start">
<h6 class="mb-0">{{ transaction.partner }}</h6> <h6 class="mb-0">{{ transaction.sender }}</h6>
<small class="text-muted">{{ transaction.date | date:'medium' }}</small> <small class="text-muted">{{ transaction.date | date:'medium' }}</small>
</div> </div>
</div> </div>
@@ -35,7 +35,6 @@
<h6 class="mb-0" [class.text-success]="transaction.amount > 0" [class.text-danger]="transaction.amount < 0"> <h6 class="mb-0" [class.text-success]="transaction.amount > 0" [class.text-danger]="transaction.amount < 0">
{{ transaction.amount | currency }} {{ transaction.amount | currency }}
</h6> </h6>
<small class="text-muted">{{ transaction.type }}</small>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -1,7 +1,7 @@
import { CommonModule, CurrencyPipe, DatePipe } from '@angular/common'; import { CommonModule, CurrencyPipe, DatePipe } from '@angular/common';
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { APIService } from '../../services/api'; import { APIService } from '../../services/api';
import { Transaction } from '@shared/interfaces/transaction'; import Transaction from '@model/transaction';
@Component({ @Component({
selector: 'app-screen-profile', selector: 'app-screen-profile',

View File

@@ -1,7 +1,7 @@
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { Transaction } from '@shared/interfaces/transaction' import Transaction from '@model/transaction'
@Injectable({ @Injectable({
providedIn: 'root', providedIn: 'root',

View File

@@ -5,6 +5,8 @@ services:
POSTGRES_PASSWORD: pass POSTGRES_PASSWORD: pass
ports: ports:
- "5432:5432" - "5432:5432"
volumes:
- ./.docker:/var/lib/postgresql
adminer: adminer:
image: adminer image: adminer

View File

@@ -4,22 +4,22 @@ import User from './user';
@Table @Table
export default class Transaction extends Model{ export default class Transaction extends Model{
@Column @Column
amount: number; amount!: number;
@Column @Column
@ForeignKey(()=> User) @ForeignKey(()=> User)
senderID: string; senderID!: string;
@BelongsTo(() => User, 'senderID') @BelongsTo(() => User, 'senderID')
sender: User; sender!: User;
@Column @Column
@ForeignKey(()=> User) @ForeignKey(()=> User)
receiverID: string; receiverID!: string;
@BelongsTo(() => User, 'receiverID') @BelongsTo(() => User, 'receiverID')
receiver: User; receiver!: User;
@CreatedAt @CreatedAt
creationDate: Date; date!: Date;
} }

View File

@@ -4,18 +4,18 @@ import { Table, Column, Model, CreatedAt, DataType} from 'sequelize-typescript';
export default class User extends Model{ export default class User extends Model{
@Column({primaryKey: true, unique: true, allowNull: false}) @Column({primaryKey: true, unique: true, allowNull: false})
userID: string; userID!: string;
@Column @Column
displayName: string; displayName!: string;
@Column(DataType.DECIMAL(20,2)) @Column(DataType.DECIMAL(20,2))
balance: number; balance!: number;
@Column @Column
password: string; password!: string;
@CreatedAt @CreatedAt
creationDate: Date; creationDate!: Date;
} }

View File

@@ -1,17 +1,16 @@
import express from 'express'; import express from 'express';
import { Transaction } from "@shared/interfaces/transaction" import Transaction from '../model/transaction';
const router = express.Router(); const router = express.Router();
// Mock data router.get('/', async (req, res) => {
const mockTransactions: Transaction[] = [ try {
{ id: '1', partner: 'Alice Smith', amount: 50.00, date: new Date('2026-03-01'), type: 'Received' }, const transactions = await Transaction.findAll({ limit: 10 });
{ id: '2', partner: 'Bob Johnson', amount: -25.50, date: new Date('2026-02-28'), type: 'Sent' }, res.json(transactions);
]; } catch (err) {
console.error('Failed to fetch transactions:', err);
// GET /api/transactions res.status(500).json({ error: 'Failed to fetch transactions' });
router.get('/', (req, res) => { }
res.json(mockTransactions);
}); });
export default router; export default router;

View File

@@ -10,7 +10,7 @@
"module": "es2022", "module": "es2022",
"lib": ["es2022", "dom"], "lib": ["es2022", "dom"],
"paths": { "paths": {
"@shared/*": ["shared/src/*"] "@model/*": ["server/src/model/*"]
} }
}, },
"exclude": ["node_modules"] "exclude": ["node_modules"]