chore: Fix editing

This commit is contained in:
Jan K9f 2025-06-23 10:57:16 +02:00
commit bb67052158
Signed by: jank
GPG key ID: 22BEAC760B3333D6
6 changed files with 30 additions and 17 deletions

View file

@ -1,10 +1,7 @@
import { JsonPipe } from '@angular/common';
import { Component, computed, effect, Input, resource } from '@angular/core';
import { CreateTodo } from '../create-todo/create-todo';
import { Component, EventEmitter, Output, resource } from '@angular/core';
@Component({
selector: 'app-todo-table',
imports: [JsonPipe, CreateTodo],
templateUrl: './todo-table.html',
styleUrl: './todo-table.css',
})
@ -12,10 +9,14 @@ export class TodoTable {
public tasks = resource({
loader: async (): Promise<Task[]> => {
const response = await fetch('http://localhost:2000/api/tasks');
return await response.json();
return (await response.json()) as Task[];
},
});
@Input({ required: true }) editTask!: (task: Task) => void;
@Output() editTaskEvent = new EventEmitter<Task>();
editTask(task: Task) {
this.editTaskEvent.emit(task);
}
toggleTaskDoneStatus(task: Task) {
fetch('http://localhost:2000/api/tasks/' + task.id, {