chore: Fix editing
This commit is contained in:
parent
28c0420354
commit
bb67052158
6 changed files with 30 additions and 17 deletions
|
@ -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, {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue