analytica-frontend-lib 1.1.24 → 1.1.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1458,15 +1458,27 @@ var useQuizStore = (0, import_zustand2.create)()(
1458
1458
  return userAnswer ? userAnswer.answerStatus : null;
1459
1459
  },
1460
1460
  getQuestionIndex: (questionId) => {
1461
- const { questionsResult } = get();
1462
- if (!questionsResult) return 0;
1463
- let idx = questionsResult.answers.findIndex(
1464
- (q) => q.questionId === questionId
1465
- );
1466
- if (idx === -1) {
1467
- idx = questionsResult.answers.findIndex((q) => q.id === questionId);
1461
+ const { questionsResult, variant } = get();
1462
+ if (variant == "result") {
1463
+ if (!questionsResult) return 0;
1464
+ let idx = questionsResult.answers.findIndex(
1465
+ (q) => q.questionId === questionId
1466
+ );
1467
+ if (idx === -1) {
1468
+ idx = questionsResult.answers.findIndex(
1469
+ (q) => q.id === questionId
1470
+ );
1471
+ }
1472
+ return idx !== -1 ? idx + 1 : 0;
1473
+ } else {
1474
+ const { getActiveQuiz } = get();
1475
+ const activeQuiz = getActiveQuiz();
1476
+ if (!activeQuiz) return 0;
1477
+ const idx = activeQuiz.quiz.questions.findIndex(
1478
+ (q) => q.id === questionId
1479
+ );
1480
+ return idx !== -1 ? idx + 1 : 0;
1468
1481
  }
1469
- return idx !== -1 ? idx + 1 : 0;
1470
1482
  },
1471
1483
  // Question Result
1472
1484
  getQuestionResultByQuestionId: (questionId) => {
@@ -3059,6 +3071,18 @@ var CardResults = (0, import_react7.forwardRef)(
3059
3071
  );
3060
3072
  var CardStatus = (0, import_react7.forwardRef)(
3061
3073
  ({ header, className, status, label, ...props }, ref) => {
3074
+ const getLabelBadge = (status2) => {
3075
+ switch (status2) {
3076
+ case "correct":
3077
+ return "Correta";
3078
+ case "incorrect":
3079
+ return "Incorreta";
3080
+ case "unanswered":
3081
+ return "Em branco";
3082
+ default:
3083
+ return "Em branco";
3084
+ }
3085
+ };
3062
3086
  return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
3063
3087
  CardBase,
3064
3088
  {
@@ -3077,8 +3101,8 @@ var CardStatus = (0, import_react7.forwardRef)(
3077
3101
  action: status == "correct" ? "success" : "error",
3078
3102
  variant: "solid",
3079
3103
  size: "medium",
3080
- iconLeft: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_phosphor_react5.CheckCircle, {}),
3081
- children: status == "correct" ? "Correta" : "Incorreta"
3104
+ iconLeft: status == "correct" ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_phosphor_react5.CheckCircle, {}) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_phosphor_react5.XCircle, {}),
3105
+ children: getLabelBadge(status)
3082
3106
  }
3083
3107
  ),
3084
3108
  label && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: "text-sm text-text-800", children: label })
