feat(core-flows,dashboard,js-sdk,medusa,types): support Fulfillment Options (#10622)

**What**
- add a list point for fetching fulfillment options for a provider
- add FO support on SO create & update on dashboard
- pass `cart` and `stockLocation` to `validateFufillmentData` context

---

CLOSES CMRC-789
CLOSES CMRC-790
This commit is contained in:
Frane Polić
2024-12-18 10:16:26 +01:00
committed by GitHub
parent f3eca7734e
commit bde4b82194
20 changed files with 1850 additions and 487 deletions

View File

@@ -9,6 +9,12 @@ export const fulfillmentProvidersQueryKeys = queryKeysFactory(
FULFILLMENT_PROVIDERS_QUERY_KEY
)
const FULFILLMENT_PROVIDER_OPTIONS_QUERY_KEY =
"fulfillment_provider_options" as const
export const fulfillmentProviderOptionsQueryKeys = queryKeysFactory(
FULFILLMENT_PROVIDER_OPTIONS_QUERY_KEY
)
export const useFulfillmentProviders = (
query?: HttpTypes.AdminFulfillmentProviderListParams,
options?: Omit<
@@ -29,3 +35,25 @@ export const useFulfillmentProviders = (
return { ...data, ...rest }
}
export const useFulfillmentProviderOptions = (
providerId: string,
options?: Omit<
UseQueryOptions<
HttpTypes.AdminFulfillmentProviderOptionsListResponse,
FetchError,
HttpTypes.AdminFulfillmentProviderOptionsListResponse,
QueryKey
>,
"queryFn" | "queryKey"
>
) => {
const { data, ...rest } = useQuery({
queryFn: () =>
sdk.admin.fulfillmentProvider.listFulfillmentOptions(providerId),
queryKey: fulfillmentProviderOptionsQueryKeys.list(providerId),
...options,
})
return { ...data, ...rest }
}