22"use client" ;
33
44import { useState , useEffect } from "react" ;
5- import AutomaticQuestions , { AutomaticModeData , GenerationMode } from "./automatico/automatico" ;
5+ import AutomaticQuestions , {
6+ AutomaticModeData ,
7+ GenerationMode ,
8+ } from "./automatico/automatico" ;
69import ManualQuestions from "./manual" ;
710import { QuestionData } from "../page" ;
811import { Button } from "@/components/ui/button" ;
912import { BsPencil } from "react-icons/bs" ;
1013
1114interface QuestionsProps {
12- onQuestionsChange : ( questions : QuestionData [ ] ) => void ;
13- onAutomaticDataChange : ( data : AutomaticModeData | null ) => void ;
14- onModeChange : ( mode : "manual" | "automatic" ) => void ;
15- questions : QuestionData [ ] ;
16- themeId : string ;
17- subTopicId : string ;
18- onSubmit ?: ( ) => void ;
15+ onQuestionsChange : ( questions : QuestionData [ ] ) => void ;
16+ onAutomaticDataChange : ( data : AutomaticModeData | null ) => void ;
17+ onModeChange : ( mode : "manual" | "automatic" ) => void ;
18+ questions : QuestionData [ ] ;
19+ themeId : string ;
20+ subTopicId : string ;
21+ onSubmit ?: ( ) => void ;
1922}
2023
2124export default function Questions ( {
22- onQuestionsChange,
23- onAutomaticDataChange,
24- onModeChange,
25- questions,
26- themeId,
27- subTopicId,
28- onSubmit,
25+ onQuestionsChange,
26+ onAutomaticDataChange,
27+ onModeChange,
28+ questions,
29+ themeId,
30+ subTopicId,
31+ onSubmit,
2932} : QuestionsProps ) {
30- const [ currentMode , setCurrentMode ] = useState < GenerationMode | "manual" | null > ( null ) ;
33+ const [ currentMode , setCurrentMode ] = useState <
34+ GenerationMode | "manual" | null
35+ > ( null ) ;
36+
37+ useEffect ( ( ) => {
38+ if ( currentMode === "manual" ) {
39+ onModeChange ( "manual" ) ;
40+ } else if ( currentMode ) {
41+ onModeChange ( "automatic" ) ;
42+ }
43+ } , [ currentMode , onModeChange ] ) ;
44+
45+ const handleModeSelect = ( mode : GenerationMode ) => {
46+ setCurrentMode ( mode ) ;
47+ } ;
48+
49+ const handleBack = ( ) => {
50+ setCurrentMode ( null ) ;
51+ } ;
3152
32- useEffect ( ( ) => {
3353 if ( currentMode === "manual" ) {
34- onModeChange ( "manual" ) ;
35- } else if ( currentMode ) {
36- onModeChange ( "automatic" ) ;
54+ return (
55+ < div className = "h-full flex flex-col" >
56+ < div className = "mb-4" >
57+ < Button
58+ variant = "ghost"
59+ onClick = { handleBack }
60+ className = "mb-2"
61+ >
62+ ← Voltar para seleção
63+ </ Button >
64+ </ div >
65+ < ManualQuestions
66+ onQuestionsChange = { onQuestionsChange }
67+ questions = { questions }
68+ onSubmit = { onSubmit }
69+ />
70+ </ div >
71+ ) ;
3772 }
38- } , [ currentMode , onModeChange ] ) ;
39-
40- const handleModeSelect = ( mode : GenerationMode ) => {
41- setCurrentMode ( mode ) ;
42- } ;
4373
44- const handleBack = ( ) => {
45- setCurrentMode ( null ) ;
46- } ;
74+ // Se for um modo automático específico (text, document, audio), renderiza o AutomaticQuestions com esse modo
75+ if ( currentMode ) {
76+ return (
77+ < div className = "h-full flex flex-col" >
78+ < div className = "mb-4" >
79+ < Button
80+ variant = "ghost"
81+ onClick = { handleBack }
82+ className = "mb-2"
83+ >
84+ ← Voltar para seleção
85+ </ Button >
86+ </ div >
87+ < AutomaticQuestions
88+ mode = { currentMode }
89+ onModeSelect = { handleModeSelect }
90+ onDataChange = { onAutomaticDataChange }
91+ onSubmit = { onSubmit }
92+ />
93+ </ div >
94+ ) ;
95+ }
4796
48- if ( currentMode === "manual" ) {
97+ // Se não tiver modo selecionado, mostra a tela de seleção unificada
4998 return (
50- < div className = "h-full flex flex-col" >
51- < div className = "mb-4" >
52- < Button variant = "ghost" onClick = { handleBack } className = "mb-2" >
53- ← Voltar para seleção
54- </ Button >
99+ < div className = "overflow-hidden h-full" >
100+ < div className = "overflow-auto h-fit p-1" >
101+ { /* Renderiza o componente AutomaticQuestions no modo de seleção (null) */ }
102+ < AutomaticQuestions
103+ mode = { null }
104+ onModeSelect = { handleModeSelect }
105+ onDataChange = { onAutomaticDataChange }
106+ />
107+
108+ { /* Card Manual adicionado abaixo */ }
109+ < div className = "max-w-5xl mx-auto mt-6" >
110+ < h3 className = "text-2xl font-bold mb-4" >
111+ Ou crie manualmente
112+ </ h3 >
113+ < button
114+ onClick = { ( ) => setCurrentMode ( "manual" ) }
115+ className = "w-full group bg-layout-card border-2 rounded-xl p-6 hover:border-orange-500 hover:shadow-lg transition-all duration-200 text-left flex items-center gap-6"
116+ >
117+ < div className = "w-14 h-14 bg-orange-100 rounded-lg flex items-center justify-center shrink-0 group-hover:bg-orange-500 transition-colors" >
118+ < BsPencil className = "w-7 h-7 text-orange-600 group-hover:text-white transition-colors" />
119+ </ div >
120+ < div >
121+ < h3 className = "text-xl font-semibold mb-2" >
122+ Manual
123+ </ h3 >
124+ < p className = "text-sm" >
125+ Crie suas próprias questões do zero, definindo
126+ enunciados e alternativas
127+ </ p >
128+ </ div >
129+ </ button >
130+ </ div >
55131 </ div >
56- < ManualQuestions
57- onQuestionsChange = { onQuestionsChange }
58- questions = { questions }
59- onSubmit = { onSubmit }
60- />
61132 </ div >
62133 ) ;
63- }
64-
65- // Se for um modo automático específico (text, document, audio), renderiza o AutomaticQuestions com esse modo
66- if ( currentMode && currentMode !== "manual" ) {
67- return (
68- < div className = "h-full flex flex-col" >
69- < div className = "mb-4" >
70- < Button variant = "ghost" onClick = { handleBack } className = "mb-2" >
71- ← Voltar para seleção
72- </ Button >
73- </ div >
74- < AutomaticQuestions
75- mode = { currentMode }
76- onModeSelect = { handleModeSelect }
77- onDataChange = { onAutomaticDataChange }
78- onSubmit = { onSubmit }
79- />
80- </ div >
81- ) ;
82- }
83-
84- // Se não tiver modo selecionado, mostra a tela de seleção unificada
85- return (
86- < div className = "overflow-hidden h-full" >
87- < div className = "overflow-auto h-fit p-1" >
88- { /* Renderiza o componente AutomaticQuestions no modo de seleção (null) */ }
89- < AutomaticQuestions
90- mode = { null }
91- onModeSelect = { handleModeSelect }
92- onDataChange = { onAutomaticDataChange }
93- />
94-
95- { /* Card Manual adicionado abaixo */ }
96- < div className = "max-w-5xl mx-auto mt-6" >
97- < h3 className = "text-2xl font-bold mb-4" > Ou crie manualmente</ h3 >
98- < button
99- onClick = { ( ) => setCurrentMode ( "manual" ) }
100- className = "w-full group bg-layout-card border-2 rounded-xl p-6 hover:border-orange-500 hover:shadow-lg transition-all duration-200 text-left flex items-center gap-6"
101- >
102- < div className = "w-14 h-14 bg-orange-100 rounded-lg flex items-center justify-center shrink-0 group-hover:bg-orange-500 transition-colors" >
103- < BsPencil className = "w-7 h-7 text-orange-600 group-hover:text-white transition-colors" />
104- </ div >
105- < div >
106- < h3 className = "text-xl font-semibold mb-2" > Manual</ h3 >
107- < p className = "text-sm" >
108- Crie suas próprias questões do zero, definindo enunciados e alternativas
109- </ p >
110- </ div >
111- </ button >
112- </ div >
113- </ div >
114- </ div >
115- ) ;
116- }
134+ }
0 commit comments