merge
This commit is contained in:
parent
2b9adfc433
commit
b2b2b1f9c5
|
|
@ -17,14 +17,6 @@ const page = () => {
|
|||
const [quizFinished, setQuizFinished] = useState<boolean>(false);
|
||||
const [data, setData] = useState<IQuizQuestions>();
|
||||
|
||||
// const { data, error, isFetching } = useQuery(
|
||||
// ['quiz_questions'],
|
||||
// () => Queries.getQuizQuestions(),
|
||||
// {
|
||||
// keepPreviousData: true,
|
||||
// },
|
||||
// );
|
||||
|
||||
useEffect(() => {
|
||||
Queries.getQuizQuestions().then((res) => {
|
||||
setData(res);
|
||||
|
|
|
|||
|
|
@ -1,40 +0,0 @@
|
|||
import { useEffect, useState } from 'react';
|
||||
|
||||
interface Message {
|
||||
data: string;
|
||||
}
|
||||
|
||||
const WebSocketComponent: React.FC = () => {
|
||||
const [message, setMessage] = useState();
|
||||
const [socket, setSocket] = useState<WebSocket | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
// Initialize WebSocket connection
|
||||
const ws = new WebSocket('ws://localhost:8080/ws');
|
||||
setSocket(ws);
|
||||
|
||||
// Event listener for messages received from server
|
||||
ws.onmessage = (event: MessageEvent) => {
|
||||
console.log('Received from server:', event.data);
|
||||
setMessage(event.data);
|
||||
};
|
||||
|
||||
// Handle WebSocket errors
|
||||
ws.onerror = (error: Event) => {
|
||||
console.error('WebSocket error:', error);
|
||||
};
|
||||
|
||||
// Cleanup the WebSocket connection on component unmount
|
||||
return () => {
|
||||
ws.close();
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1>TypeScript WebSocket Example</h1>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default WebSocketComponent;
|
||||
|
|
@ -1,4 +1,3 @@
|
|||
import PageBage from '@/components/vote/PageBage';
|
||||
import ParticipantsList from '@/components/vote/ParticipantsList';
|
||||
import VoteProvider from '@/providers/VoteProvider';
|
||||
|
||||
|
|
|
|||
|
|
@ -96,11 +96,13 @@ const QuizQuestionList = ({
|
|||
}
|
||||
}, [quizFinished]);
|
||||
|
||||
console.log(data);
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-[40px] md:gap-[160px]">
|
||||
{data && !quizSearchData ? (
|
||||
data.data.questions.map((question, id) =>
|
||||
question.status != 'new' ? (
|
||||
question.status !== 'new' ? (
|
||||
<QuizQuestion
|
||||
score={question.score}
|
||||
questionId={question.id}
|
||||
|
|
@ -119,7 +121,7 @@ const QuizQuestionList = ({
|
|||
</h2>
|
||||
) : data ? (
|
||||
data.data.questions.map((question, id) =>
|
||||
question.status != 'new' ? (
|
||||
question.status !== 'new' ? (
|
||||
<QuizQuestion
|
||||
score={question.score}
|
||||
questionId={question.id}
|
||||
|
|
|
|||
Loading…
Reference in New Issue