From 497c7c55c773a62510e1ed899199dfd35c05ab3f Mon Sep 17 00:00:00 2001 From: Rares Stefan Date: Tue, 21 Mar 2023 09:12:58 +0100 Subject: [PATCH] feat(admin-ui): Encode location id in URL on location table (#3533) Encoded the `location_id` into the query params and ensured it gets parsed on mount, into defaults. This allows safer refreshes of the locations table or accurate deep-links to be shared. Resolves CORE-1252 --- .changeset/wicked-cheetahs-fail.md | 5 +++++ .../templates/inventory-table/use-inventory-filters.ts | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 .changeset/wicked-cheetahs-fail.md diff --git a/.changeset/wicked-cheetahs-fail.md b/.changeset/wicked-cheetahs-fail.md new file mode 100644 index 0000000000..9cb2cd77cc --- /dev/null +++ b/.changeset/wicked-cheetahs-fail.md @@ -0,0 +1,5 @@ +--- +"@medusajs/admin-ui": patch +--- + +feat(admin-ui): Encode location id in URL on location table diff --git a/packages/admin-ui/ui/src/components/templates/inventory-table/use-inventory-filters.ts b/packages/admin-ui/ui/src/components/templates/inventory-table/use-inventory-filters.ts index b529c5b793..090634cbe3 100644 --- a/packages/admin-ui/ui/src/components/templates/inventory-table/use-inventory-filters.ts +++ b/packages/admin-ui/ui/src/components/templates/inventory-table/use-inventory-filters.ts @@ -25,7 +25,7 @@ interface InventoryFilterState { additionalFilters: InventoryDefaultFilters | null } -const allowedFilters = ["location", "q", "offset", "limit"] +const allowedFilters = ["q", "offset", "limit", "location_id"] const DefaultTabs = {} @@ -226,8 +226,8 @@ export const useInventoryFilters = ( if (value && typeof value === "string") { toQuery["q"] = value } - } else if (key === "offset" || key === "limit") { - toQuery[key] = value + } else if (key === "offset" || key === "limit" || key === "location") { + toQuery[stateFilterMap[key] || key] = value } else if (value.open) { toQuery[stateFilterMap[key]] = value.filter }