Skip to content

Commit

Permalink
Merged changes from production/v_1
Browse files Browse the repository at this point in the history
  • Loading branch information
raisondetre1207 committed Mar 12, 2024
1 parent 405de7d commit 2783b52
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
25 changes: 18 additions & 7 deletions WebApp/frontend/quiz_session/app/room/components/participants.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,26 @@ import { Loader } from "@mantine/core";
import { useEffect, useState } from "react";
import { useAnsweredParticipants, useParticipants } from "@/app/util/store";

export default function Participants({ includeLoaderModal = true, className = '', excludeAdmins = false}) {
export default function Participants({
includeLoaderModal = true,
className = "",
excludeAdmins = false,
}) {
const [names, setNames] = useState([]);
const { participants } = useParticipants();
const { answeredParticipants } = useAnsweredParticipants();

useEffect(() => {
if(excludeAdmins)
setNames(participants.filter(p => !p.isAdmin));
if (excludeAdmins) setNames(participants.filter((p) => !p.isAdmin));
else setNames(participants);
}, [participants, excludeAdmins]);

return (
<>
{includeLoaderModal && (
<div className={`flex flex-col items-center space-y-2 mt-8 mb-8 ${className}`}>
<div
className={`flex flex-col items-center space-y-2 mt-8 mb-8 ${className}`}
>
<Loader color="rgba(255, 255, 255, 1)" size="md" />
<div className="text-white font-regular">
Waiting for other players...
Expand All @@ -29,14 +34,20 @@ export default function Participants({ includeLoaderModal = true, className = ''

{!includeLoaderModal && (
<div className="text-white font-regular py-8 mt-4 text-center">
Participants
Participants
</div>
)}
<div className={`flex flex-wrap justify-center w-full overflow-auto ${className}`}>
<div
className={`flex flex-wrap justify-center w-full overflow-auto ${className}`}
>
{names?.map((name, index) => (
<div
key={index}
className={`py-2 px-5 rounded-md font-bold m-2 shadow-sm ${answeredParticipants.includes(name.qParticipantDesc) ? 'bg-yellow-500 text-white' : 'bg-white text-green_text'}`}
className={`py-2 px-5 rounded-md font-bold m-2 shadow-sm ${
answeredParticipants.includes(name.qParticipantDesc)
? "bg-yellow-500 text-white"
: "text-white bg-green-700/50"
}`}
>
{name.qParticipantDesc.toUpperCase()}
</div>
Expand Down
2 changes: 1 addition & 1 deletion WebApp/frontend/quiz_session/app/room/components/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default function Start() {
color="yellow"
className="shadow-lg transition ease-in-out delay-150 hover:-translate-y-1 hover:scale-110 hover:bg-yellow-500 duration-200"
onClick={() => startQuiz(connection, params)}
style={{ opacity: isAdmin ? 1 : 0 }}
style={{ visibility: isAdmin ? "visible" : "hidden" }}
size="lg"
>
Start Quiz
Expand Down

0 comments on commit 2783b52

Please sign in to comment.