analytica-frontend-lib 1.2.35 → 1.2.37

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.
@@ -1,5 +1,5 @@
1
1
  // src/components/ActivityFilters/ActivityFilters.tsx
2
- import { useState as useState9, useEffect as useEffect10, useMemo as useMemo2, useCallback, useRef as useRef6 } from "react";
2
+ import { useState as useState10, useEffect as useEffect11, useMemo as useMemo3, useCallback as useCallback2, useRef as useRef7 } from "react";
3
3
 
4
4
  // src/utils/utils.ts
5
5
  import { clsx } from "clsx";
@@ -4600,9 +4600,503 @@ var questionTypeLabels = {
4600
4600
  ["PREENCHER" /* PREENCHER */]: "Preencher Lacunas"
4601
4601
  };
4602
4602
 
4603
+ // src/hooks/useActivityFiltersData.ts
4604
+ import { useState as useState9, useEffect as useEffect10, useCallback, useMemo as useMemo2, useRef as useRef6 } from "react";
4605
+ var mapQuestionTypeToEnum = (type) => {
4606
+ const upperType = type.toUpperCase();
4607
+ const typeMap = {
4608
+ ALTERNATIVA: "ALTERNATIVA" /* ALTERNATIVA */,
4609
+ DISSERTATIVA: "DISSERTATIVA" /* DISSERTATIVA */,
4610
+ MULTIPLA_ESCOLHA: "MULTIPLA_ESCOLHA" /* MULTIPLA_ESCOLHA */,
4611
+ VERDADEIRO_FALSO: "VERDADEIRO_FALSO" /* VERDADEIRO_FALSO */,
4612
+ IMAGEM: "IMAGEM" /* IMAGEM */,
4613
+ LIGAR_PONTOS: "LIGAR_PONTOS" /* LIGAR_PONTOS */,
4614
+ PREENCHER: "PREENCHER" /* PREENCHER */
4615
+ };
4616
+ return typeMap[upperType] || null;
4617
+ };
4618
+ var areCategoriesSame = (prev, current) => {
4619
+ if (prev.length !== current.length) return false;
4620
+ return current.every((category) => {
4621
+ const prevCategory = prev.find((c) => c.key === category.key);
4622
+ if (!prevCategory) return false;
4623
+ const prevIds = (prevCategory.itens || []).map(
4624
+ (item) => item.id
4625
+ );
4626
+ const currentIds = (category.itens || []).map(
4627
+ (item) => item.id
4628
+ );
4629
+ if (prevIds.length !== currentIds.length) return false;
4630
+ return currentIds.every((id) => prevIds.includes(id));
4631
+ });
4632
+ };
4633
+ var mergeCategoriesWithSelection = (prev, current) => {
4634
+ return current.map((category) => {
4635
+ const prevCategory = prev.find((c) => c.key === category.key);
4636
+ if (!prevCategory) {
4637
+ return category;
4638
+ }
4639
+ const validSelectedIds = (prevCategory.selectedIds || []).filter(
4640
+ (id) => category.itens?.some((item) => item.id === id)
4641
+ );
4642
+ return {
4643
+ ...category,
4644
+ selectedIds: validSelectedIds
4645
+ };
4646
+ });
4647
+ };
4648
+ var mapSelectedNames = (ids, items) => {
4649
+ return ids.map((id) => {
4650
+ const item = items.find((t) => t.id === id);
4651
+ return item ? item.name : null;
4652
+ }).filter((name) => name !== null);
4653
+ };
4654
+ var useActivityFiltersDataImpl = (apiClient, options) => {
4655
+ const { selectedSubjects, institutionId } = options;
4656
+ const [banksState, setBanksState] = useState9({
4657
+ banks: [],
4658
+ bankYears: [],
4659
+ loading: false,
4660
+ error: null
4661
+ });
4662
+ const loadBanks = useCallback(async () => {
4663
+ setBanksState((prev) => ({ ...prev, loading: true, error: null }));
4664
+ try {
4665
+ const response = await apiClient.get(
4666
+ "/questions/exam-institutions"
4667
+ );
4668
+ const banksMap = /* @__PURE__ */ new Map();
4669
+ const bankYearsArray = [];
4670
+ for (const item of response.data.data) {
4671
+ if (!item.questionBankName) continue;
4672
+ const existingBank = banksMap.get(item.questionBankName);
4673
+ if (existingBank) {
4674
+ if (!existingBank.years.includes(item.year)) {
4675
+ existingBank.years.push(item.year);
4676
+ }
4677
+ existingBank.questionsCount += item.questionsCount;
4678
+ } else {
4679
+ banksMap.set(item.questionBankName, {
4680
+ id: item.questionBankName,
4681
+ name: item.questionBankName,
4682
+ examInstitution: item.questionBankName,
4683
+ years: [item.year],
4684
+ questionsCount: item.questionsCount
4685
+ });
4686
+ }
4687
+ bankYearsArray.push({
4688
+ id: `${item.questionBankYearId}-${item.questionBankName}`,
4689
+ name: item.year,
4690
+ bankId: item.questionBankName
4691
+ });
4692
+ }
4693
+ const banks = Array.from(banksMap.values()).map((bank) => ({
4694
+ id: bank.id,
4695
+ name: bank.name,
4696
+ examInstitution: bank.examInstitution
4697
+ }));
4698
+ setBanksState({
4699
+ banks,
4700
+ bankYears: bankYearsArray,
4701
+ loading: false,
4702
+ error: null
4703
+ });
4704
+ } catch (error) {
4705
+ console.error("Erro ao carregar bancas de vestibular:", error);
4706
+ setBanksState((prev) => ({
4707
+ ...prev,
4708
+ loading: false,
4709
+ error: "Erro ao carregar bancas de vestibular"
4710
+ }));
4711
+ }
4712
+ }, [apiClient]);
4713
+ const [areasState, setAreasState] = useState9({
4714
+ knowledgeAreas: [],
4715
+ loading: false,
4716
+ error: null
4717
+ });
4718
+ const loadKnowledgeAreas = useCallback(async () => {
4719
+ setAreasState((prev) => ({ ...prev, loading: true, error: null }));
4720
+ try {
4721
+ const response = await apiClient.get(
4722
+ "/knowledge/subjects"
4723
+ );
4724
+ setAreasState({
4725
+ knowledgeAreas: response.data.data,
4726
+ loading: false,
4727
+ error: null
4728
+ });
4729
+ } catch (error) {
4730
+ console.error("Erro ao carregar \xE1reas de conhecimento:", error);
4731
+ setAreasState((prev) => ({
4732
+ ...prev,
4733
+ loading: false,
4734
+ error: "Erro ao carregar \xE1reas de conhecimento"
4735
+ }));
4736
+ }
4737
+ }, [apiClient]);
4738
+ const [questionTypesState, setQuestionTypesState] = useState9({
4739
+ questionTypes: [],
4740
+ loading: false,
4741
+ error: null
4742
+ });
4743
+ const loadQuestionTypes = useCallback(async () => {
4744
+ if (!institutionId) {
4745
+ setQuestionTypesState((prev) => ({
4746
+ ...prev,
4747
+ questionTypes: [],
4748
+ loading: false,
4749
+ error: null
4750
+ }));
4751
+ return;
4752
+ }
4753
+ setQuestionTypesState((prev) => ({
4754
+ ...prev,
4755
+ loading: true,
4756
+ error: null
4757
+ }));
4758
+ try {
4759
+ const response = await apiClient.get(
4760
+ `/institutions/${institutionId}/question-types`
4761
+ );
4762
+ const mappedTypes = response.data.data.questionTypes.map(mapQuestionTypeToEnum).filter((type) => type !== null);
4763
+ setQuestionTypesState({
4764
+ questionTypes: mappedTypes,
4765
+ loading: false,
4766
+ error: null
4767
+ });
4768
+ } catch (error) {
4769
+ console.error("Erro ao carregar tipos de quest\xF5es:", error);
4770
+ setQuestionTypesState((prev) => ({
4771
+ ...prev,
4772
+ loading: false,
4773
+ error: "Erro ao carregar tipos de quest\xF5es"
4774
+ }));
4775
+ }
4776
+ }, [apiClient, institutionId]);
4777
+ const [knowledgeStructure, setKnowledgeStructure] = useState9({
4778
+ topics: [],
4779
+ subtopics: [],
4780
+ contents: [],
4781
+ loading: false,
4782
+ error: null
4783
+ });
4784
+ const [knowledgeCategories, setKnowledgeCategories] = useState9([]);
4785
+ const previousSubjectsRef = useRef6(null);
4786
+ const loadTopics = useCallback(
4787
+ async (subjectIds) => {
4788
+ if (subjectIds.length === 0) {
4789
+ setKnowledgeStructure({
4790
+ topics: [],
4791
+ subtopics: [],
4792
+ contents: [],
4793
+ loading: false,
4794
+ error: null
4795
+ });
4796
+ setKnowledgeCategories([]);
4797
+ return;
4798
+ }
4799
+ setKnowledgeStructure((prev) => ({
4800
+ ...prev,
4801
+ loading: true,
4802
+ error: null
4803
+ }));
4804
+ try {
4805
+ const response = await apiClient.post(
4806
+ "/knowledge/topics",
4807
+ { subjectIds }
4808
+ );
4809
+ const topics = response.data.data.map((topic) => ({
4810
+ id: topic.id,
4811
+ name: topic.name
4812
+ }));
4813
+ setKnowledgeStructure((prev) => ({
4814
+ ...prev,
4815
+ topics,
4816
+ subtopics: [],
4817
+ contents: [],
4818
+ loading: false,
4819
+ error: null
4820
+ }));
4821
+ } catch (error) {
4822
+ console.error("Erro ao carregar temas:", error);
4823
+ setKnowledgeStructure((prev) => ({
4824
+ ...prev,
4825
+ topics: [],
4826
+ subtopics: [],
4827
+ contents: [],
4828
+ loading: false,
4829
+ error: "Erro ao carregar temas"
4830
+ }));
4831
+ }
4832
+ },
4833
+ [apiClient]
4834
+ );
4835
+ const loadSubtopics = useCallback(
4836
+ async (topicIds, options2 = {}) => {
4837
+ const { forceApi = false } = options2;
4838
+ if (topicIds.length === 0 && !forceApi) {
4839
+ setKnowledgeStructure((prev) => ({
4840
+ ...prev,
4841
+ subtopics: [],
4842
+ contents: [],
4843
+ loading: false,
4844
+ error: null
4845
+ }));
4846
+ return;
4847
+ }
4848
+ setKnowledgeStructure((prev) => ({
4849
+ ...prev,
4850
+ loading: topicIds.length > 0,
4851
+ error: null
4852
+ }));
4853
+ try {
4854
+ const response = await apiClient.post(
4855
+ "/knowledge/subtopics",
4856
+ { topicIds }
4857
+ );
4858
+ const subtopics = response.data.data.map(
4859
+ (subtopic) => ({
4860
+ id: subtopic.id,
4861
+ name: subtopic.name,
4862
+ topicId: subtopic.topicId || topicIds[0]
4863
+ })
4864
+ );
4865
+ setKnowledgeStructure((prev) => ({
4866
+ ...prev,
4867
+ subtopics,
4868
+ contents: [],
4869
+ loading: false,
4870
+ error: null
4871
+ }));
4872
+ } catch (error) {
4873
+ console.error("Erro ao carregar subtemas:", error);
4874
+ setKnowledgeStructure((prev) => ({
4875
+ ...prev,
4876
+ subtopics: [],
4877
+ contents: [],
4878
+ loading: false,
4879
+ error: "Erro ao carregar subtemas"
4880
+ }));
4881
+ }
4882
+ },
4883
+ [apiClient]
4884
+ );
4885
+ const loadContents = useCallback(
4886
+ async (subtopicIds) => {
4887
+ if (subtopicIds.length === 0) {
4888
+ setKnowledgeStructure((prev) => ({
4889
+ ...prev,
4890
+ contents: [],
4891
+ loading: false,
4892
+ error: null
4893
+ }));
4894
+ return;
4895
+ }
4896
+ setKnowledgeStructure((prev) => ({
4897
+ ...prev,
4898
+ loading: true,
4899
+ error: null
4900
+ }));
4901
+ try {
4902
+ const response = await apiClient.post(
4903
+ "/knowledge/contents",
4904
+ { subtopicIds }
4905
+ );
4906
+ const contents = response.data.data.map(
4907
+ (content) => ({
4908
+ id: content.id,
4909
+ name: content.name,
4910
+ subtopicId: content.subtopicId || subtopicIds[0]
4911
+ })
4912
+ );
4913
+ setKnowledgeStructure((prev) => ({
4914
+ ...prev,
4915
+ contents,
4916
+ loading: false,
4917
+ error: null
4918
+ }));
4919
+ } catch (error) {
4920
+ console.error("Erro ao carregar conte\xFAdos:", error);
4921
+ setKnowledgeStructure((prev) => ({
4922
+ ...prev,
4923
+ contents: [],
4924
+ loading: false,
4925
+ error: "Erro ao carregar conte\xFAdos"
4926
+ }));
4927
+ }
4928
+ },
4929
+ [apiClient]
4930
+ );
4931
+ useEffect10(() => {
4932
+ const previousSubjects = previousSubjectsRef.current;
4933
+ const subjectsChanged = !previousSubjects || previousSubjects.length !== selectedSubjects.length || selectedSubjects.some((id, index) => id !== previousSubjects[index]);
4934
+ if (!subjectsChanged) return;
4935
+ previousSubjectsRef.current = selectedSubjects;
4936
+ if (selectedSubjects.length > 0) {
4937
+ loadTopics(selectedSubjects);
4938
+ return;
4939
+ }
4940
+ setKnowledgeStructure({
4941
+ topics: [],
4942
+ subtopics: [],
4943
+ contents: [],
4944
+ loading: false,
4945
+ error: null
4946
+ });
4947
+ setKnowledgeCategories([]);
4948
+ }, [selectedSubjects, loadTopics]);
4949
+ const handleCategoriesChange = useCallback(
4950
+ (updatedCategories) => {
4951
+ const isFirstChange = knowledgeCategories.length === 0;
4952
+ const currentTemaCategory = knowledgeCategories.find(
4953
+ (c) => c.key === "tema"
4954
+ );
4955
+ const currentSubtemaCategory = knowledgeCategories.find(
4956
+ (c) => c.key === "subtema"
4957
+ );
4958
+ const currentSelectedTopicIds = currentTemaCategory?.selectedIds || [];
4959
+ const currentSelectedSubtopicIds = currentSubtemaCategory?.selectedIds || [];
4960
+ const temaCategory = updatedCategories.find((c) => c.key === "tema");
4961
+ const selectedTopicIds = temaCategory?.selectedIds || [];
4962
+ const subtemaCategory = updatedCategories.find(
4963
+ (c) => c.key === "subtema"
4964
+ );
4965
+ const selectedSubtopicIds = subtemaCategory?.selectedIds || [];
4966
+ setKnowledgeCategories(updatedCategories);
4967
+ const topicIdsChanged = isFirstChange || currentSelectedTopicIds.length !== selectedTopicIds.length || currentSelectedTopicIds.some(
4968
+ (id) => !selectedTopicIds.includes(id)
4969
+ ) || selectedTopicIds.some(
4970
+ (id) => !currentSelectedTopicIds.includes(id)
4971
+ );
4972
+ if (topicIdsChanged) {
4973
+ loadSubtopics(selectedTopicIds, {
4974
+ forceApi: selectedTopicIds.length === 0
4975
+ });
4976
+ }
4977
+ const subtopicIdsChanged = isFirstChange || currentSelectedSubtopicIds.length !== selectedSubtopicIds.length || currentSelectedSubtopicIds.some(
4978
+ (id) => !selectedSubtopicIds.includes(id)
4979
+ ) || selectedSubtopicIds.some(
4980
+ (id) => !currentSelectedSubtopicIds.includes(id)
4981
+ );
4982
+ if (subtopicIdsChanged) {
4983
+ if (selectedSubtopicIds.length > 0) {
4984
+ loadContents(selectedSubtopicIds);
4985
+ } else {
4986
+ loadContents([]);
4987
+ }
4988
+ }
4989
+ },
4990
+ [knowledgeCategories, loadSubtopics, loadContents]
4991
+ );
4992
+ useEffect10(() => {
4993
+ if (knowledgeStructure.topics.length === 0) {
4994
+ setKnowledgeCategories((prev) => {
4995
+ if (prev.length === 0) {
4996
+ return prev;
4997
+ }
4998
+ return [];
4999
+ });
5000
+ return;
5001
+ }
5002
+ const categories = [
5003
+ {
5004
+ key: "tema",
5005
+ label: "Tema",
5006
+ dependsOn: [],
5007
+ itens: knowledgeStructure.topics,
5008
+ selectedIds: []
5009
+ },
5010
+ {
5011
+ key: "subtema",
5012
+ label: "Subtema",
5013
+ dependsOn: ["tema"],
5014
+ itens: knowledgeStructure.subtopics,
5015
+ filteredBy: [{ key: "tema", internalField: "topicId" }],
5016
+ selectedIds: []
5017
+ },
5018
+ {
5019
+ key: "assunto",
5020
+ label: "Assunto",
5021
+ dependsOn: ["subtema"],
5022
+ itens: knowledgeStructure.contents,
5023
+ filteredBy: [{ key: "subtema", internalField: "subtopicId" }],
5024
+ selectedIds: []
5025
+ }
5026
+ ];
5027
+ setKnowledgeCategories(
5028
+ (prev) => areCategoriesSame(prev, categories) ? prev : mergeCategoriesWithSelection(prev, categories)
5029
+ );
5030
+ }, [
5031
+ selectedSubjects,
5032
+ knowledgeStructure.topics,
5033
+ knowledgeStructure.subtopics,
5034
+ knowledgeStructure.contents
5035
+ ]);
5036
+ const selectedKnowledgeSummary = useMemo2(() => {
5037
+ const temaCategory = knowledgeCategories.find((c) => c.key === "tema");
5038
+ const subtemaCategory = knowledgeCategories.find(
5039
+ (c) => c.key === "subtema"
5040
+ );
5041
+ const assuntoCategory = knowledgeCategories.find(
5042
+ (c) => c.key === "assunto"
5043
+ );
5044
+ const selectedTopics = mapSelectedNames(
5045
+ temaCategory?.selectedIds || [],
5046
+ knowledgeStructure.topics
5047
+ );
5048
+ const selectedSubtopics = mapSelectedNames(
5049
+ subtemaCategory?.selectedIds || [],
5050
+ knowledgeStructure.subtopics
5051
+ );
5052
+ const selectedContents = mapSelectedNames(
5053
+ assuntoCategory?.selectedIds || [],
5054
+ knowledgeStructure.contents
5055
+ );
5056
+ return {
5057
+ topics: selectedTopics,
5058
+ subtopics: selectedSubtopics,
5059
+ contents: selectedContents
5060
+ };
5061
+ }, [knowledgeCategories, knowledgeStructure]);
5062
+ const enableSummary = useMemo2(() => {
5063
+ return knowledgeStructure.topics.length === 1 || knowledgeStructure.subtopics.length === 1 || knowledgeStructure.contents.length === 1;
5064
+ }, [knowledgeStructure]);
5065
+ return {
5066
+ // Vestibular Banks
5067
+ banks: banksState.banks,
5068
+ bankYears: banksState.bankYears,
5069
+ loadingBanks: banksState.loading,
5070
+ banksError: banksState.error,
5071
+ loadBanks,
5072
+ // Knowledge Areas
5073
+ knowledgeAreas: areasState.knowledgeAreas,
5074
+ loadingSubjects: areasState.loading,
5075
+ subjectsError: areasState.error,
5076
+ loadKnowledgeAreas,
5077
+ // Knowledge Structure
5078
+ knowledgeStructure,
5079
+ knowledgeCategories,
5080
+ handleCategoriesChange,
5081
+ selectedKnowledgeSummary,
5082
+ enableSummary,
5083
+ loadTopics,
5084
+ loadSubtopics,
5085
+ loadContents,
5086
+ // Question Types
5087
+ questionTypes: questionTypesState.questionTypes,
5088
+ loadingQuestionTypes: questionTypesState.loading,
5089
+ questionTypesError: questionTypesState.error,
5090
+ loadQuestionTypes
5091
+ };
5092
+ };
5093
+ var createUseActivityFiltersData = (apiClient) => {
5094
+ return (options) => useActivityFiltersDataImpl(apiClient, options);
5095
+ };
5096
+
4603
5097
  // src/components/ActivityFilters/ActivityFilters.tsx
