mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-03 04:33:23 +00:00
fix(dashboard): open the Unassigned tile as the Unassigned filter option
The tile link sent the board API token __unassigned__ as the dispatcher. The drill-down parser stores that as an Advanced Filters dispatcher id, while the filter UI only knows __unassigned, so the banner showed a raw __unassigned__ chip, Assigned to did not tick Unassigned, and the option could not clear it. Send ASSIGNEE_FILTER_UNASSIGNED, as the notification queue link already does; toBoardSearchQueryParams still maps it to __unassigned__ for /board/search, so the rows are unchanged.
This commit is contained in:
parent
67cb490d52
commit
8bb4c0c512
3 changed files with 18 additions and 4 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import { ALL_WIZARD_STATUSES } from "@/domain/work-orders/types/work-order-wizard";
|
||||
import { WO_TYPES, type WOType } from "@/domain/work-orders/types/work-order-wizard";
|
||||
import type { DashboardRangeKey } from "@/domain/dashboard/types/dashboard-range";
|
||||
import { BOARD_DISPATCHER_UNASSIGNED } from "@/domain/work-orders/types/work-order-board";
|
||||
import { ASSIGNEE_FILTER_UNASSIGNED } from "@/domain/work-orders/types/work-order-list";
|
||||
import {
|
||||
addDaysIso,
|
||||
businessTodayIso,
|
||||
|
|
@ -85,7 +85,7 @@ export function workOrderRegionDrilldownSearch(
|
|||
*/
|
||||
export function unassignedDrilldownSearch(range: DashboardRangeKey): URLSearchParams {
|
||||
const search = workOrderRangeDrilldownSearch(range);
|
||||
search.set("dispatchers", BOARD_DISPATCHER_UNASSIGNED);
|
||||
search.set("dispatchers", ASSIGNEE_FILTER_UNASSIGNED);
|
||||
search.set("statuses", OPEN_WIZARD_STATUSES.join(","));
|
||||
return search;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -273,7 +273,7 @@ describe("DashboardPage", () => {
|
|||
|
||||
const weekUrl = new URL(lastNavigation(), "http://x");
|
||||
expect(weekUrl.pathname).toBe("/workorders");
|
||||
expect(weekUrl.searchParams.get("dispatchers")).toBe("__unassigned__");
|
||||
expect(weekUrl.searchParams.get("dispatchers")).toBe("__unassigned");
|
||||
expect(weekUrl.searchParams.get("statuses")).not.toContain("Completed");
|
||||
expect(weekUrl.searchParams.get("dateFrom")).toMatch(/^\d{4}-\d{2}-\d{2}$/);
|
||||
expect(weekUrl.searchParams.get("dateTo")).toMatch(/^\d{4}-\d{2}-\d{2}$/);
|
||||
|
|
@ -282,7 +282,7 @@ describe("DashboardPage", () => {
|
|||
fireEvent.click(screen.getByRole("button", { name: /Unassigned/ }));
|
||||
|
||||
const allTimeUrl = new URL(lastNavigation(), "http://x");
|
||||
expect(allTimeUrl.searchParams.get("dispatchers")).toBe("__unassigned__");
|
||||
expect(allTimeUrl.searchParams.get("dispatchers")).toBe("__unassigned");
|
||||
expect(allTimeUrl.searchParams.has("dateFrom")).toBe(false);
|
||||
expect(allTimeUrl.searchParams.has("dateTo")).toBe(false);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ import {
|
|||
unassignedDrilldownSearch,
|
||||
} from "@/domain/dashboard/utils/work-order-drilldown-links";
|
||||
import { NON_TERMINAL_LIFECYCLE_STATUSES } from "@/domain/work-orders/types/work-order-board";
|
||||
import { ASSIGNEE_FILTER_UNASSIGNED } from "@/domain/work-orders/types/work-order-list";
|
||||
import { buildAdvancedFilterChips } from "@/domain/work-orders/utils/advanced-filters-utils";
|
||||
import { toBoardSearchQueryParams } from "@/domain/work-orders/utils/board-query-params";
|
||||
|
||||
describe("parseDashboardDrilldownParams", () => {
|
||||
|
|
@ -88,6 +90,18 @@ describe("parseDashboardDrilldownParams", () => {
|
|||
expect(weekParams.includeDateless).toBeUndefined();
|
||||
});
|
||||
|
||||
it("opens the Unassigned tile link as the Unassigned option of Assigned to", () => {
|
||||
const filters = parseDashboardDrilldownParams(unassignedDrilldownSearch("this-week"));
|
||||
expect(filters?.dispatchers).toEqual(new Set([ASSIGNEE_FILTER_UNASSIGNED]));
|
||||
|
||||
const chips = buildAdvancedFilterChips(filters!, { dispatcherNameOf: (id) => id });
|
||||
const assignedTo = chips.filter((chip) => chip.group === "Assigned to");
|
||||
expect(assignedTo.map((chip) => chip.value)).toEqual(["Unassigned"]);
|
||||
|
||||
const cleared = assignedTo[0]!.clear(filters!);
|
||||
expect(cleared.dispatchers.size).toBe(0);
|
||||
});
|
||||
|
||||
it("rejects partial or malformed date ranges", () => {
|
||||
expect(
|
||||
parseDashboardDrilldownParams(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue