fix(dashboard, fulfilment): fulfilment providers enabled check (#9415)
**What** - hide disabled fulfilment providers on the admin - check if the fulfilment provider has an identifier when loading providers --- FIXES CC-549
This commit is contained in:
+1
@@ -20,6 +20,7 @@ function LocationsFulfillmentProvidersSection({
|
|||||||
const { fulfillment_providers } = useFulfillmentProviders({
|
const { fulfillment_providers } = useFulfillmentProviders({
|
||||||
stock_location_id: location.id,
|
stock_location_id: location.id,
|
||||||
fields: "id",
|
fields: "id",
|
||||||
|
is_enabled: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+1
-1
@@ -69,7 +69,7 @@ export const LocationEditFulfillmentProvidersForm = ({
|
|||||||
|
|
||||||
const { fulfillment_providers, count, isLoading, isError, error } =
|
const { fulfillment_providers, count, isLoading, isError, error } =
|
||||||
useFulfillmentProviders(
|
useFulfillmentProviders(
|
||||||
{ ...searchParams },
|
{ ...searchParams, is_enabled: true },
|
||||||
{ placeholderData: keepPreviousData }
|
{ placeholderData: keepPreviousData }
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
+3
-5
@@ -6,12 +6,10 @@ import { LocationEditFulfillmentProvidersForm } from "./components/edit-fulfillm
|
|||||||
|
|
||||||
export const LocationFulfillmentProviders = () => {
|
export const LocationFulfillmentProviders = () => {
|
||||||
const { location_id } = useParams()
|
const { location_id } = useParams()
|
||||||
const { stock_location, isPending, isError, error } = useStockLocation(
|
const { stock_location, isPending, isFetching, isError, error } =
|
||||||
location_id!,
|
useStockLocation(location_id!, { fields: "id,*fulfillment_providers" })
|
||||||
{ fields: "id,*fulfillment_providers" }
|
|
||||||
)
|
|
||||||
|
|
||||||
const ready = !isPending && !!stock_location
|
const ready = !isPending && !isFetching && !!stock_location
|
||||||
|
|
||||||
if (isError) {
|
if (isError) {
|
||||||
throw error
|
throw error
|
||||||
|
|||||||
@@ -10,7 +10,9 @@ export const RegionCreate = () => {
|
|||||||
const storeCurrencies = (store?.supported_currencies ?? []).map(
|
const storeCurrencies = (store?.supported_currencies ?? []).map(
|
||||||
(c) => currencies[c.currency_code.toUpperCase()]
|
(c) => currencies[c.currency_code.toUpperCase()]
|
||||||
)
|
)
|
||||||
const { payment_providers: paymentProviders = [] } = usePaymentProviders()
|
const { payment_providers: paymentProviders = [] } = usePaymentProviders({
|
||||||
|
is_enabled: true,
|
||||||
|
})
|
||||||
|
|
||||||
if (isError) {
|
if (isError) {
|
||||||
throw error
|
throw error
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ export const RegionEdit = () => {
|
|||||||
)
|
)
|
||||||
const { payment_providers: paymentProviders = [] } = usePaymentProviders({
|
const { payment_providers: paymentProviders = [] } = usePaymentProviders({
|
||||||
limit: 999,
|
limit: 999,
|
||||||
|
is_enabled: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
if (isRegionError) {
|
if (isRegionError) {
|
||||||
|
|||||||
@@ -33,6 +33,12 @@ export default class FulfillmentProviderService extends ModulesSdkUtils.MedusaIn
|
|||||||
providerClass: Constructor<IFulfillmentProvider>,
|
providerClass: Constructor<IFulfillmentProvider>,
|
||||||
optionName?: string
|
optionName?: string
|
||||||
) {
|
) {
|
||||||
|
if (!(providerClass as any).identifier) {
|
||||||
|
throw new MedusaError(
|
||||||
|
MedusaError.Types.INVALID_ARGUMENT,
|
||||||
|
`Trying to register a fulfillment provider without an identifier.`
|
||||||
|
)
|
||||||
|
}
|
||||||
return `${(providerClass as any).identifier}_${optionName}`
|
return `${(providerClass as any).identifier}_${optionName}`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import {
|
|||||||
ModulesSdkTypes,
|
ModulesSdkTypes,
|
||||||
} from "@medusajs/framework/types"
|
} from "@medusajs/framework/types"
|
||||||
import { Lifetime, asFunction, asValue } from "awilix"
|
import { Lifetime, asFunction, asValue } from "awilix"
|
||||||
|
import { MedusaError } from "@medusajs/utils"
|
||||||
|
|
||||||
import { PaymentProviderService } from "@services"
|
import { PaymentProviderService } from "@services"
|
||||||
import * as providers from "../providers"
|
import * as providers from "../providers"
|
||||||
@@ -13,6 +14,13 @@ import * as providers from "../providers"
|
|||||||
const PROVIDER_REGISTRATION_KEY = "payment_providers"
|
const PROVIDER_REGISTRATION_KEY = "payment_providers"
|
||||||
|
|
||||||
const registrationFn = async (klass, container, pluginOptions) => {
|
const registrationFn = async (klass, container, pluginOptions) => {
|
||||||
|
if (!klass?.PROVIDER) {
|
||||||
|
throw new MedusaError(
|
||||||
|
MedusaError.Types.INVALID_ARGUMENT,
|
||||||
|
`Trying to register a payment provider without a provider identifier.`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
const key = `pp_${klass.PROVIDER}_${pluginOptions.id}`
|
const key = `pp_${klass.PROVIDER}_${pluginOptions.id}`
|
||||||
|
|
||||||
container.register({
|
container.register({
|
||||||
|
|||||||
Reference in New Issue
Block a user