@@ -4594,33 +4618,55 @@ var Quiz = (0, import_react12.forwardRef)(({ children, className, variant = "def
4594
4618
  var QuizHeaderResult = (0, import_react12.forwardRef)(
4595
4619
  ({ className, ...props }, ref) => {
4596
4620
  const { getQuestionResultByQuestionId, getCurrentQuestion } = useQuizStore();
4597
- const [isCorrect, setIsCorrect] = (0, import_react12.useState)(false);
4621
+ const [status, setStatus] = (0, import_react12.useState)(void 0);
4598
4622
  (0, import_react12.useEffect)(() => {
4599
4623
  const cq = getCurrentQuestion();
4600
4624
  if (!cq) {
4601
- setIsCorrect(false);
4625
+ setStatus(void 0);
4602
4626
  return;
4603
4627
  }
4604
4628
  const qr = getQuestionResultByQuestionId(cq.id);
4605
- setIsCorrect(qr?.answerStatus === "RESPOSTA_CORRETA" /* RESPOSTA_CORRETA */);
4629
+ setStatus(qr?.answerStatus);
4606
4630
  }, [
4607
4631
  getCurrentQuestion,
4608
4632
  getQuestionResultByQuestionId,
4609
4633
  getCurrentQuestion()?.id
4610
4634
  ]);
4635
+ const getClassesByAnswersStatus = () => {
4636
+ switch (status) {
4637
+ case "RESPOSTA_CORRETA" /* RESPOSTA_CORRETA */:
4638
+ return "bg-success-background";
4639
+ case "RESPOSTA_INCORRETA" /* RESPOSTA_INCORRETA */:
4640
+ return "bg-error-background";
4641
+ default:
4642
+ return "bg-error-background";
4643
+ }
4644
+ };
4645
+ const getLabelByAnswersStatus = () => {
4646
+ switch (status) {
4647
+ case "RESPOSTA_CORRETA" /* RESPOSTA_CORRETA */:
4648
+ return "\u{1F389} Parab\xE9ns!!";
4649
+ case "RESPOSTA_INCORRETA" /* RESPOSTA_INCORRETA */:
4650
+ return "N\xE3o foi dessa vez...";
4651
+ case "NAO_RESPONDIDO" /* NAO_RESPONDIDO */:
4652
+ return "N\xE3o foi dessa vez...voc\xEA deixou a resposta em branco";
4653
+ default:
4654
+ return "N\xE3o foi dessa vez...voc\xEA deixou a resposta em branco";
4655
+ }
4656
+ };
4611
4657
  return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
4612
4658
  "div",
4613
4659
  {
4614
4660
  ref,
4615
4661
  className: cn(
4616
4662
  "flex flex-row items-center gap-10 p-3.5 rounded-xl mb-4",
4617
- isCorrect ? "bg-success-background" : "bg-error-background",
4663
+ getClassesByAnswersStatus(),
4618
4664
  className
4619
4665
  ),
4620
4666
  ...props,
4621
4667
  children: [
4622
4668
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { className: "text-text-950 font-bold text-lg", children: "Resultado" }),
4623
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { className: "text-text-700 text-md", children: isCorrect ? "\u{1F389} Parab\xE9ns!!" : "N\xE3o foi dessa vez..." })
4669
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { className: "text-text-700 text-md", children: getLabelByAnswersStatus() })
4624
4670
  ]
4625
4671
  }
4626
4672
  );
@@ -5448,35 +5494,38 @@ var QuizQuestionList = ({
5448
5494
  case "answered":
5449
5495
  return "Respondida";
5450
5496
  case "skipped":
5451
- return "N\xE3o respondida";
5497
+ return "Em branco";
5452
5498
  default:
5453
5499
  return "Em branco";
5454
5500
  }
5455
5501
  };
5456
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "space-y-6 px-4", children: Object.entries(filteredGroupedQuestions).map(
5457
- ([subjectId, questions]) => /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("section", { className: "flex flex-col gap-2", children: [
5458
- /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("span", { className: "pt-6 pb-4 flex flex-row gap-2", children: [
5459
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "bg-primary-500 p-1 rounded-sm flex items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_phosphor_react9.BookOpen, { size: 17, className: "text-white" }) }),
5460
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { className: "text-text-800 font-bold text-lg", children: questions?.[0]?.knowledgeMatrix?.[0]?.subject?.name ?? "Sem mat\xE9ria" })
5461
- ] }),
5462
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("ul", { className: "flex flex-col gap-2", children: questions.map((question) => {
5463
- const status = getQuestionStatus(question.id);
5464
- const questionNumber = getQuestionIndex(question.id);
5465
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
5466
- CardStatus,
5467
- {
5468
- header: `Quest\xE3o ${questionNumber.toString().padStart(2, "0")}`,
5469
- label: getStatusLabel(status),
5470
- onClick: () => {
5471
- goToQuestion(questionNumber - 1);
5472
- onQuestionClick?.();
5473
- }
5474
- },
5475
- question.id
5476
- );
5477
- }) })
5478
- ] }, subjectId)
5479
- ) });
5502
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "space-y-6 px-4 h-full", children: [
5503
+ Object.entries(filteredGroupedQuestions).length == 0 && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "flex items-center justify-center text-gray-500 py-8 h-full", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { className: "text-lg", children: "Nenhum resultado" }) }),
5504
+ Object.entries(filteredGroupedQuestions).map(
5505
+ ([subjectId, questions]) => /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("section", { className: "flex flex-col gap-2", children: [
5506
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("span", { className: "pt-6 pb-4 flex flex-row gap-2", children: [
5507
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "bg-primary-500 p-1 rounded-sm flex items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_phosphor_react9.BookOpen, { size: 17, className: "text-white" }) }),
5508
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { className: "text-text-800 font-bold text-lg", children: questions?.[0]?.knowledgeMatrix?.[0]?.subject?.name ?? "Sem mat\xE9ria" })
5509
+ ] }),
5510
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("ul", { className: "flex flex-col gap-2", children: questions.map((question) => {
5511
+ const status = getQuestionStatus(question.id);
5512
+ const questionNumber = getQuestionIndex(question.id);
5513
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
5514
+ CardStatus,
5515
+ {
5516
+ header: `Quest\xE3o ${questionNumber.toString().padStart(2, "0")}`,
5517
+ label: getStatusLabel(status),
5518
+ onClick: () => {
5519
+ goToQuestion(questionNumber - 1);
5520
+ onQuestionClick?.();
5521
+ }
5522
+ },
5523
+ question.id
5524
+ );
5525
+ }) })
5526
+ ] }, subjectId)
5527
+ )
5528
+ ] });
5480
5529
  };
