Add ability to edit AI generated content

This commit is contained in:
Joey Yakimowich-Payne 2026-01-13 23:37:08 -07:00
commit bfbba7b5ab
No known key found for this signature in database
GPG key ID: 6BFE655FA5ABD1E1
15 changed files with 1089 additions and 10 deletions

27
App.tsx
View file

@ -10,6 +10,8 @@ import { Podium } from './components/Podium';
import { QuizCreator } from './components/QuizCreator';
import { RevealScreen } from './components/RevealScreen';
import { SaveQuizPrompt } from './components/SaveQuizPrompt';
import { QuizEditor } from './components/QuizEditor';
import type { Quiz } from './types';
const seededRandom = (seed: number) => {
const x = Math.sin(seed * 9999) * 10000;
@ -65,7 +67,11 @@ function App() {
currentStreak,
currentPlayerId,
pendingQuizToSave,
dismissSavePrompt
dismissSavePrompt,
sourceQuizId,
updateQuizFromEditor,
startGameFromEditor,
backFromEditor
} = useGame();
const handleSaveQuiz = async () => {
@ -76,6 +82,15 @@ function App() {
dismissSavePrompt();
};
const handleEditorSave = async (editedQuiz: Quiz) => {
updateQuizFromEditor(editedQuiz);
if (auth.isAuthenticated) {
const source = pendingQuizToSave?.topic ? 'ai_generated' : 'manual';
const topic = pendingQuizToSave?.topic || undefined;
await saveQuiz(editedQuiz, source, topic);
}
};
const currentQ = quiz?.questions[currentQuestionIndex];
// Logic to find correct option, handling both Host (has isCorrect flag) and Client (masked, needs shape)
@ -107,6 +122,16 @@ function App() {
/>
) : null}
{gameState === 'EDITING' && quiz ? (
<QuizEditor
quiz={quiz}
onSave={handleEditorSave}
onStartGame={startGameFromEditor}
onBack={backFromEditor}
sourceQuizId={sourceQuizId}
/>
) : null}
{gameState === 'LOBBY' ? (
<>
<Lobby