Fix: Ensure all skills are tracked as files, not submodules

This commit is contained in:
sck_0
2026-01-14 18:48:48 +01:00
parent 7f46ed8ca1
commit 8bd204708b
1113 changed files with 82065 additions and 2 deletions

View File

@@ -0,0 +1,81 @@
import { useState, useEffect } from 'react';
import { Todo, fetchTodos, createTodo, updateTodo, deleteTodo } from '../api/todos';
interface UseTodosReturn {
todos: Todo[];
loading: boolean;
error: string | null;
addTodo: (title: string) => Promise<void>;
toggleTodo: (id: number) => Promise<void>;
removeTodo: (id: number) => Promise<void>;
}
export const useTodos = (): UseTodosReturn => {
const [todos, setTodos] = useState<Todo[]>([]);
const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(null);
// Fetch todos on mount
useEffect(() => {
const loadTodos = async () => {
try {
setLoading(true);
setError(null);
const data = await fetchTodos();
setTodos(data);
} catch (err) {
setError('Failed to load todos');
console.error(err);
} finally {
setLoading(false);
}
};
loadTodos();
}, []);
const addTodo = async (title: string) => {
try {
const newTodo = await createTodo(title);
setTodos([newTodo, ...todos]);
} catch (err) {
setError('Failed to create todo');
console.error(err);
throw err;
}
};
const toggleTodo = async (id: number) => {
const todo = todos.find(t => t.id === id);
if (!todo) return;
try {
const updatedTodo = await updateTodo(id, !todo.completed);
setTodos(todos.map(t => t.id === id ? updatedTodo : t));
} catch (err) {
setError('Failed to update todo');
console.error(err);
throw err;
}
};
const removeTodo = async (id: number) => {
try {
await deleteTodo(id);
setTodos(todos.filter(t => t.id !== id));
} catch (err) {
setError('Failed to delete todo');
console.error(err);
throw err;
}
};
return {
todos,
loading,
error,
addTodo,
toggleTodo,
removeTodo,
};
};