Add store location map manager #20
@ -58,7 +58,7 @@ export default function useLocationMapDraftActions({
|
||||
if (!isCurrentScope()) return;
|
||||
toast.error("Create map failed", getApiErrorMessage(error, "Failed to create map"));
|
||||
} finally {
|
||||
endSaving();
|
||||
if (isCurrentScope()) endSaving();
|
||||
}
|
||||
}, [
|
||||
activeHouseholdId, applyDraftResponse, beginSaving, endSaving, isCurrentScope,
|
||||
@ -78,7 +78,7 @@ export default function useLocationMapDraftActions({
|
||||
if (!isCurrentScope()) return;
|
||||
toast.error("Create map failed", getApiErrorMessage(error, "Failed to create map from zones"));
|
||||
} finally {
|
||||
endSaving();
|
||||
if (isCurrentScope()) endSaving();
|
||||
}
|
||||
}, [
|
||||
activeHouseholdId, applyDraftResponse, beginSaving, endSaving, isCurrentScope,
|
||||
@ -100,7 +100,7 @@ export default function useLocationMapDraftActions({
|
||||
if (!isCurrentScope()) return;
|
||||
toast.error("Save draft failed", getApiErrorMessage(error, "Failed to save map draft"));
|
||||
} finally {
|
||||
endSaving();
|
||||
if (isCurrentScope()) endSaving();
|
||||
}
|
||||
}, [
|
||||
activeHouseholdId, applyDraftResponse, beginSaving, endSaving, isCurrentScope, locationId,
|
||||
@ -137,7 +137,7 @@ export default function useLocationMapDraftActions({
|
||||
const message = getApiErrorMessage(error, "Failed to publish map");
|
||||
toast.error("Publish failed", savedPendingDraft ? `${message}. Draft changes were saved.` : message);
|
||||
} finally {
|
||||
endSaving();
|
||||
if (isCurrentScope()) endSaving();
|
||||
}
|
||||
}, [
|
||||
activeHouseholdId, applyDraftResponse, beginSaving, endSaving, hasUnsavedChanges, isCurrentScope,
|
||||
|
||||
@ -88,6 +88,8 @@ export default function useLocationMapDraftState({
|
||||
|
||||
setLoading(true);
|
||||
setLoadError(null);
|
||||
setSaving(false);
|
||||
setSavingAction(null);
|
||||
setFilters({ ...DEFAULT_MAP_FILTERS });
|
||||
setLayersOpen(false);
|
||||
try {
|
||||
|
||||
@ -702,12 +702,14 @@ test("ignores stale map save responses after switching locations", async ({ page
|
||||
|
||||
await expect(page.getByRole("button", { name: "Map area Ontario Produce" })).toBeVisible();
|
||||
await expect(page.locator(".location-map-title span")).toHaveText("Ontario");
|
||||
await expect(page.getByRole("button", { name: "Edit Draft" })).toBeEnabled();
|
||||
|
||||
releaseSaveResponse();
|
||||
await saveResponded;
|
||||
|
||||
await expect(page.getByRole("button", { name: "Map area Ontario Produce" })).toBeVisible();
|
||||
await expect(page.locator(".location-map-title span")).toHaveText("Ontario");
|
||||
await expect(page.getByRole("button", { name: "Edit Draft" })).toBeEnabled();
|
||||
await expect(page.getByRole("button", { name: "Map area Saved Eastvale Bakery" })).toHaveCount(0);
|
||||
await expect(page.getByText("Saved draft")).toHaveCount(0);
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user