5481
5530
  var QuizFooter = (0, import_react12.forwardRef)(
5482
5531
  ({
@@ -5510,7 +5559,7 @@ var QuizFooter = (0, import_react12.forwardRef)(
5510
5559
  const [modalResultOpen, setModalResultOpen] = (0, import_react12.useState)(false);
5511
5560
  const [modalNavigateOpen, setModalNavigateOpen] = (0, import_react12.useState)(false);
5512
5561
  const [modalResolutionOpen, setModalResolutionOpen] = (0, import_react12.useState)(false);
5513
- const [filterType, setFilterType] = (0, import_react12.useState)(void 0);
5562
+ const [filterType, setFilterType] = (0, import_react12.useState)("all");
5514
5563
  const unansweredQuestions = getUnansweredQuestionsFromUserAnswers();
5515
5564
  const allQuestions = getTotalQuestions();
5516
5565
  const handleFinishQuiz = async () => {
@@ -5586,7 +5635,7 @@ var QuizFooter = (0, import_react12.forwardRef)(
5586
5635
  }
5587
5636
  )
5588
5637
  ] }),
5589
- !isFirstQuestion && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
5638
+ !isFirstQuestion && !isLastQuestion && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
5590
5639
  Button_default,
5591
5640
  {
5592
5641
  size: "small",
@@ -5698,7 +5747,14 @@ var QuizFooter = (0, import_react12.forwardRef)(
5698
5747
  /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex flex-row justify-between items-center py-6 pt-6 pb-4 border-b border-border-200", children: [
5699
5748
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { className: "text-text-950 font-bold text-lg", children: "Filtrar por" }),
5700
5749
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "max-w-[266px]", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(Select_default, { value: filterType, onValueChange: setFilterType, children: [
5701
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(SelectTrigger, { variant: "rounded", className: "max-w-[266px]", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(SelectValue, { placeholder: "Selecione uma op\xE7\xE3o" }) }),
5750
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
5751
+ SelectTrigger,
5752
+ {
5753
+ variant: "rounded",
5754
+ className: "max-w-[266px] min-w-[160px]",
5755
+ children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(SelectValue, { placeholder: "Selecione uma op\xE7\xE3o" })
5756
+ }
5757
+ ),
5702
5758
  /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(SelectContent, { children: [
5703
5759
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(SelectItem, { value: "all", children: "Todas" }),
5704
5760
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(SelectItem, { value: "unanswered", children: "Em branco" }),
@@ -5706,7 +5762,7 @@ var QuizFooter = (0, import_react12.forwardRef)(
5706
5762
  ] })
5707
5763
  ] }) })
5708
5764
  ] }),
5709
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "flex flex-col gap-2 not-lg:h-[calc(100vh-200px)] lg:max-h-[687px] overflow-y-auto", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
5765
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "flex flex-col gap-2 not-lg:h-[calc(100vh-200px)] lg:max-h-[687px] lg:h-[687px] overflow-y-auto", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
5710
5766
  QuizQuestionList,
5711
5767
  {
5712
5768
  filterType,
@@ -5948,6 +6004,8 @@ var QuizListResultByMateria = ({
5948
6004
  return "correct";
5949
6005
  if (question.answerStatus === "RESPOSTA_INCORRETA" /* RESPOSTA_INCORRETA */)
5950
6006
  return "incorrect";
6007
+ if (question.answerStatus === "NAO_RESPONDIDO" /* NAO_RESPONDIDO */)
6008
+ return "unanswered";
5951
6009
  return void 0;
5952
6010
  })(),
5953
6011
  onClick: () => onQuestionClick?.(question)