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