fix(medusa,dashboard): don't send price updates for deleted regions/currencies (#9361)

**What**
- Fixes an issue where the admin dashboard would send region prices for deleted regions.
- Also, includes the implementation for `GET /admin/shipping-options/:id` and its corresponding SDK function.

**Why**
- When a region price for a deleted region was sent to the backend it would result in the insert hitting a not null constraint on the currency_code for prices. To avoid this the dashboard should not send region prices for deleted regions. 

**Additional context**
- Prices for deleted regions should ideally not be returned when fetching shipping option prices. However, we don't yet have a mechanism for cleaning up region prices after a region is deleted.

Fixes CC-540
This commit is contained in:
Sebastian Rindom
2024-09-30 13:51:55 +02:00
committed by GitHub
parent 7484cef0fa
commit 852df3f764
8 changed files with 207 additions and 55 deletions
@@ -18,24 +18,24 @@ export const shippingOptionsQueryKeys = queryKeysFactory(
SHIPPING_OPTIONS_QUERY_KEY
)
// TODO: Endpoint is not implemented yet
// export const useShippingOption = (
// id: string,
// options?: UseQueryOptions<
// HttpTypes.AdminShippingOptionResponse,
// Error,
// HttpTypes.AdminShippingOptionResponse,
// QueryKey
// >
// ) => {
// const { data, ...rest } = useQuery({
// queryFn: () => sdk.admin.shippingOption.retrieve(id),
// queryKey: shippingOptionsQueryKeys.retrieve(id),
// ...options,
// })
export const useShippingOption = (
id: string,
query?: Record<string, any>,
options?: UseQueryOptions<
HttpTypes.AdminShippingOptionResponse,
Error,
HttpTypes.AdminShippingOptionResponse,
QueryKey
>
) => {
const { data, ...rest } = useQuery({
queryFn: () => sdk.admin.shippingOption.retrieve(id, query),
queryKey: shippingOptionsQueryKeys.detail(id),
...options,
})
// return { ...data, ...rest }
// }
return { ...data, ...rest }
}
export const useShippingOptions = (
query?: HttpTypes.AdminShippingOptionListParams,