Add ability to edit AI generated content
This commit is contained in:
parent
846ba2a69c
commit
bfbba7b5ab
15 changed files with 1089 additions and 10 deletions
27
App.tsx
27
App.tsx
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue