Track frontend as regular files instead of a submodule
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import { Task } from '../types';
|
||||
|
||||
export const generatePlan = async (goal: string): Promise<Task[]> => {
|
||||
try {
|
||||
const response = await fetch('/api/generate-plan', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({ goal }),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const errorData = await response.json().catch(() => ({ error: 'Failed to generate plan from server.' }));
|
||||
throw new Error(errorData.error || `Server responded with status ${response.status}`);
|
||||
}
|
||||
|
||||
const tasks: Omit<Task, 'status'>[] = await response.json();
|
||||
|
||||
// Add the 'status' property to each task, same as before.
|
||||
return tasks.map(task => ({
|
||||
...task,
|
||||
status: 'todo',
|
||||
}));
|
||||
} catch (error) {
|
||||
console.error("Error generating plan:", error);
|
||||
const message = error instanceof Error ? error.message : "An unknown error occurred.";
|
||||
throw new Error(`Failed to generate a plan. ${message}`);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user