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.js
CHANGED
|
@@ -13065,8 +13065,10 @@ var CreateActivity = ({
|
|
|
13065
13065
|
onCreateActivity,
|
|
13066
13066
|
onSaveModel
|
|
13067
13067
|
}) => {
|
|
13068
|
-
const
|
|
13068
|
+
const [searchParams] = (0, import_react_router_dom.useSearchParams)();
|
|
13069
13069
|
const navigate = (0, import_react_router_dom.useNavigate)();
|
|
13070
|
+
const typeParam = searchParams.get("type") || void 0;
|
|
13071
|
+
const idParam = searchParams.get("id") || void 0;
|
|
13070
13072
|
const applyFilters = useQuestionFiltersStore(
|
|
13071
13073
|
(state) => state.applyFilters
|
|
13072
13074
|
);
|
|
@@ -13087,9 +13089,9 @@ var CreateActivity = ({
|
|
|
13087
13089
|
const [loading, setLoading] = (0, import_react38.useState)(false);
|
|
13088
13090
|
const [questions, setQuestions] = (0, import_react38.useState)([]);
|
|
13089
13091
|
const [loadingInitialQuestions, setLoadingInitialQuestions] = (0, import_react38.useState)(false);
|
|
13090
|
-
const [draftId, setDraftId] = (0, import_react38.useState)(
|
|
13092
|
+
const [draftId, setDraftId] = (0, import_react38.useState)(idParam ?? null);
|
|
13091
13093
|
const [activityType, setActivityType] = (0, import_react38.useState)(
|
|
13092
|
-
getTypeFromUrlString(
|
|
13094
|
+
getTypeFromUrlString(typeParam)
|
|
13093
13095
|
);
|
|
13094
13096
|
const [lastSavedAt, setLastSavedAt] = (0, import_react38.useState)(null);
|
|
13095
13097
|
const [isSaving, setIsSaving] = (0, import_react38.useState)(false);
|
|
@@ -13139,10 +13141,10 @@ var CreateActivity = ({
|
|
|
13139
13141
|
}, [activity?.id, activity?.filters, resolvedPreFilters]);
|
|
13140
13142
|
(0, import_react38.useEffect)(() => {
|
|
13141
13143
|
const fetchActivityDraft = async () => {
|
|
13142
|
-
if (
|
|
13144
|
+
if (idParam && idParam !== lastFetchedActivityIdRef.current) {
|
|
13143
13145
|
setLoading(true);
|
|
13144
13146
|
try {
|
|
13145
|
-
const response = await apiClient.get(`/activity-drafts/${
|
|
13147
|
+
const response = await apiClient.get(`/activity-drafts/${idParam}`);
|
|
13146
13148
|
const activityData = "data" in response.data ? response.data.data : response.data;
|
|
13147
13149
|
setActivity(activityData);
|
|
13148
13150
|
setPreFilters(activityData.filters);
|
|
@@ -13151,7 +13153,7 @@ var CreateActivity = ({
|
|
|
13151
13153
|
if (activityData.updatedAt) {
|
|
13152
13154
|
setLastSavedAt(new Date(activityData.updatedAt));
|
|
13153
13155
|
}
|
|
13154
|
-
lastFetchedActivityIdRef.current =
|
|
13156
|
+
lastFetchedActivityIdRef.current = idParam;
|
|
13155
13157
|
} catch (error) {
|
|
13156
13158
|
console.error("Erro ao buscar rascunho da atividade:", error);
|
|
13157
13159
|
addToast({
|
|
@@ -13167,19 +13169,19 @@ var CreateActivity = ({
|
|
|
13167
13169
|
}
|
|
13168
13170
|
};
|
|
13169
13171
|
fetchActivityDraft();
|
|
13170
|
-
}, [
|
|
13172
|
+
}, [idParam, apiClient, addToast]);
|
|
13171
13173
|
(0, import_react38.useEffect)(() => {
|
|
13172
13174
|
if (activity?.id && activity?.type) {
|
|
13173
13175
|
const urlType = getTypeFromUrl(activity.type);
|
|
13174
|
-
const currentUrlType =
|
|
13175
|
-
const currentUrlId =
|
|
13176
|
+
const currentUrlType = typeParam;
|
|
13177
|
+
const currentUrlId = idParam;
|
|
13176
13178
|
if (!currentUrlType || !currentUrlId || currentUrlId !== activity.id || currentUrlType !== urlType) {
|
|
13177
|
-
navigate(`/criar-atividade
|
|
13179
|
+
navigate(`/criar-atividade?type=${urlType}&id=${activity.id}`, {
|
|
13178
13180
|
replace: true
|
|
13179
13181
|
});
|
|
13180
13182
|
}
|
|
13181
13183
|
}
|
|
13182
|
-
}, [activity?.id, activity?.type,
|
|
13184
|
+
}, [activity?.id, activity?.type, typeParam, idParam, navigate]);
|
|
13183
13185
|
const validateSaveConditions = (0, import_react38.useCallback)(() => {
|
|
13184
13186
|
if (questions.length === 0 && !hasFirstSaveBeenDone.current) {
|
|
13185
13187
|
return false;
|
|
@@ -13300,7 +13302,7 @@ var CreateActivity = ({
|
|
|
13300
13302
|
lastFetchedActivityIdRef.current = savedDraft.id;
|
|
13301
13303
|
if (wasNewDraft && savedDraft.id) {
|
|
13302
13304
|
const urlType = getTypeFromUrl(savedDraft.type);
|
|
13303
|
-
navigate(`/criar-atividade
|
|
13305
|
+
navigate(`/criar-atividade?type=${urlType}&id=${savedDraft.id}`, {
|
|
13304
13306
|
replace: true
|
|
13305
13307
|
});
|
|
13306
13308
|
}
|