Add loading steps with interval and fix style class formatting
This commit is contained in:
@@ -199,6 +199,14 @@ export function ComicCreationForm({
|
|||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
setLoadingStep(0);
|
setLoadingStep(0);
|
||||||
|
|
||||||
|
// Progress through loading steps
|
||||||
|
const stepInterval = setInterval(() => {
|
||||||
|
setLoadingStep((prev) => {
|
||||||
|
if (prev < 3) return prev + 1;
|
||||||
|
return prev;
|
||||||
|
});
|
||||||
|
}, 3500);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Check credits
|
// Check credits
|
||||||
const hasApiKey = !!apiKey;
|
const hasApiKey = !!apiKey;
|
||||||
@@ -218,12 +226,14 @@ export function ComicCreationForm({
|
|||||||
description: "Failed to check credits",
|
description: "Failed to check credits",
|
||||||
variant: "destructive",
|
variant: "destructive",
|
||||||
});
|
});
|
||||||
|
clearInterval(stepInterval);
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (creditsData.creditsRemaining === 0) {
|
if (creditsData.creditsRemaining === 0) {
|
||||||
setShowApiModal(true);
|
setShowApiModal(true);
|
||||||
|
clearInterval(stepInterval);
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -259,6 +269,7 @@ export function ComicCreationForm({
|
|||||||
|
|
||||||
// Clear the draft since submission was successful
|
// Clear the draft since submission was successful
|
||||||
localStorage.removeItem(PROMPT_STORAGE_KEY);
|
localStorage.removeItem(PROMPT_STORAGE_KEY);
|
||||||
|
clearInterval(stepInterval);
|
||||||
// Redirect to the story editor using slug
|
// Redirect to the story editor using slug
|
||||||
router.push(`/story/${result.storySlug}`);
|
router.push(`/story/${result.storySlug}`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -277,6 +288,7 @@ export function ComicCreationForm({
|
|||||||
variant: "destructive",
|
variant: "destructive",
|
||||||
duration: 4000,
|
duration: 4000,
|
||||||
});
|
});
|
||||||
|
clearInterval(stepInterval);
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -300,6 +312,7 @@ export function ComicCreationForm({
|
|||||||
"Enhancing prompt...",
|
"Enhancing prompt...",
|
||||||
"Generating scenes...",
|
"Generating scenes...",
|
||||||
"Creating your comic...",
|
"Creating your comic...",
|
||||||
|
"Finishing up...",
|
||||||
];
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -410,8 +423,7 @@ export function ComicCreationForm({
|
|||||||
setStyle(styleOption.id);
|
setStyle(styleOption.id);
|
||||||
setShowStyleDropdown(false);
|
setShowStyleDropdown(false);
|
||||||
}}
|
}}
|
||||||
className={`w-full text-left px-3 py-2 rounded text-xs transition-colors flex items-center justify-between ${
|
className={`w-full text-left px-3 py-2 rounded text-xs transition-colors flex items-center justify-between ${style === styleOption.id
|
||||||
style === styleOption.id
|
|
||||||
? "bg-indigo/10 text-indigo"
|
? "bg-indigo/10 text-indigo"
|
||||||
: "text-muted-foreground hover:bg-white/5 hover:text-white"
|
: "text-muted-foreground hover:bg-white/5 hover:text-white"
|
||||||
}`}
|
}`}
|
||||||
|
|||||||
Reference in New Issue
Block a user