quiz page adjustments, added pagination
This commit is contained in:
parent
f6fddab1bf
commit
cff0dd5371
|
|
@ -288,3 +288,45 @@ export const getTossData = async ({
|
||||||
console.log(err);
|
console.log(err);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getQuizWinnersById = async (id: number) => {
|
||||||
|
try {
|
||||||
|
const res = await fetch(
|
||||||
|
`${baseUrl.QUIZ_SRC}${routes.getQuizQuestionsWinners(id)}`,
|
||||||
|
{
|
||||||
|
next: { revalidate: 3600 },
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
const result = await res.json();
|
||||||
|
console.log(result);
|
||||||
|
|
||||||
|
return result as IQuizQuestionsWinners;
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getNextQuizWinnners = async (
|
||||||
|
id: number,
|
||||||
|
limit: number,
|
||||||
|
offset: number
|
||||||
|
) => {
|
||||||
|
try {
|
||||||
|
const res = await fetch(
|
||||||
|
`${baseUrl.QUIZ_SRC}${routes.getQuizQuestionsWinners(
|
||||||
|
id
|
||||||
|
)}?limit=${limit}&offset=${offset}`,
|
||||||
|
{
|
||||||
|
next: { revalidate: 3600 },
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
const result = await res.json();
|
||||||
|
console.log(result);
|
||||||
|
|
||||||
|
return result as IQuizQuestionsWinners;
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,42 +1,42 @@
|
||||||
import localFont from 'next/font/local';
|
import localFont from "next/font/local";
|
||||||
import Script from 'next/script';
|
import Script from "next/script";
|
||||||
|
|
||||||
import { Roboto } from 'next/font/google';
|
import { Roboto } from "next/font/google";
|
||||||
import { Merriweather } from 'next/font/google';
|
import { Merriweather } from "next/font/google";
|
||||||
import { Merriweather_Sans } from 'next/font/google';
|
import { Merriweather_Sans } from "next/font/google";
|
||||||
import { Alexandria } from 'next/font/google';
|
import { Alexandria } from "next/font/google";
|
||||||
|
|
||||||
import 'swiper/swiper-bundle.css';
|
import "swiper/swiper-bundle.css";
|
||||||
import './globals.css';
|
import "./globals.css";
|
||||||
import QueryProvider from '@/providers/QueryProvider';
|
import QueryProvider from "@/providers/QueryProvider";
|
||||||
import { HtmlContext } from 'next/dist/shared/lib/html-context.shared-runtime';
|
import { HtmlContext } from "next/dist/shared/lib/html-context.shared-runtime";
|
||||||
// FONTS
|
// FONTS
|
||||||
const aeroport = localFont({
|
const aeroport = localFont({
|
||||||
src: '../fonts/Aeroport.otf',
|
src: "../fonts/Aeroport.otf",
|
||||||
variable: '--font-aeroport',
|
variable: "--font-aeroport",
|
||||||
});
|
});
|
||||||
const roboto = Roboto({
|
const roboto = Roboto({
|
||||||
subsets: ['latin'],
|
subsets: ["latin"],
|
||||||
weight: ['300', '400', '700'],
|
weight: ["300", "400", "700"],
|
||||||
variable: '--font-roboto',
|
variable: "--font-roboto",
|
||||||
});
|
});
|
||||||
const mw = Merriweather({
|
const mw = Merriweather({
|
||||||
subsets: ['cyrillic', 'cyrillic-ext', 'latin', 'latin-ext'],
|
subsets: ["cyrillic", "cyrillic-ext", "latin", "latin-ext"],
|
||||||
weight: '700',
|
weight: "700",
|
||||||
variable: '--font-mw',
|
variable: "--font-mw",
|
||||||
});
|
});
|
||||||
const mw_sans = Merriweather_Sans({
|
const mw_sans = Merriweather_Sans({
|
||||||
subsets: ['cyrillic-ext', 'latin', 'latin-ext'],
|
subsets: ["cyrillic-ext", "latin", "latin-ext"],
|
||||||
weight: ['300', '400', '700'],
|
weight: ["300", "400", "700"],
|
||||||
variable: '--font-mwsans',
|
variable: "--font-mwsans",
|
||||||
});
|
});
|
||||||
const alexandria = Alexandria({
|
const alexandria = Alexandria({
|
||||||
subsets: ['latin', 'latin-ext'],
|
subsets: ["latin", "latin-ext"],
|
||||||
variable: '--font-alexandria',
|
variable: "--font-alexandria",
|
||||||
});
|
});
|
||||||
|
|
||||||
export const metadata = {
|
export const metadata = {
|
||||||
title: 'Turkmen TV',
|
title: "Turkmen TV",
|
||||||
};
|
};
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
|
|
@ -47,12 +47,14 @@ export default function RootLayout({ children }: IProps) {
|
||||||
return (
|
return (
|
||||||
<html
|
<html
|
||||||
lang="tm"
|
lang="tm"
|
||||||
className={`${aeroport.variable} ${mw.variable} ${roboto.variable} ${mw_sans.variable} ${alexandria.variable}`}>
|
className={`${aeroport.variable} ${mw.variable} ${roboto.variable} ${mw_sans.variable} ${alexandria.variable}`}
|
||||||
|
>
|
||||||
<head>
|
<head>
|
||||||
<link rel="icon" href="/logo.png" sizes="any" />
|
<link rel="icon" href="/logo.png" sizes="any" />
|
||||||
<meta
|
<meta
|
||||||
name="viewport"
|
name="viewport"
|
||||||
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no;"></meta>
|
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no;"
|
||||||
|
></meta>
|
||||||
</head>
|
</head>
|
||||||
<body className="relative overflow-x-hidden">
|
<body className="relative overflow-x-hidden">
|
||||||
<QueryProvider>{children}</QueryProvider>
|
<QueryProvider>{children}</QueryProvider>
|
||||||
|
|
@ -61,7 +63,8 @@ export default function RootLayout({ children }: IProps) {
|
||||||
<Script
|
<Script
|
||||||
id="ganalytics-import"
|
id="ganalytics-import"
|
||||||
async
|
async
|
||||||
src="https://www.googletagmanager.com/gtag/js?id=G-F2267QXY9T"></Script>
|
src="https://www.googletagmanager.com/gtag/js?id=G-F2267QXY9T"
|
||||||
|
></Script>
|
||||||
<Script id="ganalytics-body">
|
<Script id="ganalytics-body">
|
||||||
{`
|
{`
|
||||||
window.dataLayer = window.dataLayer || [];
|
window.dataLayer = window.dataLayer || [];
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ const QuizSearch = ({ quizId }: { quizId: number }) => {
|
||||||
event: React.FormEvent<HTMLFormElement>
|
event: React.FormEvent<HTMLFormElement>
|
||||||
) => {
|
) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
setActive(true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
|
|
@ -50,11 +51,9 @@ const QuizSearch = ({ quizId }: { quizId: number }) => {
|
||||||
);
|
);
|
||||||
|
|
||||||
// Handle the response as needed
|
// Handle the response as needed
|
||||||
|
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
setQuizSearchData(data);
|
setQuizSearchData(data);
|
||||||
setSearchActive(true);
|
setSearchActive(true);
|
||||||
setActive(true);
|
|
||||||
} catch (error) {}
|
} catch (error) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,40 +1,18 @@
|
||||||
"use client";
|
"use client";
|
||||||
import { Queries } from "@/api/queries";
|
import {
|
||||||
|
getNextQuizWinnners,
|
||||||
|
getQuizWinnersById,
|
||||||
|
Queries,
|
||||||
|
} from "@/api/queries";
|
||||||
|
|
||||||
import { v4 } from "uuid";
|
import { v4 } from "uuid";
|
||||||
import { useState, useEffect, useContext } from "react";
|
import { useState, useEffect, useContext } from "react";
|
||||||
import { IQuizQuestionsWinners } from "@/models/quizQuestionsWinners.model";
|
import {
|
||||||
|
Datum,
|
||||||
|
IQuizQuestionsWinners,
|
||||||
|
} from "@/models/quizQuestionsWinners.model";
|
||||||
import QuizContext from "@/context/QuizContext";
|
import QuizContext from "@/context/QuizContext";
|
||||||
import { useQuizSearchActive } from "@/store/store";
|
import { useQuizSearchActive } from "@/store/store";
|
||||||
|
|
||||||
interface Message {
|
|
||||||
answer: string;
|
|
||||||
score: number;
|
|
||||||
date: string;
|
|
||||||
serial_number: number;
|
|
||||||
serial_number_for_correct: number;
|
|
||||||
starred_src: string;
|
|
||||||
quiz_id: number;
|
|
||||||
question_id: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Winner {
|
|
||||||
total_score_of_client: string;
|
|
||||||
correct_answers_time: string;
|
|
||||||
client_id: number;
|
|
||||||
client: {
|
|
||||||
id: number;
|
|
||||||
phone: string;
|
|
||||||
answers: {
|
|
||||||
id: number;
|
|
||||||
question_id: number;
|
|
||||||
score: number;
|
|
||||||
serial_number_for_correct: number;
|
|
||||||
client_id: number;
|
|
||||||
}[];
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
quizId: number;
|
quizId: number;
|
||||||
quizFinished: boolean;
|
quizFinished: boolean;
|
||||||
|
|
@ -42,23 +20,58 @@ interface IProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
const QuizWinnerTable = ({ quizId, quizFinished, smsNumber }: IProps) => {
|
const QuizWinnerTable = ({ quizId, quizFinished, smsNumber }: IProps) => {
|
||||||
const [winnersData, setWinnersData] = useState<IQuizQuestionsWinners>();
|
const [winnersData, setWinnersData] = useState<Datum[] | []>([]);
|
||||||
const { questionsData } = useContext(QuizContext).quizQuestionsContext;
|
const { questionsData } = useContext(QuizContext).quizQuestionsContext;
|
||||||
|
const [winnersTotal, setWinnersTotal] = useState<number>(0);
|
||||||
|
const [nextPageQueries, setQueries] = useState<{
|
||||||
|
limit: number;
|
||||||
|
offset: number;
|
||||||
|
}>({
|
||||||
|
limit: 0,
|
||||||
|
offset: 0,
|
||||||
|
});
|
||||||
const { quizSearchData } = useContext(QuizContext).quizSearchContext;
|
const { quizSearchData } = useContext(QuizContext).quizSearchContext;
|
||||||
const { active } = useQuizSearchActive();
|
const { active } = useQuizSearchActive();
|
||||||
|
|
||||||
|
async function getData(next?: boolean) {
|
||||||
|
if (next) {
|
||||||
|
const res = await getNextQuizWinnners(
|
||||||
|
quizId,
|
||||||
|
nextPageQueries.limit,
|
||||||
|
nextPageQueries.offset
|
||||||
|
);
|
||||||
|
if (res) {
|
||||||
|
setWinnersData([...winnersData, ...res.data]);
|
||||||
|
setQueries({
|
||||||
|
limit: res?.meta.per_page,
|
||||||
|
offset: nextPageQueries.offset + res?.meta.per_page,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const res = await getQuizWinnersById(quizId);
|
||||||
|
if (res) {
|
||||||
|
setWinnersTotal(res.meta.total);
|
||||||
|
setWinnersData(res.data);
|
||||||
|
setQueries({
|
||||||
|
limit: res?.meta.per_page,
|
||||||
|
offset: nextPageQueries.offset + res?.meta.per_page,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!active) {
|
if (!active) {
|
||||||
Queries.getQuizWinners(quizId).then((res) => {
|
// Queries.getQuizWinners(quizId).then((res) => {
|
||||||
setWinnersData(res);
|
// setWinnersData(res);
|
||||||
});
|
// });
|
||||||
|
getData();
|
||||||
} else if (active) {
|
} else if (active) {
|
||||||
setWinnersData(undefined);
|
setWinnersData([]);
|
||||||
}
|
}
|
||||||
}, [quizId, active]);
|
}, [quizId, active]);
|
||||||
|
|
||||||
return winnersData?.data.length !== 0 ? (
|
return quizSearchData?.data || (winnersData && winnersData?.length) !== 0 ? (
|
||||||
<div className="flex flex-col justify-center items-center gap-[60px]">
|
<div className="flex flex-col justify-center items-center gap-[60px]">
|
||||||
<div className="flex flex-col gap-5 justify-center items-center w-full">
|
<div className="flex flex-col gap-5 justify-center items-center w-full">
|
||||||
<h2 className="text-textBlack text-[28px] text-center md:text-left md:text-[32px] font-semibold">
|
<h2 className="text-textBlack text-[28px] text-center md:text-left md:text-[32px] font-semibold">
|
||||||
|
|
@ -69,33 +82,30 @@ const QuizWinnerTable = ({ quizId, quizFinished, smsNumber }: IProps) => {
|
||||||
<div className="table-desktop hidden sm:flex flex-col bg-fillTableHead rounded-[25px] shadow-quizButton overflow-hidden max-w-[1000px] w-full">
|
<div className="table-desktop hidden sm:flex flex-col bg-fillTableHead rounded-[25px] shadow-quizButton overflow-hidden max-w-[1000px] w-full">
|
||||||
{/* Table Head */}
|
{/* Table Head */}
|
||||||
<div className="flex border-b border-fillTableStrokeTableHead">
|
<div className="flex border-b border-fillTableStrokeTableHead">
|
||||||
{winnersData?.data[0].client_id || quizSearchData?.data ? (
|
{winnersData[0].client_id || quizSearchData?.data ? (
|
||||||
<div className="text-center flex justify-center items-center text-base text-textBlack leading-[125%] font-semibold max-w-[54px] w-[100%] pl-6 pr-3 py-5">
|
<div className="text-center flex justify-center items-center text-base text-textBlack leading-[125%] font-semibold max-w-[54px] w-[100%] pl-6 pr-3 py-5">
|
||||||
<span>Ýeri</span>
|
<span>Ýeri</span>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{winnersData?.data[0].client.phone || quizSearchData?.data ? (
|
{winnersData[0].phone || quizSearchData?.data ? (
|
||||||
<div className="text-center flex justify-center items-center text-base text-textBlack leading-[125%] font-semibold max-w-[176px] w-[100%] px-3 py-5">
|
<div className="text-center flex justify-center items-center text-base text-textBlack leading-[125%] font-semibold max-w-[176px] w-[100%] px-3 py-5">
|
||||||
<span>Telefon beligisi</span>
|
<span>Telefon beligisi</span>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{winnersData?.data[0].client.answers.length ||
|
{winnersData[0].answers.length || quizSearchData?.data ? (
|
||||||
quizSearchData?.data ? (
|
|
||||||
<div className="text-center flex justify-center items-center text-base text-textBlack leading-[125%] font-semibold w-[100%] px-3 py-5">
|
<div className="text-center flex justify-center items-center text-base text-textBlack leading-[125%] font-semibold w-[100%] px-3 py-5">
|
||||||
<span>Jogap beriş nobatlary</span>
|
<span>Jogap beriş nobatlary</span>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{winnersData?.data[0].total_score_of_client ||
|
{winnersData[0].total_score_of_client || quizSearchData?.data ? (
|
||||||
quizSearchData?.data ? (
|
|
||||||
<div className="text-center flex justify-center items-center text-base text-textBlack leading-[125%] font-semibold max-w-[180px] w-[100%] px-3 py-5">
|
<div className="text-center flex justify-center items-center text-base text-textBlack leading-[125%] font-semibold max-w-[180px] w-[100%] px-3 py-5">
|
||||||
<span>Nobatlaryň jemi</span>
|
<span>Nobatlaryň jemi</span>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
{winnersData?.data[0].total_score_of_client ||
|
{winnersData[0].total_score_of_client || quizSearchData?.data ? (
|
||||||
quizSearchData?.data ? (
|
|
||||||
<div className="text-center flex justify-center items-center text-base text-textBlack leading-[125%] font-semibold max-w-[180px] w-[100%] px-3 py-5">
|
<div className="text-center flex justify-center items-center text-base text-textBlack leading-[125%] font-semibold max-w-[180px] w-[100%] px-3 py-5">
|
||||||
<span>Utuklaryň jemi</span>
|
<span>Utuklaryň jemi</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -105,7 +115,7 @@ const QuizWinnerTable = ({ quizId, quizFinished, smsNumber }: IProps) => {
|
||||||
{/* Table Body */}
|
{/* Table Body */}
|
||||||
<div className="">
|
<div className="">
|
||||||
{winnersData
|
{winnersData
|
||||||
? winnersData?.data.map((winner, id) => (
|
? winnersData.map((winner, id) => (
|
||||||
<div
|
<div
|
||||||
className={`flex border-b border-fillTableStrokeTableRow ${
|
className={`flex border-b border-fillTableStrokeTableRow ${
|
||||||
id % 2 === 0 ? "bg-fillTableRow" : "bg-fillTableRow2"
|
id % 2 === 0 ? "bg-fillTableRow" : "bg-fillTableRow2"
|
||||||
|
|
@ -116,27 +126,27 @@ const QuizWinnerTable = ({ quizId, quizFinished, smsNumber }: IProps) => {
|
||||||
<span>
|
<span>
|
||||||
{id > 0 &&
|
{id > 0 &&
|
||||||
winner.correct_answers_time ===
|
winner.correct_answers_time ===
|
||||||
winnersData.data[id - 1].correct_answers_time
|
winnersData[id - 1].correct_answers_time
|
||||||
? id
|
? id
|
||||||
: id + 1}
|
: id + 1}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
{winnersData.data[0].client.phone ? (
|
{winnersData[0].phone ? (
|
||||||
<div className="flex justify-center items-center text-base text-textBlack leading-[125%] font-semibold max-w-[176px] w-[100%] px-3 py-5">
|
<div className="flex justify-center items-center text-base text-textBlack leading-[125%] font-semibold max-w-[176px] w-[100%] px-3 py-5">
|
||||||
<span>+{winner.client.phone}</span>
|
<span>+{winner.phone}</span>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
{winnersData.data[0].client.answers.length !== 0 ? (
|
{winnersData[0].answers.length !== 0 ? (
|
||||||
<div className="flex justify-center items-center gap-6 text-base text-textGray leading-[125%] w-[100%] px-3 py-5">
|
<div className="flex justify-center items-center gap-6 text-base text-textGray leading-[125%] w-[100%] px-3 py-5">
|
||||||
{questionsData
|
{questionsData
|
||||||
? questionsData.map((question) => {
|
? questionsData.map((question) => {
|
||||||
const matchingAnswer =
|
const matchingAnswer =
|
||||||
winner.client.answers.find(
|
winner.answers.find(
|
||||||
(answer) =>
|
(answer) =>
|
||||||
answer.question_id === question.id &&
|
answer.question_id === question.id &&
|
||||||
answer.score > 0
|
answer.score > 0
|
||||||
) ||
|
) ||
|
||||||
winner.client.answers.find(
|
winner.answers.find(
|
||||||
(answer) => answer.question_id === question.id
|
(answer) => answer.question_id === question.id
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -168,14 +178,14 @@ const QuizWinnerTable = ({ quizId, quizFinished, smsNumber }: IProps) => {
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{winnersData.data[0].total_score_of_client ? (
|
{winnersData[0].total_score_of_client ? (
|
||||||
<div className="flex justify-center items-center text-base text-textBlack leading-[125%] max-w-[180px] w-[100%] px-3 py-3">
|
<div className="flex justify-center items-center text-base text-textBlack leading-[125%] max-w-[180px] w-[100%] px-3 py-3">
|
||||||
<span className="border border-[#2C7CDA] text-[#2C7CDA] rounded-full w-[36px] h-[36px] flex justify-center items-center text-base leading-[125%] ">
|
<span className="border border-[#2C7CDA] text-[#2C7CDA] rounded-full w-[36px] h-[36px] flex justify-center items-center text-base leading-[125%] ">
|
||||||
{winner.correct_answers_time}
|
{winner.correct_answers_time}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
{winnersData.data[0].total_score_of_client ? (
|
{winnersData[0].total_score_of_client ? (
|
||||||
<div className="flex justify-center items-center text-base text-textBlack leading-[125%] max-w-[180px] w-[100%] px-3 py-3">
|
<div className="flex justify-center items-center text-base text-textBlack leading-[125%] max-w-[180px] w-[100%] px-3 py-3">
|
||||||
<span className="bg-fillOrange rounded-full w-[36px] h-[36px] flex justify-center items-center text-base leading-[125%] text-white">
|
<span className="bg-fillOrange rounded-full w-[36px] h-[36px] flex justify-center items-center text-base leading-[125%] text-white">
|
||||||
{winner.total_score_of_client}
|
{winner.total_score_of_client}
|
||||||
|
|
@ -253,26 +263,24 @@ const QuizWinnerTable = ({ quizId, quizFinished, smsNumber }: IProps) => {
|
||||||
<div className="sm:hidden flex flex-col bg-fillTableHead rounded-[13px] shadow-quizButton overflow-hidden max-w-[1000px] w-full">
|
<div className="sm:hidden flex flex-col bg-fillTableHead rounded-[13px] shadow-quizButton overflow-hidden max-w-[1000px] w-full">
|
||||||
{/* Table Head */}
|
{/* Table Head */}
|
||||||
<div className="flex border-b border-fillTableStrokeTableHead p-2 gap-[8px]">
|
<div className="flex border-b border-fillTableStrokeTableHead p-2 gap-[8px]">
|
||||||
{winnersData?.data[0].client_id || quizSearchData?.data ? (
|
{winnersData[0].client_id || quizSearchData?.data ? (
|
||||||
<div className="text-center flex items-center text-xs text-textBlack leading-[125%] font-semibold max-w-[14px] w-[100%]">
|
<div className="text-center flex items-center text-xs text-textBlack leading-[125%] font-semibold max-w-[14px] w-[100%]">
|
||||||
<span>Ýeri</span>
|
<span>Ýeri</span>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{winnersData?.data[0].client.phone || quizSearchData?.data ? (
|
{winnersData[0].phone || quizSearchData?.data ? (
|
||||||
<div className="text-center flex justify-center items-center text-xs text-textBlack leading-[125%] font-semibold max-w-[107px] w-[100%]">
|
<div className="text-center flex justify-center items-center text-xs text-textBlack leading-[125%] font-semibold max-w-[107px] w-[100%]">
|
||||||
<span>Telefon beligisi</span>
|
<span>Telefon beligisi</span>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{winnersData?.data[0].total_score_of_client ||
|
{winnersData[0].total_score_of_client || quizSearchData?.data ? (
|
||||||
quizSearchData?.data ? (
|
|
||||||
<div className="text-center flex justify-center items-center text-xs text-textBlack leading-[125%] font-semibold max-w-[75px] w-[100%]">
|
<div className="text-center flex justify-center items-center text-xs text-textBlack leading-[125%] font-semibold max-w-[75px] w-[100%]">
|
||||||
<span>Nobatlaryň jemi </span>
|
<span>Nobatlaryň jemi </span>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
{winnersData?.data[0].total_score_of_client ||
|
{winnersData[0].total_score_of_client || quizSearchData?.data ? (
|
||||||
quizSearchData?.data ? (
|
|
||||||
<div className="text-center flex justify-center items-center text-xs text-textBlack leading-[125%] font-semibold max-w-[99px] w-[100%]">
|
<div className="text-center flex justify-center items-center text-xs text-textBlack leading-[125%] font-semibold max-w-[99px] w-[100%]">
|
||||||
<span>Utuklaryň jemi</span>
|
<span>Utuklaryň jemi</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -282,7 +290,7 @@ const QuizWinnerTable = ({ quizId, quizFinished, smsNumber }: IProps) => {
|
||||||
{/* Table Body */}
|
{/* Table Body */}
|
||||||
<div className="">
|
<div className="">
|
||||||
{winnersData
|
{winnersData
|
||||||
? winnersData?.data.map((winner, id) => (
|
? winnersData.map((winner, id) => (
|
||||||
<div
|
<div
|
||||||
className={`flex border-b border-fillTableStrokeTableRow items-center p-[8px] gap-[8px] ${
|
className={`flex border-b border-fillTableStrokeTableRow items-center p-[8px] gap-[8px] ${
|
||||||
id % 2 === 0 ? "bg-fillTableRow" : "bg-fillTableRow2"
|
id % 2 === 0 ? "bg-fillTableRow" : "bg-fillTableRow2"
|
||||||
|
|
@ -295,20 +303,20 @@ const QuizWinnerTable = ({ quizId, quizFinished, smsNumber }: IProps) => {
|
||||||
|
|
||||||
<div className="flex flex-col gap-[8px] w-full">
|
<div className="flex flex-col gap-[8px] w-full">
|
||||||
<div className="flex gap-[8px] items-center">
|
<div className="flex gap-[8px] items-center">
|
||||||
{winnersData.data[0].client.phone ? (
|
{winnersData[0].phone ? (
|
||||||
<div className="flex items-center text-xs text-textBlack leading-[125%] font-semibold max-w-[107px] w-full">
|
<div className="flex items-center text-xs text-textBlack leading-[125%] font-semibold max-w-[107px] w-full">
|
||||||
<span>+{winner.client.phone}</span>
|
<span>+{winner.phone}</span>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{winnersData.data[0].total_score_of_client ? (
|
{winnersData[0].total_score_of_client ? (
|
||||||
<div className="flex justify-center items-center text-xs text-textBlack leading-[125%] max-w-[75px] w-full">
|
<div className="flex justify-center items-center text-xs text-textBlack leading-[125%] max-w-[75px] w-full">
|
||||||
<span className="border border-[#2C7CDA] text-[#2C7CDA] rounded-full w-[24px] h-[24px] flex justify-center items-center text-xs leading-[125%] ">
|
<span className="border border-[#2C7CDA] text-[#2C7CDA] rounded-full w-[24px] h-[24px] flex justify-center items-center text-xs leading-[125%] ">
|
||||||
{winner.correct_answers_time}
|
{winner.correct_answers_time}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
{winnersData.data[0].total_score_of_client ? (
|
{winnersData[0].total_score_of_client ? (
|
||||||
<div className="flex justify-center items-center text-xs text-textBlack leading-[125%] max-w-[99px] w-full">
|
<div className="flex justify-center items-center text-xs text-textBlack leading-[125%] max-w-[99px] w-full">
|
||||||
<span className="bg-fillOrange rounded-full w-[24px] h-[24px] flex justify-center items-center text-xs leading-[125%] text-white">
|
<span className="bg-fillOrange rounded-full w-[24px] h-[24px] flex justify-center items-center text-xs leading-[125%] text-white">
|
||||||
{winner.total_score_of_client}
|
{winner.total_score_of_client}
|
||||||
|
|
@ -317,22 +325,22 @@ const QuizWinnerTable = ({ quizId, quizFinished, smsNumber }: IProps) => {
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
<div className="flex gap-[8px] items-center">
|
<div className="flex gap-[8px] items-center">
|
||||||
{winnersData?.data[0].client.answers.length !== 0 ? (
|
{winnersData[0].answers.length !== 0 ? (
|
||||||
<div className="flex justify-center items-center text-xs text-textLight leading-[125%] font-semibold w-fit">
|
<div className="flex justify-center items-center text-xs text-textLight leading-[125%] font-semibold w-fit">
|
||||||
<span>Jogap beriş nobatlary:</span>
|
<span>Jogap beriş nobatlary:</span>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
{winnersData.data[0].client.answers.length !== 0 ? (
|
{winnersData[0].answers.length !== 0 ? (
|
||||||
<div className="flex justify-center items-center gap-[4px] text-xs text-textGray leading-[125%] w-fit">
|
<div className="flex justify-center items-center gap-[4px] text-xs text-textGray leading-[125%] w-fit">
|
||||||
{questionsData
|
{questionsData
|
||||||
? questionsData.map((question) => {
|
? questionsData.map((question) => {
|
||||||
const matchingAnswer =
|
const matchingAnswer =
|
||||||
winner.client.answers.find(
|
winner.answers.find(
|
||||||
(answer) =>
|
(answer) =>
|
||||||
answer.question_id === question.id &&
|
answer.question_id === question.id &&
|
||||||
answer.score > 0
|
answer.score > 0
|
||||||
) ||
|
) ||
|
||||||
winner.client.answers.find(
|
winner.answers.find(
|
||||||
(answer) =>
|
(answer) =>
|
||||||
answer.question_id === question.id
|
answer.question_id === question.id
|
||||||
);
|
);
|
||||||
|
|
@ -446,6 +454,15 @@ const QuizWinnerTable = ({ quizId, quizFinished, smsNumber }: IProps) => {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{winnersData.length < winnersTotal && (
|
||||||
|
<button
|
||||||
|
onClick={() => getData(true)}
|
||||||
|
className="py-[5px] px-[10px] rounded-md bg-blue-500 text-white border border-blue-500 lg:hover:bg-white lg:hover:text-blue-500 transition-all duration-300"
|
||||||
|
>
|
||||||
|
Dowamy
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* Rules block */}
|
{/* Rules block */}
|
||||||
<div className="flex flex-col gap-[20px] p-5 border border-strokeLightGray1 rounded-[25px] max-w-[1000px] w-full items-center justify-center">
|
<div className="flex flex-col gap-[20px] p-5 border border-strokeLightGray1 rounded-[25px] max-w-[1000px] w-full items-center justify-center">
|
||||||
<h3 className="text-[26px] text-textBlack font-semibold leading-[124%]">
|
<h3 className="text-[26px] text-textBlack font-semibold leading-[124%]">
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,15 @@
|
||||||
export interface IQuizQuestionsWinners {
|
export interface IQuizQuestionsWinners {
|
||||||
data: Datum[];
|
data: Datum[];
|
||||||
|
meta: IMeta;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Datum {
|
export interface Datum {
|
||||||
total_score_of_client: string;
|
total_score_of_client: string;
|
||||||
correct_answers_time: string;
|
correct_answers_time: string;
|
||||||
client_id: number;
|
client_id: number;
|
||||||
client: Client;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Client {
|
|
||||||
id: number;
|
|
||||||
phone: string;
|
phone: string;
|
||||||
answers: Answer[];
|
answers: Answer[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Answer {
|
export interface Answer {
|
||||||
id: number;
|
id: number;
|
||||||
question_id: number;
|
question_id: number;
|
||||||
|
|
@ -22,3 +17,13 @@ export interface Answer {
|
||||||
serial_number_for_correct: number;
|
serial_number_for_correct: number;
|
||||||
client_id: number;
|
client_id: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface IMeta {
|
||||||
|
current_page: number;
|
||||||
|
from: number;
|
||||||
|
last_page: number;
|
||||||
|
path: string;
|
||||||
|
per_page: number;
|
||||||
|
to: number;
|
||||||
|
total: number;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
import { IQuizSearchData } from '@/models/quizSearchData.model';
|
import { IQuizSearchData } from "@/models/quizSearchData.model";
|
||||||
import { Dispatch, SetStateAction } from 'react';
|
import { Dispatch, SetStateAction } from "react";
|
||||||
|
|
||||||
export interface IQuizSearch {
|
export interface IQuizSearch {
|
||||||
quizSearchData: IQuizSearchData | undefined;
|
quizSearchData: IQuizSearchData | undefined;
|
||||||
setQuizSearchData: Dispatch<SetStateAction<IQuizSearchData | undefined>>;
|
setQuizSearchData: Dispatch<SetStateAction<IQuizSearchData | undefined>>;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue