analytica-frontend-lib 1.2.65 → 1.2.66
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.js +14 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -12234,7 +12234,7 @@ var createQuestionsListHook = (apiClient) => {
|
|
|
12234
12234
|
|
|
12235
12235
|
// src/components/ActivityCreate/ActivityCreate.tsx
|
|
12236
12236
|
import { useCallback as useCallback5, useEffect as useEffect23, useMemo as useMemo11, useState as useState24, useRef as useRef15 } from "react";
|
|
12237
|
-
import {
|
|
12237
|
+
import { useSearchParams, useNavigate } from "react-router-dom";
|
|
12238
12238
|
import { Funnel } from "phosphor-react";
|
|
12239
12239
|
|
|
12240
12240
|
// src/components/ActivityListQuestions/ActivityListQuestions.tsx
|
|
@@ -12856,8 +12856,10 @@ var CreateActivity = ({
|
|
|
12856
12856
|
onCreateActivity,
|
|
12857
12857
|
onSaveModel
|
|
12858
12858
|
}) => {
|
|
12859
|
-
const
|
|
12859
|
+
const [searchParams] = useSearchParams();
|
|
12860
12860
|
const navigate = useNavigate();
|
|
12861
|
+
const typeParam = searchParams.get("type") || void 0;
|
|
12862
|
+
const idParam = searchParams.get("id") || void 0;
|
|
12861
12863
|
const applyFilters = useQuestionFiltersStore(
|
|
12862
12864
|
(state) => state.applyFilters
|
|
12863
12865
|
);
|
|
@@ -12878,9 +12880,9 @@ var CreateActivity = ({
|
|
|
12878
12880
|
const [loading, setLoading] = useState24(false);
|
|
12879
12881
|
const [questions, setQuestions] = useState24([]);
|
|
12880
12882
|
const [loadingInitialQuestions, setLoadingInitialQuestions] = useState24(false);
|
|
12881
|
-
const [draftId, setDraftId] = useState24(
|
|
12883
|
+
const [draftId, setDraftId] = useState24(idParam ?? null);
|
|
12882
12884
|
const [activityType, setActivityType] = useState24(
|
|
12883
|
-
getTypeFromUrlString(
|
|
12885
|
+
getTypeFromUrlString(typeParam)
|
|
12884
12886
|
);
|
|
12885
12887
|
const [lastSavedAt, setLastSavedAt] = useState24(null);
|
|
12886
12888
|
const [isSaving, setIsSaving] = useState24(false);
|
|
@@ -12930,10 +12932,10 @@ var CreateActivity = ({
|
|
|
12930
12932
|
}, [activity?.id, activity?.filters, resolvedPreFilters]);
|
|
12931
12933
|
useEffect23(() => {
|
|
12932
12934
|
const fetchActivityDraft = async () => {
|
|
12933
|
-
if (
|
|
12935
|
+
if (idParam && idParam !== lastFetchedActivityIdRef.current) {
|
|
12934
12936
|
setLoading(true);
|
|
12935
12937
|
try {
|
|
12936
|
-
const response = await apiClient.get(`/activity-drafts/${
|
|
12938
|
+
const response = await apiClient.get(`/activity-drafts/${idParam}`);
|
|
12937
12939
|
const activityData = "data" in response.data ? response.data.data : response.data;
|
|
12938
12940
|
setActivity(activityData);
|
|
12939
12941
|
setPreFilters(activityData.filters);
|
|
@@ -12942,7 +12944,7 @@ var CreateActivity = ({
|
|
|
12942
12944
|
if (activityData.updatedAt) {
|
|
12943
12945
|
setLastSavedAt(new Date(activityData.updatedAt));
|
|
12944
12946
|
}
|
|
12945
|
-
lastFetchedActivityIdRef.current =
|
|
12947
|
+
lastFetchedActivityIdRef.current = idParam;
|
|
12946
12948
|
} catch (error) {
|
|
12947
12949
|
console.error("Erro ao buscar rascunho da atividade:", error);
|
|
12948
12950
|
addToast({
|
|
@@ -12958,19 +12960,19 @@ var CreateActivity = ({
|
|
|
12958
12960
|
}
|
|
12959
12961
|
};
|
|
12960
12962
|
fetchActivityDraft();
|
|
12961
|
-
}, [
|
|
12963
|
+
}, [idParam, apiClient, addToast]);
|
|
12962
12964
|
useEffect23(() => {
|
|
12963
12965
|
if (activity?.id && activity?.type) {
|
|
12964
12966
|
const urlType = getTypeFromUrl(activity.type);
|
|
12965
|
-
const currentUrlType =
|
|
12966
|
-
const currentUrlId =
|
|
12967
|
+
const currentUrlType = typeParam;
|
|
12968
|
+
const currentUrlId = idParam;
|
|
12967
12969
|
if (!currentUrlType || !currentUrlId || currentUrlId !== activity.id || currentUrlType !== urlType) {
|
|
12968
|
-
navigate(`/criar-atividade
|
|
12970
|
+
navigate(`/criar-atividade?type=${urlType}&id=${activity.id}`, {
|
|
12969
12971
|
replace: true
|
|
12970
12972
|
});
|
|
12971
12973
|
}
|
|
12972
12974
|
}
|
|
12973
|
-
}, [activity?.id, activity?.type,
|
|
12975
|
+
}, [activity?.id, activity?.type, typeParam, idParam, navigate]);
|
|
12974
12976
|
const validateSaveConditions = useCallback5(() => {
|
|
12975
12977
|
if (questions.length === 0 && !hasFirstSaveBeenDone.current) {
|
|
12976
12978
|
return false;
|
|
@@ -13091,7 +13093,7 @@ var CreateActivity = ({
|
|
|
13091
13093
|
lastFetchedActivityIdRef.current = savedDraft.id;
|
|
13092
13094
|
if (wasNewDraft && savedDraft.id) {
|
|
13093
13095
|
const urlType = getTypeFromUrl(savedDraft.type);
|
|
13094
|
-
navigate(`/criar-atividade
|
|
13096
|
+
navigate(`/criar-atividade?type=${urlType}&id=${savedDraft.id}`, {
|
|
13095
13097
|
replace: true
|
|
13096
13098
|
});
|
|
13097
13099
|
}
|