Add loading state and style constants, enhance API key modal with delete

This commit is contained in:
Riccardo Giorato
2025-12-26 12:15:01 +01:00
parent 14b247ffaa
commit 66b252fb2e
17 changed files with 379 additions and 198 deletions
+16 -2
View File
@@ -64,7 +64,7 @@ export default function StoryEditorPage() {
image: page.generatedImageUrl || "",
prompt: page.prompt,
characterUploads: page.characterImageUrls,
style: "noir",
style: storyData.style || "noir",
dbId: page.id,
})))
@@ -76,7 +76,7 @@ export default function StoryEditorPage() {
console.error("Error loading story:", error)
toast({
title: "Error loading story",
description: "Failed to load the story data.",
description: "Failed to load story data.",
variant: "destructive",
duration: 4000,
})
@@ -90,6 +90,20 @@ export default function StoryEditorPage() {
}
}, [slug, toast])
// Keyboard navigation
useEffect(() => {
const handleKeyDown = (e: KeyboardEvent) => {
if (e.key === "ArrowRight") {
setCurrentPage((prev) => (prev < pages.length - 1 ? prev + 1 : prev))
} else if (e.key === "ArrowLeft") {
setCurrentPage((prev) => (prev > 0 ? prev - 1 : prev))
}
}
window.addEventListener("keydown", handleKeyDown)
return () => window.removeEventListener("keydown", handleKeyDown)
}, [pages.length])
const handleAddPage = () => {
const storedKey = localStorage.getItem("together_api_key")
if (!storedKey && pages.length >= 1) {