fix: clarify member map empty state

This commit is contained in:
Nico 2026-06-03 13:05:30 -07:00
parent 0361420813
commit 607f74e679
2 changed files with 37 additions and 12 deletions

View File

@ -8,16 +8,20 @@ export default function LocationMapSetupPanel({
onCreateFromZones,
onCreateBlank,
}) {
const description = hasAnyMap
? canManage
? "A draft map exists for this location."
: "A map draft exists for this location, but it has not been published yet."
: canManage
? "Create a rough map for this store location."
: "A household admin has not published a map yet.";
return (
<section className="location-map-setup">
<h2>{hasAnyMap ? "Draft Map" : "No Map"}</h2>
<p>
{hasAnyMap
? "A draft map exists for this location."
: "Create a rough map for this store location."}
</p>
<div className="location-map-setup-actions">
{hasAnyMap ? (
<p>{description}</p>
{hasAnyMap && canManage ? (
<div className="location-map-setup-actions">
<>
<button type="button" className="btn-primary" onClick={onContinue}>
Continue Editing
@ -29,7 +33,9 @@ export default function LocationMapSetupPanel({
Publish Map
</button>
</>
) : canManage ? (
</div>
) : !hasAnyMap && canManage ? (
<div className="location-map-setup-actions">
<>
<button type="button" className="btn-primary" onClick={onCreateFromZones} disabled={saving}>
Create Map From Existing Zones
@ -38,10 +44,8 @@ export default function LocationMapSetupPanel({
Create Blank Map
</button>
</>
) : (
<p className="location-map-muted">A household admin has not published a map yet.</p>
)}
</div>
</div>
) : null}
</section>
);
}

View File

@ -578,3 +578,24 @@ test("members can view a published map but cannot edit it", async ({ page }) =>
await expect(page.getByRole("button", { name: "Save Draft" })).toHaveCount(0);
await expect(page.getByRole("button", { name: "Publish" })).toHaveCount(0);
});
test("members see a clean empty state when no map is published", async ({ page }) => {
await mockMapShell(page, memberHousehold);
await page.route("**/households/1/locations/10/map", async (route) => {
await route.fulfill({
status: 200,
contentType: "application/json",
body: JSON.stringify(noMapState(false)),
});
});
await page.goto("/stores/100/locations/10/map");
await expect(page.getByRole("heading", { name: "No Map" })).toBeVisible();
await expect(page.getByText("A household admin has not published a map yet.")).toBeVisible();
await expect(page.getByText("Create a rough map for this store location.")).toHaveCount(0);
await expect(page.getByRole("button", { name: "Create Map From Existing Zones" })).toHaveCount(0);
await expect(page.getByRole("button", { name: "Create Blank Map" })).toHaveCount(0);
await expect(page.getByLabel("Map controls")).toHaveCount(0);
});