4604
5098
  import { jsx as jsx21, jsxs as jsxs16 } from "react/jsx-runtime";
4605
- var questionTypes = [
5099
+ var questionTypesFallback = [
4606
5100
  "ALTERNATIVA" /* ALTERNATIVA */,
4607
5101
  "VERDADEIRO_FALSO" /* VERDADEIRO_FALSO */,
4608
5102
  "DISSERTATIVA" /* DISSERTATIVA */,
@@ -4616,7 +5110,7 @@ var QuestionTypeFilter = ({
4616
5110
  onToggleType,
4617
5111
  allowedQuestionTypes
4618
5112
  }) => {
4619
- const availableQuestionTypes = allowedQuestionTypes || questionTypes;
5113
+ const availableQuestionTypes = allowedQuestionTypes || questionTypesFallback;
4620
5114
  return /* @__PURE__ */ jsxs16("div", { children: [
4621
5115
  /* @__PURE__ */ jsx21(Text_default, { size: "sm", weight: "bold", className: "mb-3 block", children: "Tipo de quest\xE3o" }),
4622
5116
  /* @__PURE__ */ jsx21("div", { className: "grid grid-cols-2 gap-2", children: availableQuestionTypes.map((questionType) => /* @__PURE__ */ jsx21(
@@ -4741,45 +5235,42 @@ var FilterActions = ({
4741
5235
  ] });
4742
5236
  };
4743
5237
  var ActivityFilters = ({
5238
+ apiClient,
4744
5239
  onFiltersChange,
4745
5240
  variant = "default",
4746
- // Data
4747
- banks = [],
4748
- bankYears = [],
4749
- knowledgeAreas = [],
4750
- knowledgeStructure = {
4751
- topics: [],
4752
- subtopics: [],
4753
- contents: [],
4754
- loading: false,
4755
- error: null
4756
- },
4757
- knowledgeCategories = [],
5241
+ institutionId = null,
4758
5242
  // Question types
4759
5243
  allowedQuestionTypes,
4760
- // Loading states
4761
- loadingBanks = false,
4762
- loadingKnowledge: _loadingKnowledge = false,
4763
- loadingSubjects = false,
4764
- // Errors
4765
- banksError = null,
4766
- subjectsError = null,
4767
- // Load functions
4768
- loadBanks,
4769
- loadKnowledge,
4770
- loadTopics,
4771
- loadSubtopics: _loadSubtopics,
4772
- loadContents: _loadContents,
4773
- // Handlers
4774
- handleCategoriesChange,
4775
5244
  // Action buttons
4776
5245
  onClearFilters,
4777
5246
  onApplyFilters
4778
5247
  }) => {
4779
- const [selectedQuestionTypes, setSelectedQuestionTypes] = useState9([]);
4780
- const [selectedSubject, setSelectedSubject] = useState9(null);
4781
- const prevAllowedQuestionTypesRef = useRef6(null);
4782
- useEffect10(() => {
5248
+ const useActivityFiltersData = createUseActivityFiltersData(apiClient);
5249
+ const [selectedQuestionTypes, setSelectedQuestionTypes] = useState10([]);
5250
+ const [selectedSubject, setSelectedSubject] = useState10(null);
5251
+ const {
5252
+ banks,
5253
+ bankYears,
5254
+ loadingBanks,
5255
+ banksError,
5256
+ knowledgeAreas,
5257
+ loadingSubjects,
5258
+ subjectsError,
5259
+ knowledgeStructure,
5260
+ knowledgeCategories,
5261
+ handleCategoriesChange,
5262
+ loadBanks,
5263
+ loadKnowledgeAreas,
5264
+ loadQuestionTypes,
5265
+ questionTypes,
5266
+ loadingQuestionTypes,
5267
+ questionTypesError
5268
+ } = useActivityFiltersData({
5269
+ selectedSubjects: selectedSubject ? [selectedSubject] : [],
5270
+ institutionId
5271
+ });
5272
+ const prevAllowedQuestionTypesRef = useRef7(null);
5273
+ useEffect11(() => {
4783
5274
  if (!allowedQuestionTypes || allowedQuestionTypes.length === 0) {
4784
5275
  prevAllowedQuestionTypesRef.current = null;
4785
5276
  return;
@@ -4812,8 +5303,8 @@ var ActivityFilters = ({
4812
5303
  return prev;
4813
5304
  });
4814
5305
  }, [allowedQuestionTypes]);
4815
- const [bankCategories, setBankCategories] = useState9([]);
4816
- const selectedSubjects = useMemo2(
5306
+ const [bankCategories, setBankCategories] = useState10([]);
5307
+ const selectedSubjects = useMemo3(
4817
5308
  () => selectedSubject ? [selectedSubject] : [],
4818
5309
  [selectedSubject]
4819
5310
  );
@@ -4826,7 +5317,7 @@ var ActivityFilters = ({
4826
5317
  const handleBankCategoriesChange = (updatedCategories) => {
4827
5318
  setBankCategories(updatedCategories);
4828
5319
  };
4829
- useEffect10(() => {
5320
+ useEffect11(() => {
4830
5321
  setBankCategories((prevCategories) => {
4831
5322
  const bankCategory = {
4832
5323
  key: "banca",
@@ -4852,37 +5343,42 @@ var ActivityFilters = ({
4852
5343
  return [bankCategory, yearCategory];
4853
5344
  });
4854
5345
  }, [banks, bankYears]);
4855
- useEffect10(() => {
5346
+ useEffect11(() => {
4856
5347
  if (loadBanks) {
4857
5348
  loadBanks();
4858
5349
  }
4859
- if (loadKnowledge) {
4860
- loadKnowledge();
5350
+ if (loadKnowledgeAreas) {
5351
+ loadKnowledgeAreas();
4861
5352
  }
4862
- }, [loadBanks, loadKnowledge]);
4863
- useEffect10(() => {
4864
- if (selectedSubject && loadTopics) {
4865
- loadTopics([selectedSubject]);
5353
+ if (loadQuestionTypes) {
5354
+ loadQuestionTypes();
5355
+ }
5356
+ }, [loadBanks, loadKnowledgeAreas, loadQuestionTypes, institutionId]);
5357
+ const availableQuestionTypes = useMemo3(() => {
5358
+ const source = questionTypes && questionTypes.length > 0 ? questionTypes : questionTypesFallback;
5359
+ if (!allowedQuestionTypes || allowedQuestionTypes.length === 0) {
5360
+ return source;
4866
5361
  }
4867
- }, [selectedSubject, loadTopics]);
4868
- const getSelectedKnowledgeIds = useCallback(() => {
5362
+ return source.filter((type) => allowedQuestionTypes.includes(type));
5363
+ }, [questionTypes, allowedQuestionTypes]);
5364
+ const getSelectedKnowledgeIds = useCallback2(() => {
4869
5365
  return getSelectedIdsFromCategories(knowledgeCategories, {
4870
5366
  topicIds: "tema",
4871
5367
  subtopicIds: "subtema",
4872
5368
  contentIds: "assunto"
4873
5369
  });
4874
5370
  }, [knowledgeCategories]);
4875
- const getSelectedBankIds = useCallback(() => {
5371
+ const getSelectedBankIds = useCallback2(() => {
4876
5372
  return getSelectedIdsFromCategories(bankCategories, {
4877
5373
  bankIds: "banca",
4878
5374
  yearIds: "ano"
4879
5375
  });
4880
5376
  }, [bankCategories]);
4881
- const onFiltersChangeRef = useRef6(onFiltersChange);
4882
- useEffect10(() => {
5377
+ const onFiltersChangeRef = useRef7(onFiltersChange);
5378
+ useEffect11(() => {
4883
5379
  onFiltersChangeRef.current = onFiltersChange;
4884
5380
  }, [onFiltersChange]);
4885
- useEffect10(() => {
5381
+ useEffect11(() => {
4886
5382
  const knowledgeIds = getSelectedKnowledgeIds();
4887
5383
  const bankIds = getSelectedBankIds();
4888
5384
  const filters = {
@@ -4913,7 +5409,25 @@ var ActivityFilters = ({
4913
5409
  {
4914
5410
  selectedTypes: selectedQuestionTypes,
4915
5411
  onToggleType: toggleQuestionType,
4916
- allowedQuestionTypes
5412
+ allowedQuestionTypes: availableQuestionTypes
5413
+ }
5414
+ ),
5415
+ loadingQuestionTypes && /* @__PURE__ */ jsx21(
5416
+ Text_default,
5417
+ {
5418
+ size: "sm",
5419
+ className: "text-text-600",
5420
+ "data-testid": "question-types-loading",
5421
+ children: "Carregando tipos de quest\xE3o..."
5422
+ }
5423
+ ),
5424
+ questionTypesError && /* @__PURE__ */ jsx21(
5425
+ Text_default,
5426
+ {
5427
+ size: "sm",
5428
+ className: "text-error-500",
5429
+ "data-testid": "question-types-error",
5430
+ children: questionTypesError
4917
5431
  }
4918
5432
  ),
4919
5433
  /* @__PURE__ */ jsxs16("div", { children: [
@@ -4966,7 +5480,7 @@ var ActivityFiltersPopover = ({
4966
5480
  triggerLabel = "Filtro de quest\xF5es",
4967
5481
  ...activityFiltersProps
4968
5482
  }) => {
4969
- const [open, setOpen] = useState9(false);
5483
+ const [open, setOpen] = useState10(false);
4970
5484
  return /* @__PURE__ */ jsxs16(DropdownMenu_default, { open, onOpenChange: setOpen, children: [
4971
5485
  /* @__PURE__ */ jsx21(DropdownMenuTrigger, { children: /* @__PURE__ */ jsx21(Button_default, { variant: "outline", children: triggerLabel }) }),
4972
5486
  /* @__PURE__ */ jsx21(