Spaces:
Sleeping
Sleeping
wip
Browse files- src/app/api/text/question/route.ts +24 -6
- src/app/page.tsx +16 -2
- src/components/court/Court.tsx +6 -1
- src/components/defense/Defense.tsx +17 -15
- src/components/lawyer/Lawyer.tsx +17 -3
src/app/api/text/question/route.ts
CHANGED
@@ -21,7 +21,7 @@ export async function POST(request: Request) {
|
|
21 |
|
22 |
const prompts = {
|
23 |
fr: `Pouvez-vous trouver 1 question amusante pour réfuter les alibis que le juge pourrait poser à l'avocat de l'accusé dans cette affaire ?
|
24 |
-
(ne demandez pas de dessiner ou de faire des gestes, seulement des réponses textuelles)
|
25 |
Pouvez-vous aussi donner 3 mots aléatoires *mais réels* que l'avocat devra ajouter à son discours. Ces mots doivent être simple, drole, reliés a l'affaire ou des mots ou expressions embarassantes pour un statut d'avocat (ex: "euuuh, et voila quoi..").
|
26 |
Je veux un mot en lien avec le case.
|
27 |
Je veux un mot ou expression embarassante pour un avocat.
|
@@ -32,15 +32,21 @@ export async function POST(request: Request) {
|
|
32 |
|
33 |
description de l'histoire : ${story.description}
|
34 |
alibis : ${story.alibi.join(', ')}
|
35 |
-
${chat.messages.length > 0 ? `historique de la discussion : ${chatHistory}` : ''}
|
|
|
|
|
|
|
|
|
|
|
36 |
|
37 |
Réponse en JSON avec ce format :
|
38 |
{
|
|
|
39 |
"question" : " Votre question incisive de juge ici ",
|
40 |
"words" : [" expression1 ", " expression2 ", " expression3 "].
|
41 |
}`,
|
42 |
en: `can you find 1 fun questions to refute the alibis the judge could ask the lawyer of the accused about this case ?
|
43 |
-
(do not ask to draw or to gesture, only text answers)
|
44 |
Can you also give 3 random *but real* words for the lawyer to add to his speech. These words should be simple, funny, related to the case or embarrassing words or phrases for a lawyer (e.g. “uh huh, here goes nothing”).
|
45 |
I want a word related to the case.
|
46 |
I want a word or phrase embarassant for a lawyer.
|
@@ -51,15 +57,21 @@ export async function POST(request: Request) {
|
|
51 |
|
52 |
story description: ${story.description}
|
53 |
alibis: ${story.alibi.join(', ')}
|
54 |
-
${chat.messages.length > 0 ? `discussion history: ${chatHistory}` : ''}
|
|
|
|
|
|
|
|
|
|
|
55 |
|
56 |
Answer in JSON with this format:
|
57 |
{
|
|
|
58 |
"question": "Your incisive judge question here",
|
59 |
"words": ["expression1", "expression2", "expression3"]
|
60 |
}`,
|
61 |
es: `¿puedes encontrar 1 preguntas divertidas para refutar las coartadas que el juez podría hacer al abogado del acusado sobre este caso?
|
62 |
-
(no pidas dibujar o gesticular, sólo respuestas de texto)
|
63 |
También puedes dar 3 palabras aleatorias *pero reales* para que el abogado las añada a su discurso. Estas palabras deben ser sencillas, divertidas, relacionadas con el caso o palabras o frases embarazosas para un abogado (por ejemplo, «uh huh, aquí vamos..»).
|
64 |
Quiero una palabra relacionada con el caso.
|
65 |
Quiero una palabra o frase embarazosa para un abogado.
|
@@ -70,10 +82,16 @@ export async function POST(request: Request) {
|
|
70 |
|
71 |
descripción de la historia: ${story.description}
|
72 |
coartadas: ${story.alibi.join(', ')}
|
73 |
-
${chat.messages.length > 0 ? `historia de la discusión: ${chatHistory}` : ''}
|
|
|
|
|
|
|
|
|
|
|
74 |
|
75 |
Respuesta en JSON con este formato:
|
76 |
{
|
|
|
77 |
"question": "Tu incisiva pregunta de juez aquí",
|
78 |
"words": ["expresión1", "expresión2", "expresión3"]
|
79 |
}`
|
|
|
21 |
|
22 |
const prompts = {
|
23 |
fr: `Pouvez-vous trouver 1 question amusante pour réfuter les alibis que le juge pourrait poser à l'avocat de l'accusé dans cette affaire ?
|
24 |
+
(ne demandez pas de dessiner ou de faire des gestes, seulement des réponses textuelles), La question doit commencer par "Pourquoi" ou "J'aimerais savoir" ect .
|
25 |
Pouvez-vous aussi donner 3 mots aléatoires *mais réels* que l'avocat devra ajouter à son discours. Ces mots doivent être simple, drole, reliés a l'affaire ou des mots ou expressions embarassantes pour un statut d'avocat (ex: "euuuh, et voila quoi..").
|
26 |
Je veux un mot en lien avec le case.
|
27 |
Je veux un mot ou expression embarassante pour un avocat.
|
|
|
32 |
|
33 |
description de l'histoire : ${story.description}
|
34 |
alibis : ${story.alibi.join(', ')}
|
35 |
+
history : ${chat.messages.length > 0 ? `historique de la discussion : ${chatHistory}` : 'Vide'}
|
36 |
+
|
37 |
+
Je veux egalement une réaction a la derniere réponse de l'avocat. Cela peut etre des "Hmmm, d'accord" ou alors "Vous ne m'avez pas vraiment convaincu... Pourquoi parlez vous de ...".
|
38 |
+
Prends le role du juge et reponds avec condescendance. Cela doit etre dans un champ json "reaction" different de "question".
|
39 |
+
Parcontre la reaction ne doit pas finir par une question. Elle doit finir par trois petits points '...'
|
40 |
+
si history est vide, ne mettez pas reaction dans le json.
|
41 |
|
42 |
Réponse en JSON avec ce format :
|
43 |
{
|
44 |
+
"reaction" : "Votre réaction incisive ici",
|
45 |
"question" : " Votre question incisive de juge ici ",
|
46 |
"words" : [" expression1 ", " expression2 ", " expression3 "].
|
47 |
}`,
|
48 |
en: `can you find 1 fun questions to refute the alibis the judge could ask the lawyer of the accused about this case ?
|
49 |
+
(do not ask to draw or to gesture, only text answers), The question must start with "Why" or "I would like to know" etc.
|
50 |
Can you also give 3 random *but real* words for the lawyer to add to his speech. These words should be simple, funny, related to the case or embarrassing words or phrases for a lawyer (e.g. “uh huh, here goes nothing”).
|
51 |
I want a word related to the case.
|
52 |
I want a word or phrase embarassant for a lawyer.
|
|
|
57 |
|
58 |
story description: ${story.description}
|
59 |
alibis: ${story.alibi.join(', ')}
|
60 |
+
history: ${chat.messages.length > 0 ? `discussion history: ${chatHistory}` : 'Empty'}
|
61 |
+
|
62 |
+
I want a reaction to the last answer of the lawyer. This could be "Hmmm, d'accord" or then "Vous ne m'avez pas vraiment convaincu... Pourquoi parlez vous de ...".
|
63 |
+
Take the role of the judge and answer with condescendance. This must be in a json field "reaction" different from "question".
|
64 |
+
The reaction must not end with a question. It has to finish with three dots '...'
|
65 |
+
If history is empty, do not put reaction in the json.
|
66 |
|
67 |
Answer in JSON with this format:
|
68 |
{
|
69 |
+
"reaction": "Your incisive reaction here",
|
70 |
"question": "Your incisive judge question here",
|
71 |
"words": ["expression1", "expression2", "expression3"]
|
72 |
}`,
|
73 |
es: `¿puedes encontrar 1 preguntas divertidas para refutar las coartadas que el juez podría hacer al abogado del acusado sobre este caso?
|
74 |
+
(no pidas dibujar o gesticular, sólo respuestas de texto), La pregunta debe comenzar con "Por qué" o "Me gustaría saber" etc.
|
75 |
También puedes dar 3 palabras aleatorias *pero reales* para que el abogado las añada a su discurso. Estas palabras deben ser sencillas, divertidas, relacionadas con el caso o palabras o frases embarazosas para un abogado (por ejemplo, «uh huh, aquí vamos..»).
|
76 |
Quiero una palabra relacionada con el caso.
|
77 |
Quiero una palabra o frase embarazosa para un abogado.
|
|
|
82 |
|
83 |
descripción de la historia: ${story.description}
|
84 |
coartadas: ${story.alibi.join(', ')}
|
85 |
+
history: ${chat.messages.length > 0 ? `historia de la discusión: ${chatHistory}` : 'vacío'}
|
86 |
+
|
87 |
+
Quiero una reacción a la última respuesta del abogado. Esto podría ser "Hmmm, d'accord" o entonces "Vous ne m'avez pas vraiment convaincu... Pourquoi parlez vous de ...".
|
88 |
+
Toma el papel del juez y responde con condescendencia. Cela debe estar en un campo json "reaction" diferente de "question".
|
89 |
+
La reacción no debe terminar con una pregunta. It has to finish with three dots '...'
|
90 |
+
Si history está vacío, no pongas reacción en el json.
|
91 |
|
92 |
Respuesta en JSON con este formato:
|
93 |
{
|
94 |
+
"reaction": "Tu reacción incisiva aquí",
|
95 |
"question": "Tu incisiva pregunta de juez aquí",
|
96 |
"words": ["expresión1", "expresión2", "expresión3"]
|
97 |
}`
|
src/app/page.tsx
CHANGED
@@ -64,6 +64,8 @@ export default function Home() {
|
|
64 |
|
65 |
const [currentQuestion, setCurrentQuestion] = useState<string>('');
|
66 |
|
|
|
|
|
67 |
const resetGame = () => {
|
68 |
setCurrentScene('menu');
|
69 |
setStory(null);
|
@@ -75,8 +77,7 @@ export default function Home() {
|
|
75 |
|
76 |
const setNextScene = () => {
|
77 |
if (currentScene === 'lawyer') {
|
78 |
-
if (round <
|
79 |
-
setRound(round + 1);
|
80 |
setCurrentScene('court');
|
81 |
} else {
|
82 |
setCurrentScene('end');
|
@@ -111,6 +112,8 @@ export default function Home() {
|
|
111 |
setRequiredWords,
|
112 |
chat,
|
113 |
setChat,
|
|
|
|
|
114 |
};
|
115 |
|
116 |
useEffect(() => {
|
@@ -147,6 +150,12 @@ export default function Home() {
|
|
147 |
// eslint-disable-next-line react-hooks/exhaustive-deps
|
148 |
}, [currentScene]); // on écoute les changements de currentScene
|
149 |
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
useEffect(() => {
|
151 |
const fetchQuestion = async () => {
|
152 |
try {
|
@@ -164,9 +173,14 @@ export default function Home() {
|
|
164 |
|
165 |
const data = await response.json();
|
166 |
console.log('data:', data)
|
|
|
167 |
if (data.question && data.words) {
|
168 |
setCurrentQuestion(data.question);
|
169 |
setRequiredWords(data.words);
|
|
|
|
|
|
|
|
|
170 |
setChat(prevChat => ({
|
171 |
messages: [...prevChat.messages, { content: data.question, role: 'judge' }]
|
172 |
}));
|
|
|
64 |
|
65 |
const [currentQuestion, setCurrentQuestion] = useState<string>('');
|
66 |
|
67 |
+
const [reaction, setReaction] = useState<string>('');
|
68 |
+
|
69 |
const resetGame = () => {
|
70 |
setCurrentScene('menu');
|
71 |
setStory(null);
|
|
|
77 |
|
78 |
const setNextScene = () => {
|
79 |
if (currentScene === 'lawyer') {
|
80 |
+
if (round < 4) {
|
|
|
81 |
setCurrentScene('court');
|
82 |
} else {
|
83 |
setCurrentScene('end');
|
|
|
112 |
setRequiredWords,
|
113 |
chat,
|
114 |
setChat,
|
115 |
+
reaction,
|
116 |
+
setReaction,
|
117 |
};
|
118 |
|
119 |
useEffect(() => {
|
|
|
150 |
// eslint-disable-next-line react-hooks/exhaustive-deps
|
151 |
}, [currentScene]); // on écoute les changements de currentScene
|
152 |
|
153 |
+
useEffect(() => {
|
154 |
+
if (reaction !== '') {
|
155 |
+
console.log('reaction:', reaction)
|
156 |
+
}
|
157 |
+
}, [reaction]);
|
158 |
+
|
159 |
useEffect(() => {
|
160 |
const fetchQuestion = async () => {
|
161 |
try {
|
|
|
173 |
|
174 |
const data = await response.json();
|
175 |
console.log('data:', data)
|
176 |
+
console.log('round:', round)
|
177 |
if (data.question && data.words) {
|
178 |
setCurrentQuestion(data.question);
|
179 |
setRequiredWords(data.words);
|
180 |
+
if (data.reaction && data.reaction !== '') {
|
181 |
+
console.log('data.reaction:', data.reaction)
|
182 |
+
setReaction(data.reaction);
|
183 |
+
}
|
184 |
setChat(prevChat => ({
|
185 |
messages: [...prevChat.messages, { content: data.question, role: 'judge' }]
|
186 |
}));
|
src/components/court/Court.tsx
CHANGED
@@ -5,11 +5,15 @@ import Image from 'next/image';
|
|
5 |
interface CourtSceneProps {
|
6 |
setNextScene: () => void;
|
7 |
currentQuestion: string;
|
|
|
|
|
8 |
}
|
9 |
|
10 |
const CourtScene: FC<CourtSceneProps> = ({
|
11 |
setNextScene,
|
12 |
-
currentQuestion
|
|
|
|
|
13 |
}) => {
|
14 |
const [showFirstImage, setShowFirstImage] = useState(true);
|
15 |
|
@@ -47,6 +51,7 @@ const CourtScene: FC<CourtSceneProps> = ({
|
|
47 |
<div className="absolute bottom-0 left-1/2 transform -translate-x-1/2 w-[80%] bg-black/60 border border-black border-8 mb-[8vh] p-6">
|
48 |
<div className="text-white roboto-slab">
|
49 |
<p className="text-4xl mb-4">
|
|
|
50 |
{currentQuestion ? currentQuestion : '...'}
|
51 |
</p>
|
52 |
|
|
|
5 |
interface CourtSceneProps {
|
6 |
setNextScene: () => void;
|
7 |
currentQuestion: string;
|
8 |
+
reaction: string;
|
9 |
+
round: number;
|
10 |
}
|
11 |
|
12 |
const CourtScene: FC<CourtSceneProps> = ({
|
13 |
setNextScene,
|
14 |
+
currentQuestion,
|
15 |
+
reaction,
|
16 |
+
round
|
17 |
}) => {
|
18 |
const [showFirstImage, setShowFirstImage] = useState(true);
|
19 |
|
|
|
51 |
<div className="absolute bottom-0 left-1/2 transform -translate-x-1/2 w-[80%] bg-black/60 border border-black border-8 mb-[8vh] p-6">
|
52 |
<div className="text-white roboto-slab">
|
53 |
<p className="text-4xl mb-4">
|
54 |
+
{reaction !== '' && round !== 1 ? reaction.replace(/\?/g, '') : ''} <br />
|
55 |
{currentQuestion ? currentQuestion : '...'}
|
56 |
</p>
|
57 |
|
src/components/defense/Defense.tsx
CHANGED
@@ -17,7 +17,8 @@ interface DefenseSceneProps {
|
|
17 |
setNextScene: () => void;
|
18 |
setChat: (chat: SetStateAction<Chat>) => void;
|
19 |
setCurrentQuestion: Dispatch<SetStateAction<string>>;
|
20 |
-
setRequiredWords: Dispatch<SetStateAction<string[]
|
|
|
21 |
}
|
22 |
|
23 |
const DefenseScene: FC<DefenseSceneProps> = ({
|
@@ -26,13 +27,14 @@ const DefenseScene: FC<DefenseSceneProps> = ({
|
|
26 |
setNextScene,
|
27 |
setCurrentQuestion,
|
28 |
setRequiredWords,
|
29 |
-
setChat
|
|
|
30 |
}) => {
|
31 |
const [answer, setAnswer] = useState('');
|
32 |
const [insertedWords, setInsertedWords] = useState<boolean[]>([]);
|
33 |
const [countdown, setCountdown] = useState(60);
|
34 |
const [isTimeUp, setIsTimeUp] = useState(false);
|
35 |
-
const [wordPositions, setWordPositions] = useState<Array<{word: string; position: number}>>([]);
|
36 |
const [mandatoryWords, setMandatoryWords] = useState(requiredWords);
|
37 |
const [isLoading, setIsLoading] = useState(true);
|
38 |
|
@@ -41,6 +43,7 @@ const DefenseScene: FC<DefenseSceneProps> = ({
|
|
41 |
if (requiredWords.length > 0) {
|
42 |
setMandatoryWords(requiredWords);
|
43 |
}
|
|
|
44 |
}, [requiredWords]);
|
45 |
|
46 |
// Génération des positions et initialisation
|
@@ -224,19 +227,19 @@ const DefenseScene: FC<DefenseSceneProps> = ({
|
|
224 |
<span className="text-5xl text-sky-500 roboto-slab mt-2">
|
225 |
{item.word.toUpperCase()}
|
226 |
</span>
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
? `in `
|
231 |
: `en `
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
? ` words`
|
238 |
: ` palabras`
|
239 |
-
|
240 |
</div>
|
241 |
);
|
242 |
}).filter(Boolean)[0]}
|
@@ -260,11 +263,10 @@ const DefenseScene: FC<DefenseSceneProps> = ({
|
|
260 |
<button
|
261 |
onClick={() => handleSubmit(answer)}
|
262 |
disabled={!isAnswerValid()}
|
263 |
-
className={`absolute bottom-5 right-5 px-8 py-4 rounded-lg text-xl transition-all duration-300 ${
|
264 |
-
isAnswerValid()
|
265 |
? 'bg-sky-500 hover:bg-blue-700 cursor-pointer'
|
266 |
: 'bg-gray-600 cursor-not-allowed'
|
267 |
-
|
268 |
>
|
269 |
{language === 'fr' ? 'Soumettre' : language === 'en' ? 'Submit' : 'Submit'}
|
270 |
</button>
|
|
|
17 |
setNextScene: () => void;
|
18 |
setChat: (chat: SetStateAction<Chat>) => void;
|
19 |
setCurrentQuestion: Dispatch<SetStateAction<string>>;
|
20 |
+
setRequiredWords: Dispatch<SetStateAction<string[]>>;
|
21 |
+
setReaction: Dispatch<SetStateAction<string>>;
|
22 |
}
|
23 |
|
24 |
const DefenseScene: FC<DefenseSceneProps> = ({
|
|
|
27 |
setNextScene,
|
28 |
setCurrentQuestion,
|
29 |
setRequiredWords,
|
30 |
+
setChat,
|
31 |
+
setReaction
|
32 |
}) => {
|
33 |
const [answer, setAnswer] = useState('');
|
34 |
const [insertedWords, setInsertedWords] = useState<boolean[]>([]);
|
35 |
const [countdown, setCountdown] = useState(60);
|
36 |
const [isTimeUp, setIsTimeUp] = useState(false);
|
37 |
+
const [wordPositions, setWordPositions] = useState<Array<{ word: string; position: number }>>([]);
|
38 |
const [mandatoryWords, setMandatoryWords] = useState(requiredWords);
|
39 |
const [isLoading, setIsLoading] = useState(true);
|
40 |
|
|
|
43 |
if (requiredWords.length > 0) {
|
44 |
setMandatoryWords(requiredWords);
|
45 |
}
|
46 |
+
setReaction('');
|
47 |
}, [requiredWords]);
|
48 |
|
49 |
// Génération des positions et initialisation
|
|
|
227 |
<span className="text-5xl text-sky-500 roboto-slab mt-2">
|
228 |
{item.word.toUpperCase()}
|
229 |
</span>
|
230 |
+
<span className="text-5xl text-white roboto-slab mt-2"> {language === 'fr'
|
231 |
+
? `dans `
|
232 |
+
: language === 'en'
|
233 |
? `in `
|
234 |
: `en `
|
235 |
+
}</span>
|
236 |
+
<span className="text-5xl text-red-500 roboto-slab mt-2">{remainingWords}</span>
|
237 |
+
<span className="text-5xl text-white roboto-slab mt-2"> {language === 'fr'
|
238 |
+
? ` mots`
|
239 |
+
: language === 'en'
|
240 |
? ` words`
|
241 |
: ` palabras`
|
242 |
+
}</span>
|
243 |
</div>
|
244 |
);
|
245 |
}).filter(Boolean)[0]}
|
|
|
263 |
<button
|
264 |
onClick={() => handleSubmit(answer)}
|
265 |
disabled={!isAnswerValid()}
|
266 |
+
className={`absolute bottom-5 right-5 px-8 py-4 rounded-lg text-xl transition-all duration-300 ${isAnswerValid()
|
|
|
267 |
? 'bg-sky-500 hover:bg-blue-700 cursor-pointer'
|
268 |
: 'bg-gray-600 cursor-not-allowed'
|
269 |
+
}`}
|
270 |
>
|
271 |
{language === 'fr' ? 'Soumettre' : language === 'en' ? 'Submit' : 'Submit'}
|
272 |
</button>
|
src/components/lawyer/Lawyer.tsx
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
'use client';
|
2 |
-
import { FC, useState, useEffect } from 'react';
|
3 |
import Image from 'next/image';
|
4 |
|
5 |
interface Message {
|
@@ -17,6 +17,7 @@ interface LawyerSceneProps {
|
|
17 |
setNextScene: () => void;
|
18 |
currentQuestion: string;
|
19 |
round: number;
|
|
|
20 |
}
|
21 |
|
22 |
const LawyerScene: FC<LawyerSceneProps> = ({
|
@@ -25,13 +26,26 @@ const LawyerScene: FC<LawyerSceneProps> = ({
|
|
25 |
setNextScene,
|
26 |
currentQuestion,
|
27 |
round,
|
|
|
28 |
}) => {
|
29 |
const [visible, setVisible] = useState(false);
|
30 |
const [buttonEnabled, setButtonEnabled] = useState(false);
|
31 |
const [countdown, setCountdown] = useState(3);
|
32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
useEffect(() => {
|
34 |
setVisible(true);
|
|
|
35 |
const timer = setInterval(() => {
|
36 |
setCountdown((prev) => {
|
37 |
if (prev <= 1) {
|
@@ -69,7 +83,7 @@ const LawyerScene: FC<LawyerSceneProps> = ({
|
|
69 |
{language === 'fr' ? 'Question du juge' : language === 'en' ? 'Judge\'s question' : 'Pregunta del juez'}:
|
70 |
</h2>
|
71 |
<p className="text-xl text-white roboto-slab">
|
72 |
-
{
|
73 |
</p>
|
74 |
</div>
|
75 |
|
@@ -79,7 +93,7 @@ const LawyerScene: FC<LawyerSceneProps> = ({
|
|
79 |
{language === 'fr' ? 'Votre réponse' : language === 'en' ? 'Your answer' : 'Tu respuesta'}:
|
80 |
</h2>
|
81 |
<p className="text-xl text-white roboto-slab whitespace-pre-wrap mb-8">
|
82 |
-
{
|
83 |
</p>
|
84 |
|
85 |
{/* Flèche à droite */}
|
|
|
1 |
'use client';
|
2 |
+
import { FC, useState, useEffect, Dispatch, SetStateAction } from 'react';
|
3 |
import Image from 'next/image';
|
4 |
|
5 |
interface Message {
|
|
|
17 |
setNextScene: () => void;
|
18 |
currentQuestion: string;
|
19 |
round: number;
|
20 |
+
setRound: Dispatch<SetStateAction<number>>;
|
21 |
}
|
22 |
|
23 |
const LawyerScene: FC<LawyerSceneProps> = ({
|
|
|
26 |
setNextScene,
|
27 |
currentQuestion,
|
28 |
round,
|
29 |
+
setRound,
|
30 |
}) => {
|
31 |
const [visible, setVisible] = useState(false);
|
32 |
const [buttonEnabled, setButtonEnabled] = useState(false);
|
33 |
const [countdown, setCountdown] = useState(3);
|
34 |
|
35 |
+
const [question, setQuestion] = useState('');
|
36 |
+
const [answer, setAnswer] = useState('');
|
37 |
+
|
38 |
+
useEffect(() => {
|
39 |
+
const lastJudgeMessage = chat.messages.filter((message: Message) => message.role === 'judge').slice(-1)[0]?.content;
|
40 |
+
const lastLawyerMessage = chat.messages.filter((message: Message) => message.role === 'lawyer').slice(-1)[0]?.content;
|
41 |
+
setQuestion(lastJudgeMessage || '');
|
42 |
+
setAnswer(lastLawyerMessage || '');
|
43 |
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
44 |
+
}, []); // Only run once on mount
|
45 |
+
|
46 |
useEffect(() => {
|
47 |
setVisible(true);
|
48 |
+
setRound(round + 1);
|
49 |
const timer = setInterval(() => {
|
50 |
setCountdown((prev) => {
|
51 |
if (prev <= 1) {
|
|
|
83 |
{language === 'fr' ? 'Question du juge' : language === 'en' ? 'Judge\'s question' : 'Pregunta del juez'}:
|
84 |
</h2>
|
85 |
<p className="text-xl text-white roboto-slab">
|
86 |
+
{question}
|
87 |
</p>
|
88 |
</div>
|
89 |
|
|
|
93 |
{language === 'fr' ? 'Votre réponse' : language === 'en' ? 'Your answer' : 'Tu respuesta'}:
|
94 |
</h2>
|
95 |
<p className="text-xl text-white roboto-slab whitespace-pre-wrap mb-8">
|
96 |
+
{answer}
|
97 |
</p>
|
98 |
|
99 |
{/* Flèche à droite */}
|