show laoding state on create project screen

This commit is contained in:
Ramnique Singh 2025-08-18 11:47:26 +05:30
parent 2f33b41a3c
commit abbc2f0d2a

View file

@ -108,22 +108,18 @@ export function BuildAssistantSection({ defaultName }: BuildAssistantSectionProp
}, []); }, []);
const handleCreateAssistant = async () => { const handleCreateAssistant = async () => {
if (!userPrompt.trim()) {
setPromptError("Prompt cannot be empty");
return;
}
setIsCreating(true); setIsCreating(true);
try { try {
await createProjectWithOptions({ await createProjectWithOptions({
name: defaultName, name: defaultName,
prompt: userPrompt, prompt: userPrompt.trim(),
router, router,
onError: (error) => { onError: (error) => {
console.error('Error creating project:', error); console.error('Error creating project:', error);
} }
}); });
} finally { } catch (error) {
console.error('Error creating project:', error);
setIsCreating(false); setIsCreating(false);
} }
}; };
@ -171,15 +167,6 @@ export function BuildAssistantSection({ defaultName }: BuildAssistantSectionProp
} }
}; };
// Handle "I'll build it myself" button
const handleBuildItMyself = async () => {
await createProjectWithOptions({
name: defaultName,
template: 'default',
router
});
};
return ( return (
<> <>
<input <input
@ -278,7 +265,8 @@ export function BuildAssistantSection({ defaultName }: BuildAssistantSectionProp
<Button <Button
variant="primary" variant="primary"
size="sm" size="sm"
onClick={handleBuildItMyself} onClick={handleCreateAssistant}
isLoading={isCreating}
type="button" type="button"
className="bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 hover:bg-gray-50 dark:hover:bg-gray-600 border border-gray-300 dark:border-gray-600" className="bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 hover:bg-gray-50 dark:hover:bg-gray-600 border border-gray-300 dark:border-gray-600"
> >