Update story-editor-client.tsx
This commit is contained in:
@@ -55,6 +55,7 @@ export function StoryEditorClient() {
|
|||||||
const [showGenerateModal, setShowGenerateModal] = useState(false);
|
const [showGenerateModal, setShowGenerateModal] = useState(false);
|
||||||
const [showDeleteDialog, setShowDeleteDialog] = useState(false);
|
const [showDeleteDialog, setShowDeleteDialog] = useState(false);
|
||||||
const [pageToDelete, setPageToDelete] = useState<number | null>(null);
|
const [pageToDelete, setPageToDelete] = useState<number | null>(null);
|
||||||
|
const [showRedrawDialog, setShowRedrawDialog] = useState(false);
|
||||||
const [loadingPageId, setLoadingPageId] = useState<number | null>(null);
|
const [loadingPageId, setLoadingPageId] = useState<number | null>(null);
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
const [existingCharacterImages, setExistingCharacterImages] = useState<
|
const [existingCharacterImages, setExistingCharacterImages] = useState<
|
||||||
@@ -163,11 +164,16 @@ export function StoryEditorClient() {
|
|||||||
setShowGenerateModal(true);
|
setShowGenerateModal(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleRedrawPage = async () => {
|
const handleRedrawPage = () => {
|
||||||
if (!apiKey) {
|
if (!apiKey) {
|
||||||
setShowApiModal(true);
|
setShowApiModal(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
setShowRedrawDialog(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
const confirmRedrawPage = async () => {
|
||||||
|
setShowRedrawDialog(false);
|
||||||
|
|
||||||
const currentPageData = pages[currentPage];
|
const currentPageData = pages[currentPage];
|
||||||
if (!currentPageData) return;
|
if (!currentPageData) return;
|
||||||
@@ -179,7 +185,7 @@ export function StoryEditorClient() {
|
|||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
"x-api-key": apiKey,
|
"x-api-key": apiKey!,
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
storyId: story?.slug,
|
storyId: story?.slug,
|
||||||
@@ -498,6 +504,23 @@ export function StoryEditorClient() {
|
|||||||
</AlertDialogFooter>
|
</AlertDialogFooter>
|
||||||
</AlertDialogContent>
|
</AlertDialogContent>
|
||||||
</AlertDialog>
|
</AlertDialog>
|
||||||
|
|
||||||
|
<AlertDialog open={showRedrawDialog} onOpenChange={setShowRedrawDialog}>
|
||||||
|
<AlertDialogContent>
|
||||||
|
<AlertDialogHeader>
|
||||||
|
<AlertDialogTitle>Redraw Page</AlertDialogTitle>
|
||||||
|
<AlertDialogDescription>
|
||||||
|
Are you sure you want to redraw page {currentPage + 1}? This will regenerate the image for this page with a fresh result.
|
||||||
|
</AlertDialogDescription>
|
||||||
|
</AlertDialogHeader>
|
||||||
|
<AlertDialogFooter>
|
||||||
|
<AlertDialogCancel>Cancel</AlertDialogCancel>
|
||||||
|
<AlertDialogAction onClick={confirmRedrawPage}>
|
||||||
|
Redraw
|
||||||
|
</AlertDialogAction>
|
||||||
|
</AlertDialogFooter>
|
||||||
|
</AlertDialogContent>
|
||||||
|
</AlertDialog>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user