analytica-frontend-lib 1.1.23 → 1.1.25
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/Auth/useUrlAuthentication/index.d.mts +6 -0
- package/dist/Auth/useUrlAuthentication/index.d.ts +6 -0
- package/dist/Auth/useUrlAuthentication/index.js +41 -8
- package/dist/Auth/useUrlAuthentication/index.js.map +1 -1
- package/dist/Auth/useUrlAuthentication/index.mjs +42 -9
- package/dist/Auth/useUrlAuthentication/index.mjs.map +1 -1
- package/dist/CheckBox/index.d.mts +1 -1
- package/dist/CheckBox/index.d.ts +1 -1
- package/dist/Quiz/index.js +1 -1
- package/dist/Quiz/index.js.map +1 -1
- package/dist/Quiz/index.mjs +1 -1
- package/dist/Quiz/index.mjs.map +1 -1
- package/dist/Radio/index.d.mts +2 -2
- package/dist/Radio/index.d.ts +2 -2
- package/dist/Search/index.d.mts +1 -1
- package/dist/Search/index.d.ts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +42 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +47 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -7862,7 +7862,7 @@ function createZustandAuthAdapter(useAuthStore) {
|
|
|
7862
7862
|
}
|
|
7863
7863
|
|
|
7864
7864
|
// src/components/Auth/useUrlAuthentication.ts
|
|
7865
|
-
import { useEffect as useEffect14 } from "react";
|
|
7865
|
+
import { useEffect as useEffect14, useRef as useRef10 } from "react";
|
|
7866
7866
|
import { useLocation as useLocation2 } from "react-router-dom";
|
|
7867
7867
|
var getAuthParams = (location, extractParams) => {
|
|
7868
7868
|
const searchParams = new URLSearchParams(location.search);
|
|
@@ -7910,28 +7910,58 @@ var handleUserData = (responseData, setUser) => {
|
|
|
7910
7910
|
};
|
|
7911
7911
|
function useUrlAuthentication(options) {
|
|
7912
7912
|
const location = useLocation2();
|
|
7913
|
+
const processedRef = useRef10(false);
|
|
7913
7914
|
useEffect14(() => {
|
|
7914
7915
|
const handleAuthentication = async () => {
|
|
7916
|
+
if (processedRef.current) {
|
|
7917
|
+
return;
|
|
7918
|
+
}
|
|
7915
7919
|
const authParams = getAuthParams(location, options.extractParams);
|
|
7916
7920
|
if (!hasValidAuthParams(authParams)) {
|
|
7917
7921
|
return;
|
|
7918
7922
|
}
|
|
7923
|
+
processedRef.current = true;
|
|
7919
7924
|
try {
|
|
7920
7925
|
options.setTokens({
|
|
7921
7926
|
token: authParams.token,
|
|
7922
7927
|
refreshToken: authParams.refreshToken
|
|
7923
7928
|
});
|
|
7924
|
-
const
|
|
7925
|
-
|
|
7926
|
-
|
|
7929
|
+
const maxRetries = options.maxRetries || 3;
|
|
7930
|
+
const retryDelay = options.retryDelay || 1e3;
|
|
7931
|
+
let retries = 0;
|
|
7932
|
+
let sessionData = null;
|
|
7933
|
+
while (retries < maxRetries && !sessionData) {
|
|
7934
|
+
try {
|
|
7935
|
+
const response = await options.api.get(options.endpoint, {
|
|
7936
|
+
headers: {
|
|
7937
|
+
Authorization: `Bearer ${authParams.token}`
|
|
7938
|
+
}
|
|
7939
|
+
});
|
|
7940
|
+
sessionData = response.data.data;
|
|
7941
|
+
break;
|
|
7942
|
+
} catch (error) {
|
|
7943
|
+
retries++;
|
|
7944
|
+
console.warn(
|
|
7945
|
+
`Tentativa ${retries}/${maxRetries} falhou para ${options.endpoint}:`,
|
|
7946
|
+
error
|
|
7947
|
+
);
|
|
7948
|
+
if (retries < maxRetries) {
|
|
7949
|
+
await new Promise(
|
|
7950
|
+
(resolve) => setTimeout(resolve, retryDelay * retries)
|
|
7951
|
+
);
|
|
7952
|
+
} else {
|
|
7953
|
+
throw error;
|
|
7954
|
+
}
|
|
7927
7955
|
}
|
|
7928
|
-
}
|
|
7929
|
-
options.setSessionInfo(
|
|
7930
|
-
handleProfileSelection(
|
|
7931
|
-
handleUserData(
|
|
7956
|
+
}
|
|
7957
|
+
options.setSessionInfo(sessionData);
|
|
7958
|
+
handleProfileSelection(sessionData, options.setSelectedProfile);
|
|
7959
|
+
handleUserData(sessionData, options.setUser);
|
|
7932
7960
|
options.clearParamsFromURL?.();
|
|
7933
7961
|
} catch (error) {
|
|
7934
7962
|
console.error("Erro ao obter informa\xE7\xF5es da sess\xE3o:", error);
|
|
7963
|
+
processedRef.current = false;
|
|
7964
|
+
options.onError?.(error);
|
|
7935
7965
|
}
|
|
7936
7966
|
};
|
|
7937
7967
|
handleAuthentication();
|
|
@@ -7944,7 +7974,10 @@ function useUrlAuthentication(options) {
|
|
|
7944
7974
|
options.api,
|
|
7945
7975
|
options.endpoint,
|
|
7946
7976
|
options.extractParams,
|
|
7947
|
-
options.clearParamsFromURL
|
|
7977
|
+
options.clearParamsFromURL,
|
|
7978
|
+
options.maxRetries,
|
|
7979
|
+
options.retryDelay,
|
|
7980
|
+
options.onError
|
|
7948
7981
|
]);
|
|
7949
7982
|
}
|
|
7950
7983
|
|
|
@@ -7977,7 +8010,7 @@ import {
|
|
|
7977
8010
|
useId as useId10,
|
|
7978
8011
|
useState as useState17,
|
|
7979
8012
|
useCallback as useCallback4,
|
|
7980
|
-
useRef as
|
|
8013
|
+
useRef as useRef11
|
|
7981
8014
|
} from "react";
|
|
7982
8015
|
|
|
7983
8016
|
// src/components/Quiz/useQuizStore.ts
|
|
@@ -8761,8 +8794,8 @@ var QuizMultipleChoice = ({ paddingBottom }) => {
|
|
|
8761
8794
|
const currentQuestionResult = getQuestionResultByQuestionId(
|
|
8762
8795
|
currentQuestion?.id || ""
|
|
8763
8796
|
);
|
|
8764
|
-
const prevSelectedValuesRef =
|
|
8765
|
-
const prevQuestionIdRef =
|
|
8797
|
+
const prevSelectedValuesRef = useRef11([]);
|
|
8798
|
+
const prevQuestionIdRef = useRef11("");
|
|
8766
8799
|
const allCurrentAnswerIds = useMemo6(() => {
|
|
8767
8800
|
return allCurrentAnswers?.map((answer) => answer.optionId) || [];
|
|
8768
8801
|
}, [allCurrentAnswers]);
|
|
@@ -8856,7 +8889,7 @@ var QuizDissertative = ({ paddingBottom }) => {
|
|
|
8856
8889
|
currentQuestion?.id || ""
|
|
8857
8890
|
);
|
|
8858
8891
|
const currentAnswer = getCurrentAnswer();
|
|
8859
|
-
const textareaRef =
|
|
8892
|
+
const textareaRef = useRef11(null);
|
|
8860
8893
|
const handleAnswerChange = (value) => {
|
|
8861
8894
|
if (currentQuestion) {
|
|
8862
8895
|
selectDissertativeAnswer(currentQuestion.id, value);
|
|
@@ -9497,7 +9530,7 @@ var QuizFooter = forwardRef19(
|
|
|
9497
9530
|
const [modalResultOpen, setModalResultOpen] = useState17(false);
|
|
9498
9531
|
const [modalNavigateOpen, setModalNavigateOpen] = useState17(false);
|
|
9499
9532
|
const [modalResolutionOpen, setModalResolutionOpen] = useState17(false);
|
|
9500
|
-
const [filterType, setFilterType] = useState17(
|
|
9533
|
+
const [filterType, setFilterType] = useState17("all");
|
|
9501
9534
|
const unansweredQuestions = getUnansweredQuestionsFromUserAnswers();
|
|
9502
9535
|
const allQuestions = getTotalQuestions();
|
|
9503
9536
|
const handleFinishQuiz = async () => {
|