MCPcopy Create free account
hub / github.com/mlco2/codecarbon / handleSave

Function handleSave

webapp/src/components/createProjectModal.tsx:42–67  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

40 const [isLoading, setIsLoading] = useState(false);
41
42 const handleSave = async () => {
43 toast.promise(
44 async () => {
45 setIsLoading(true);
46 try {
47 const newProject = await createProject(
48 organizationId,
49 formData,
50 );
51 await onProjectCreated(); // Call the callback to refresh the project list
52 handleClose(); // Automatically close the modal after successful creation
53 return newProject; // Return for the success message
54 } catch (error) {
55 console.error("Failed to create project:", error);
56 throw error; // Rethrow for the error message
57 } finally {
58 setIsLoading(false);
59 }
60 },
61 {
62 loading: "Creating project...",
63 success: "Project created successfully!",
64 error: "Failed to create project",
65 },
66 );
67 };
68
69 const handleClose = () => {
70 // Reset state when closing

Callers

nothing calls this directly

Calls 2

createProjectFunction · 0.90
handleCloseFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…