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.
package/dist/index.mjs CHANGED
@@ -4482,6 +4482,18 @@ var CardResults = forwardRef12(
4482
4482
  );
4483
4483
  var CardStatus = forwardRef12(
4484
4484
  ({ header, className, status, label, ...props }, ref) => {
4485
+ const getLabelBadge = (status2) => {
4486
+ switch (status2) {
4487
+ case "correct":
4488
+ return "Correta";
4489
+ case "incorrect":
4490
+ return "Incorreta";
4491
+ case "unanswered":
4492
+ return "Em branco";
4493
+ default:
4494
+ return "Em branco";
4495
+ }
4496
+ };
4485
4497
  return /* @__PURE__ */ jsx26(
4486
4498
  CardBase,
4487
4499
  {
@@ -4500,8 +4512,8 @@ var CardStatus = forwardRef12(
4500
4512
  action: status == "correct" ? "success" : "error",
4501
4513
  variant: "solid",
4502
4514
  size: "medium",
4503
- iconLeft: /* @__PURE__ */ jsx26(CheckCircle3, {}),
4504
- children: status == "correct" ? "Correta" : "Incorreta"
4515
+ iconLeft: status == "correct" ? /* @__PURE__ */ jsx26(CheckCircle3, {}) : /* @__PURE__ */ jsx26(XCircle2, {}),
4516
+ children: getLabelBadge(status)
4505
4517
  }
4506
4518
  ),
4507
4519
  label && /* @__PURE__ */ jsx26("p", { className: "text-sm text-text-800", children: label })
@@ -8043,6 +8055,7 @@ var ANSWER_STATUS = /* @__PURE__ */ ((ANSWER_STATUS2) => {
8043
8055
  ANSWER_STATUS2["RESPOSTA_CORRETA"] = "RESPOSTA_CORRETA";
8044
8056
  ANSWER_STATUS2["RESPOSTA_INCORRETA"] = "RESPOSTA_INCORRETA";
8045
8057
  ANSWER_STATUS2["PENDENTE_AVALIACAO"] = "PENDENTE_AVALIACAO";
8058
+ ANSWER_STATUS2["NAO_RESPONDIDO"] = "NAO_RESPONDIDO";
8046
8059
  return ANSWER_STATUS2;
8047
8060
  })(ANSWER_STATUS || {});
8048
8061
  var useQuizStore = create7()(
@@ -8537,15 +8550,27 @@ var useQuizStore = create7()(
8537
8550
  return userAnswer ? userAnswer.answerStatus : null;
8538
8551
  },
8539
8552
  getQuestionIndex: (questionId) => {
8540
- const { questionsResult } = get();
8541
- if (!questionsResult) return 0;
8542
- let idx = questionsResult.answers.findIndex(
8543
- (q) => q.questionId === questionId
8544
- );
8545
- if (idx === -1) {
8546
- idx = questionsResult.answers.findIndex((q) => q.id === questionId);
8553
+ const { questionsResult, variant } = get();
8554
+ if (variant == "result") {
8555
+ if (!questionsResult) return 0;
8556
+ let idx = questionsResult.answers.findIndex(
8557
+ (q) => q.questionId === questionId
8558
+ );
8559
+ if (idx === -1) {
8560
+ idx = questionsResult.answers.findIndex(
8561
+ (q) => q.id === questionId
8562
+ );
8563
+ }
8564
+ return idx !== -1 ? idx + 1 : 0;
8565
+ } else {
8566
+ const { getActiveQuiz } = get();
8567
+ const activeQuiz = getActiveQuiz();
8568
+ if (!activeQuiz) return 0;
8569
+ const idx = activeQuiz.quiz.questions.findIndex(
8570
+ (q) => q.id === questionId
8571
+ );
8572
+ return idx !== -1 ? idx + 1 : 0;
8547
8573
  }
8548
- return idx !== -1 ? idx + 1 : 0;
8549
8574
  },
8550
8575
  // Question Result
8551
8576
  getQuestionResultByQuestionId: (questionId) => {
@@ -8614,33 +8639,55 @@ var Quiz = forwardRef19(({ children, className, variant = "default", ...props },
8614
8639
  var QuizHeaderResult = forwardRef19(
8615
8640
  ({ className, ...props }, ref) => {
8616
8641
  const { getQuestionResultByQuestionId, getCurrentQuestion } = useQuizStore();
8617
- const [isCorrect, setIsCorrect] = useState17(false);
8642
+ const [status, setStatus] = useState17(void 0);
8618
8643
  useEffect15(() => {
8619
8644
  const cq = getCurrentQuestion();
8620
8645
  if (!cq) {
8621
- setIsCorrect(false);
8646
+ setStatus(void 0);
8622
8647
  return;
8623
8648
  }
8624
8649
  const qr = getQuestionResultByQuestionId(cq.id);
8625
- setIsCorrect(qr?.answerStatus === "RESPOSTA_CORRETA" /* RESPOSTA_CORRETA */);
8650
+ setStatus(qr?.answerStatus);
8626
8651
  }, [
8627
8652
  getCurrentQuestion,
8628
8653
  getQuestionResultByQuestionId,
8629
8654
  getCurrentQuestion()?.id
8630
8655
  ]);
8656
+ const getClassesByAnswersStatus = () => {
8657
+ switch (status) {
8658
+ case "RESPOSTA_CORRETA" /* RESPOSTA_CORRETA */:
8659
+ return "bg-success-background";
8660
+ case "RESPOSTA_INCORRETA" /* RESPOSTA_INCORRETA */:
8661
+ return "bg-error-background";
8662
+ default:
8663
+ return "bg-error-background";
8664
+ }
8665
+ };
8666
+ const getLabelByAnswersStatus = () => {
8667
+ switch (status) {
8668
+ case "RESPOSTA_CORRETA" /* RESPOSTA_CORRETA */:
8669
+ return "\u{1F389} Parab\xE9ns!!";
8670
+ case "RESPOSTA_INCORRETA" /* RESPOSTA_INCORRETA */:
8671
+ return "N\xE3o foi dessa vez...";
8672
+ case "NAO_RESPONDIDO" /* NAO_RESPONDIDO */:
8673
+ return "N\xE3o foi dessa vez...voc\xEA deixou a resposta em branco";
8674
+ default:
8675
+ return "N\xE3o foi dessa vez...voc\xEA deixou a resposta em branco";
8676
+ }
8677
+ };
8631
8678
  return /* @__PURE__ */ jsxs32(
8632
8679
  "div",
8633
8680
  {
8634
8681
  ref,
8635
8682
  className: cn(
8636
8683
  "flex flex-row items-center gap-10 p-3.5 rounded-xl mb-4",
8637
- isCorrect ? "bg-success-background" : "bg-error-background",
8684
+ getClassesByAnswersStatus(),
8638
8685
  className
8639
8686
  ),
8640
8687
  ...props,
8641
8688
  children: [
8642
8689
  /* @__PURE__ */ jsx39("p", { className: "text-text-950 font-bold text-lg", children: "Resultado" }),
8643
- /* @__PURE__ */ jsx39("p", { className: "text-text-700 text-md", children: isCorrect ? "\u{1F389} Parab\xE9ns!!" : "N\xE3o foi dessa vez..." })
8690
+ /* @__PURE__ */ jsx39("p", { className: "text-text-700 text-md", children: getLabelByAnswersStatus() })
8644
8691
  ]
8645
8692
  }
8646
8693
  );
@@ -9468,35 +9515,38 @@ var QuizQuestionList = ({
9468
9515
  case "answered":
9469
9516
  return "Respondida";
9470
9517
  case "skipped":
9471
- return "N\xE3o respondida";
9518
+ return "Em branco";
9472
9519
  default:
9473
9520
  return "Em branco";
9474
9521
  }
9475
9522
  };
9476
- return /* @__PURE__ */ jsx39("div", { className: "space-y-6 px-4", children: Object.entries(filteredGroupedQuestions).map(
9477
- ([subjectId, questions]) => /* @__PURE__ */ jsxs32("section", { className: "flex flex-col gap-2", children: [
9478
- /* @__PURE__ */ jsxs32("span", { className: "pt-6 pb-4 flex flex-row gap-2", children: [
9479
- /* @__PURE__ */ jsx39("div", { className: "bg-primary-500 p-1 rounded-sm flex items-center justify-center", children: /* @__PURE__ */ jsx39(BookOpen, { size: 17, className: "text-white" }) }),
9480
- /* @__PURE__ */ jsx39("p", { className: "text-text-800 font-bold text-lg", children: questions?.[0]?.knowledgeMatrix?.[0]?.subject?.name ?? "Sem mat\xE9ria" })
9481
- ] }),
9482
- /* @__PURE__ */ jsx39("ul", { className: "flex flex-col gap-2", children: questions.map((question) => {
9483
- const status = getQuestionStatus(question.id);
9484
- const questionNumber = getQuestionIndex(question.id);
9485
- return /* @__PURE__ */ jsx39(
9486
- CardStatus,
9487
- {
9488
- header: `Quest\xE3o ${questionNumber.toString().padStart(2, "0")}`,
9489
- label: getStatusLabel(status),
9490
- onClick: () => {
9491
- goToQuestion(questionNumber - 1);
9492
- onQuestionClick?.();
9493
- }
9494
- },
9495
- question.id
9496
- );
9497
- }) })
9498
- ] }, subjectId)
9499
- ) });
9523
+ return /* @__PURE__ */ jsxs32("div", { className: "space-y-6 px-4 h-full", children: [
9524
+ Object.entries(filteredGroupedQuestions).length == 0 && /* @__PURE__ */ jsx39("div", { className: "flex items-center justify-center text-gray-500 py-8 h-full", children: /* @__PURE__ */ jsx39("p", { className: "text-lg", children: "Nenhum resultado" }) }),
9525
+ Object.entries(filteredGroupedQuestions).map(
9526
+ ([subjectId, questions]) => /* @__PURE__ */ jsxs32("section", { className: "flex flex-col gap-2", children: [
9527
+ /* @__PURE__ */ jsxs32("span", { className: "pt-6 pb-4 flex flex-row gap-2", children: [
9528
+ /* @__PURE__ */ jsx39("div", { className: "bg-primary-500 p-1 rounded-sm flex items-center justify-center", children: /* @__PURE__ */ jsx39(BookOpen, { size: 17, className: "text-white" }) }),
9529
+ /* @__PURE__ */ jsx39("p", { className: "text-text-800 font-bold text-lg", children: questions?.[0]?.knowledgeMatrix?.[0]?.subject?.name ?? "Sem mat\xE9ria" })
9530
+ ] }),
9531
+ /* @__PURE__ */ jsx39("ul", { className: "flex flex-col gap-2", children: questions.map((question) => {
9532
+ const status = getQuestionStatus(question.id);
9533
+ const questionNumber = getQuestionIndex(question.id);
9534
+ return /* @__PURE__ */ jsx39(
9535
+ CardStatus,
9536
+ {
9537
+ header: `Quest\xE3o ${questionNumber.toString().padStart(2, "0")}`,
9538
+ label: getStatusLabel(status),
9539
+ onClick: () => {
9540
+ goToQuestion(questionNumber - 1);
9541
+ onQuestionClick?.();
9542
+ }
9543
+ },
9544
+ question.id
9545
+ );
9546
+ }) })
9547
+ ] }, subjectId)
9548
+ )
9549
+ ] });
9500
9550
  };
9501
9551
  var QuizFooter = forwardRef19(
9502
9552
  ({
@@ -9530,7 +9580,7 @@ var QuizFooter = forwardRef19(
9530
9580
  const [modalResultOpen, setModalResultOpen] = useState17(false);
9531
9581
  const [modalNavigateOpen, setModalNavigateOpen] = useState17(false);
9532
9582
  const [modalResolutionOpen, setModalResolutionOpen] = useState17(false);
9533
- const [filterType, setFilterType] = useState17(void 0);
9583
+ const [filterType, setFilterType] = useState17("all");
9534
9584
  const unansweredQuestions = getUnansweredQuestionsFromUserAnswers();
9535
9585
  const allQuestions = getTotalQuestions();
9536
9586
  const handleFinishQuiz = async () => {
@@ -9606,7 +9656,7 @@ var QuizFooter = forwardRef19(
9606
9656
  }
9607
9657
  )
9608
9658
  ] }),
9609
- !isFirstQuestion && /* @__PURE__ */ jsx39(
9659
+ !isFirstQuestion && !isLastQuestion && /* @__PURE__ */ jsx39(
9610
9660
  Button_default,
9611
9661
  {
9612
9662
  size: "small",
@@ -9718,7 +9768,14 @@ var QuizFooter = forwardRef19(
9718
9768
  /* @__PURE__ */ jsxs32("div", { className: "flex flex-row justify-between items-center py-6 pt-6 pb-4 border-b border-border-200", children: [
9719
9769
  /* @__PURE__ */ jsx39("p", { className: "text-text-950 font-bold text-lg", children: "Filtrar por" }),
9720
9770
  /* @__PURE__ */ jsx39("span", { className: "max-w-[266px]", children: /* @__PURE__ */ jsxs32(Select_default, { value: filterType, onValueChange: setFilterType, children: [
9721
- /* @__PURE__ */ jsx39(SelectTrigger, { variant: "rounded", className: "max-w-[266px]", children: /* @__PURE__ */ jsx39(SelectValue, { placeholder: "Selecione uma op\xE7\xE3o" }) }),
9771
+ /* @__PURE__ */ jsx39(
9772
+ SelectTrigger,
9773
+ {
9774
+ variant: "rounded",
9775
+ className: "max-w-[266px] min-w-[160px]",
9776
+ children: /* @__PURE__ */ jsx39(SelectValue, { placeholder: "Selecione uma op\xE7\xE3o" })
9777
+ }
9778
+ ),
9722
9779
  /* @__PURE__ */ jsxs32(SelectContent, { children: [
9723
9780
  /* @__PURE__ */ jsx39(SelectItem, { value: "all", children: "Todas" }),
9724
9781
  /* @__PURE__ */ jsx39(SelectItem, { value: "unanswered", children: "Em branco" }),
@@ -9726,7 +9783,7 @@ var QuizFooter = forwardRef19(
9726
9783
  ] })
9727
9784
  ] }) })
9728
9785
  ] }),
9729
- /* @__PURE__ */ jsx39("div", { className: "flex flex-col gap-2 not-lg:h-[calc(100vh-200px)] lg:max-h-[687px] overflow-y-auto", children: /* @__PURE__ */ jsx39(
9786
+ /* @__PURE__ */ jsx39("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__ */ jsx39(
9730
9787
  QuizQuestionList,
9731
9788
  {
9732
9789
  filterType,
@@ -9968,6 +10025,8 @@ var QuizListResultByMateria = ({
9968
10025
  return "correct";
9969
10026
  if (question.answerStatus === "RESPOSTA_INCORRETA" /* RESPOSTA_INCORRETA */)
9970
10027
  return "incorrect";
10028
+ if (question.answerStatus === "NAO_RESPONDIDO" /* NAO_RESPONDIDO */)
10029
+ return "unanswered";
9971
10030
  return void 0;
9972
10031
  })(),
9973
10032
  onClick: () => onQuestionClick?.(question)