253
254 try {
255 const response = await fetch('/api/auth/signup', {
256 method: 'POST',
257 headers: {
294
295 try {
296 const response = await fetch('/api/auth/login', {
297 method: 'POST',
298 headers: {
27 setAiSuggesting(true);
28 try {
29 const response = await fetch("/api/ai/suggest-priority", {
30 method: "POST",
31 headers: { "Content-Type": "application/json" },
276
277 try {
278 const response = await fetch('/api/auth/login', {
279 method: 'POST',
280 headers: {
10 const [aiLoading, setAiLoading] = useState(false);
11
12 // Fetch todos from API
13 const fetchTodos = async () => {
14 try {
15 const response = await fetch("/api/todos");
16 if (response.ok) {
17 const data = await response.json();
19 }
20 } catch (error) {
21 console.error("Error fetching todos:", error);
22 } finally {
23 setLoading(false);
28 const addTodo = async (title: string, description: string, priority: number) => {
29 try {
30 const response = await fetch("/api/todos", {
31 method: "POST",
32 headers: { "Content-Type": "application/json" },
46 const updateTodo = async (id: number, updates: Partial<Todo>) => {
47 try {
48 const response = await fetch(`/api/todos/${id}`, {
49 method: "PUT",
50 headers: { "Content-Type": "application/json" },
64 const deleteTodo = async (id: number) => {
65 try {
66 const response = await fetch(`/api/todos/${id}`, {
67 method: "DELETE",
68 });
80 setAiLoading(true);
81 try {
82 const response = await fetch("/api/ai/prioritize", {
83 method: "POST",
84 headers: { "Content-Type": "application/json" },
87 if (response.ok) {
88 // Refresh todos to get updated AI priorities
89 await fetchTodos();
90 }
91 } catch (error) {
97
98 useEffect(() => {
99 fetchTodos();
100 }, []);
101
17 return c.json(todoList);
18 } catch (error) {
19 console.error("Error fetching todos:", error);
20 return c.json({ error: "Failed to fetch todos" }, 500);
21 }
22});
37 return c.json(todo);
38 } catch (error) {
39 console.error("Error fetching todo:", error);
40 return c.json({ error: "Failed to fetch todo" }, 500);
41 }
42});
178
179// This is the entry point for HTTP vals
180export default app.fetch;
226 const data = Object.fromEntries(formData);
227
228 const response = await fetch('/api/contact', {
229 method: 'POST',
230 headers: {
250 async function loadSessions() {
251 try {
252 const response = await fetch('/api/sessions');
253 if (response.ok) {
254 sessions = await response.json();
298 async function loadSession(sessionId) {
299 try {
300 const response = await fetch(`/api/sessions/${sessionId}`);
301 if (response.ok) {
302 const data = await response.json();
344 if (!currentSession) {
345 try {
346 const response = await fetch('/api/sessions', {
347 method: 'POST',
348 headers: { 'Content-Type': 'application/json' },
371 try {
372 // Send message to API
373 const response = await fetch(`/api/sessions/${currentSession.id}/messages`, {
374 method: 'POST',
375 headers: { 'Content-Type': 'application/json' },
27});
28
29export default app.fetch;
11 return c.json(todoList);
12 } catch (error) {
13 console.error("Error fetching todos:", error);
14 return c.json({ error: "Failed to fetch todos" }, 500);
15 }
16});