analytica-frontend-lib 1.1.23 → 1.1.24

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
@@ -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 response = await options.api.get(options.endpoint, {
7925
- headers: {
7926
- Authorization: `Bearer ${authParams.token}`
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(response.data.data);
7930
- handleProfileSelection(response.data.data, options.setSelectedProfile);
7931
- handleUserData(response.data.data, options.setUser);
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 useRef10
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 = useRef10([]);
8765
- const prevQuestionIdRef = useRef10("");
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 = useRef10(null);
8892
+ const textareaRef = useRef11(null);
8860
8893
  const handleAnswerChange = (value) => {
8861
8894
  if (currentQuestion) {
8862
8895
  selectDissertativeAnswer(currentQuestion.id, value);