Add store location map manager #20

Open
nalalangan wants to merge 206 commits from feature/location-map-manager into feature/store-selector-modal
2 changed files with 7 additions and 16 deletions
Showing only changes of commit 7af995f561 - Show all commits

View File

@ -11,9 +11,7 @@ export default function LocationMapSetupPanel({
onCreateBlank, onCreateBlank,
}) { }) {
const hasZones = zoneCount > 0; const hasZones = zoneCount > 0;
const createFromZonesLabel = hasZones const createFromZonesLabel = `Create From ${zoneCount} Zone${zoneCount === 1 ? "" : "s"}`;
? `Create From ${zoneCount} Zone${zoneCount === 1 ? "" : "s"}`
: "Create From Zones";
const createBlankLabel = savingAction === "create-blank" ? "Creating..." : "Create Blank Map"; const createBlankLabel = savingAction === "create-blank" ? "Creating..." : "Create Blank Map";
const createZonesButtonLabel = savingAction === "create-zones" ? "Creating..." : createFromZonesLabel; const createZonesButtonLabel = savingAction === "create-zones" ? "Creating..." : createFromZonesLabel;
const publishLabel = savingAction === "publish" ? "Publishing..." : "Publish"; const publishLabel = savingAction === "publish" ? "Publishing..." : "Publish";
@ -44,14 +42,9 @@ export default function LocationMapSetupPanel({
) : !hasAnyMap && canManage ? ( ) : !hasAnyMap && canManage ? (
<div className="location-map-setup-actions"> <div className="location-map-setup-actions">
{!hasZones ? ( {!hasZones ? (
<>
<button type="button" className="btn-primary" onClick={onCreateBlank} disabled={saving}> <button type="button" className="btn-primary" onClick={onCreateBlank} disabled={saving}>
{createBlankLabel} {createBlankLabel}
</button> </button>
<button type="button" className="btn-secondary" onClick={onCreateFromZones} disabled>
{createFromZonesLabel}
</button>
</>
) : ( ) : (
<> <>
<button type="button" className="btn-primary" onClick={onCreateFromZones} disabled={saving}> <button type="button" className="btn-primary" onClick={onCreateFromZones} disabled={saving}>

View File

@ -440,14 +440,12 @@ test("admin setup uses compact status rows when no zones exist yet", async ({ pa
await expect(setupDetails.getByText("Status")).toHaveCount(0); await expect(setupDetails.getByText("Status")).toHaveCount(0);
await expect(page.getByText("Not started")).toHaveCount(0); await expect(page.getByText("Not started")).toHaveCount(0);
await expect(page.getByText("No zones are available yet.")).toHaveCount(0); await expect(page.getByText("No zones are available yet.")).toHaveCount(0);
await expect(page.getByRole("button", { name: "Create From Zones" })).toBeDisabled(); await expect(page.getByRole("button", { name: "Create From Zones" })).toHaveCount(0);
await expect(page.getByRole("button", { name: "Create Blank Map" })).toBeEnabled(); await expect(page.getByRole("button", { name: "Create Blank Map" })).toBeEnabled();
const blankButtonBox = await page.getByRole("button", { name: "Create Blank Map" }).boundingBox(); const blankButtonBox = await page.getByRole("button", { name: "Create Blank Map" }).boundingBox();
const fromZonesButtonBox = await page.getByRole("button", { name: "Create From Zones" }).boundingBox();
expect(blankButtonBox).not.toBeNull(); expect(blankButtonBox).not.toBeNull();
expect(fromZonesButtonBox).not.toBeNull(); if (!blankButtonBox) throw new Error("No-zone setup action was not measurable");
if (!blankButtonBox || !fromZonesButtonBox) throw new Error("No-zone setup actions were not measurable"); expect(blankButtonBox.height).toBeGreaterThanOrEqual(40);
expect(blankButtonBox.y).toBeLessThan(fromZonesButtonBox.y);
await expect(page.getByLabel("Map controls")).toHaveCount(0); await expect(page.getByLabel("Map controls")).toHaveCount(0);
}); });