Add store location map manager #20
@ -8,16 +8,20 @@ export default function LocationMapSetupPanel({
|
|||||||
onCreateFromZones,
|
onCreateFromZones,
|
||||||
onCreateBlank,
|
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 (
|
return (
|
||||||
<section className="location-map-setup">
|
<section className="location-map-setup">
|
||||||
<h2>{hasAnyMap ? "Draft Map" : "No Map"}</h2>
|
<h2>{hasAnyMap ? "Draft Map" : "No Map"}</h2>
|
||||||
<p>
|
<p>{description}</p>
|
||||||
{hasAnyMap
|
{hasAnyMap && canManage ? (
|
||||||
? "A draft map exists for this location."
|
|
||||||
: "Create a rough map for this store location."}
|
|
||||||
</p>
|
|
||||||
<div className="location-map-setup-actions">
|
<div className="location-map-setup-actions">
|
||||||
{hasAnyMap ? (
|
|
||||||
<>
|
<>
|
||||||
<button type="button" className="btn-primary" onClick={onContinue}>
|
<button type="button" className="btn-primary" onClick={onContinue}>
|
||||||
Continue Editing
|
Continue Editing
|
||||||
@ -29,7 +33,9 @@ export default function LocationMapSetupPanel({
|
|||||||
Publish Map
|
Publish Map
|
||||||
</button>
|
</button>
|
||||||
</>
|
</>
|
||||||
) : canManage ? (
|
</div>
|
||||||
|
) : !hasAnyMap && canManage ? (
|
||||||
|
<div className="location-map-setup-actions">
|
||||||
<>
|
<>
|
||||||
<button type="button" className="btn-primary" onClick={onCreateFromZones} disabled={saving}>
|
<button type="button" className="btn-primary" onClick={onCreateFromZones} disabled={saving}>
|
||||||
Create Map From Existing Zones
|
Create Map From Existing Zones
|
||||||
@ -38,10 +44,8 @@ export default function LocationMapSetupPanel({
|
|||||||
Create Blank Map
|
Create Blank Map
|
||||||
</button>
|
</button>
|
||||||
</>
|
</>
|
||||||
) : (
|
|
||||||
<p className="location-map-muted">A household admin has not published a map yet.</p>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
|
) : null}
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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: "Save Draft" })).toHaveCount(0);
|
||||||
await expect(page.getByRole("button", { name: "Publish" })).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);
|
||||||
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user