Skip to content

The complete open source platform to run your entire marketplace. Storefront, vendor panel, admin console, and integrations in one enterprise-grade platform you own.

refactor(admin): replace FetchError with ClientError, remove useExtension, add seller status cell and hooks

vholik93e380278d31
diff --git a/packages/admin/src/components/common/logo-box/index.ts b/packages/admin/src/components/common/logo-box/index.ts
index 96e7eccdd..bbc1a9b23 100644
--- a/packages/admin/src/components/common/logo-box/index.ts
+++ b/packages/admin/src/components/common/logo-box/index.ts
@@ -1,2 +1 @@
-export * from "./logo-box"
export * from "./avatar-box"
diff --git a/packages/admin/src/components/table/table-cells/seller/seller-status-cell/seller-status-cell.tsx b/packages/admin/src/components/table/table-cells/seller/seller-status-cell/seller-status-cell.tsx
new file mode 100644
index 000000000..371bea350
--- /dev/null
+++ b/packages/admin/src/components/table/table-cells/seller/seller-status-cell/seller-status-cell.tsx
@@ -0,0 +1,20 @@
+import { useTranslation } from "react-i18next"
+
+import { StatusCell } from "../../common/status-cell"
+import { SellerStatus } from "@mercurjs/types"
+
+type SellerStatusCellProps = {
+ status: SellerStatus
+}
+
+export const SellerStatusCell = ({ status }: SellerStatusCellProps) => {
+ const { t } = useTranslation()
+
+ const [color, text] = {
+ [SellerStatus.PENDING]: ["orange", t("sellers.status.pending")],
+ [SellerStatus.ACTIVE]: ["green", t("sellers.status.active")],
+ [SellerStatus.SUSPENDED]: ["red", t("sellers.status.suspended")],
+ }[status] as ["orange" | "green" | "red", string]
+
+ return <StatusCell color={color}>{text}</StatusCell>
+}
diff --git a/packages/admin/src/hooks/api/api-keys.tsx b/packages/admin/src/hooks/api/api-keys.tsx
index 41027c129..69b25ff22 100644
--- a/packages/admin/src/hooks/api/api-keys.tsx
+++ b/packages/admin/src/hooks/api/api-keys.tsx
@@ -1,5 +1,5 @@
import { HttpTypes } from "@medusajs/types"
-import { FetchError } from "@medusajs/js-sdk"
+import { ClientError } from "@mercurjs/client"
import {
MutationOptions,
QueryKey,
@@ -21,7 +21,7 @@ export const useApiKey = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminApiKeyResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminApiKeyResponse,
QueryKey
>,
@@ -42,7 +42,7 @@ export const useApiKeys = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminGetApiKeysParams,
- FetchError,
+ ClientError,
HttpTypes.AdminApiKeyListResponse,
QueryKey
>,
@@ -61,7 +61,7 @@ export const useApiKeys = (
export const useCreateApiKey = (
options?: UseMutationOptions<
HttpTypes.AdminApiKeyResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminCreateApiKey
>
) => {
@@ -80,7 +80,7 @@ export const useUpdateApiKey = (
id: string,
options?: UseMutationOptions<
HttpTypes.AdminApiKeyResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminUpdateApiKey
>
) => {
@@ -98,7 +98,7 @@ export const useUpdateApiKey = (
export const useRevokeApiKey = (
id: string,
- options?: UseMutationOptions<HttpTypes.AdminApiKeyResponse, FetchError, void>
+ options?: UseMutationOptions<HttpTypes.AdminApiKeyResponse, ClientError, void>
) => {
return useMutation({
mutationFn: () => sdk.admin.apiKey.revoke(id),
@@ -115,7 +115,7 @@ export const useDeleteApiKey = (
id: string,
options?: MutationOptions<
HttpTypes.AdminApiKeyDeleteResponse,
- FetchError,
+ ClientError,
void
>
) => {
@@ -134,7 +134,7 @@ export const useBatchRemoveSalesChannelsFromApiKey = (
id: string,
options?: UseMutationOptions<
HttpTypes.AdminApiKeyResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminBatchLink["remove"]
>
) => {
@@ -158,7 +158,7 @@ export const useBatchAddSalesChannelsToApiKey = (
id: string,
options?: UseMutationOptions<
HttpTypes.AdminApiKeyResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminBatchLink["add"]
>
) => {
diff --git a/packages/admin/src/hooks/api/auth.tsx b/packages/admin/src/hooks/api/auth.tsx
index e28d9d6ae..bf9f13ce2 100644
--- a/packages/admin/src/hooks/api/auth.tsx
+++ b/packages/admin/src/hooks/api/auth.tsx
@@ -1,4 +1,4 @@
-import { FetchError } from "@medusajs/js-sdk"
+import { ClientError } from "@mercurjs/client"
import { HttpTypes } from "@medusajs/types"
import { UseMutationOptions, useMutation } from "@tanstack/react-query"
import { sdk } from "../../lib/client"
@@ -9,7 +9,7 @@ export const useSignInWithEmailPass = (
| {
location: string
},
- FetchError,
+ ClientError,
HttpTypes.AdminSignUpWithEmailPassword
>
) => {
@@ -25,7 +25,7 @@ export const useSignInWithEmailPass = (
export const useSignUpWithEmailPass = (
options?: UseMutationOptions<
string,
- FetchError,
+ ClientError,
HttpTypes.AdminSignInWithEmailPassword
>
) => {
@@ -39,7 +39,7 @@ export const useSignUpWithEmailPass = (
}
export const useResetPasswordForEmailPass = (
- options?: UseMutationOptions<void, FetchError, { email: string }>
+ options?: UseMutationOptions<void, ClientError, { email: string }>
) => {
return useMutation({
mutationFn: (payload) =>
@@ -53,7 +53,7 @@ export const useResetPasswordForEmailPass = (
})
}
-export const useLogout = (options?: UseMutationOptions<void, FetchError>) => {
+export const useLogout = (options?: UseMutationOptions<void, ClientError>) => {
return useMutation({
mutationFn: () => sdk.auth.logout(),
...options,
@@ -62,7 +62,7 @@ export const useLogout = (options?: UseMutationOptions<void, FetchError>) => {
export const useUpdateProviderForEmailPass = (
token: string,
- options?: UseMutationOptions<void, FetchError, HttpTypes.AdminUpdateProvider>
+ options?: UseMutationOptions<void, ClientError, HttpTypes.AdminUpdateProvider>
) => {
return useMutation({
mutationFn: (payload) =>
diff --git a/packages/admin/src/hooks/api/campaigns.tsx b/packages/admin/src/hooks/api/campaigns.tsx
index 6d5f5824a..d7e362f04 100644
--- a/packages/admin/src/hooks/api/campaigns.tsx
+++ b/packages/admin/src/hooks/api/campaigns.tsx
@@ -1,4 +1,4 @@
-import { FetchError } from "@medusajs/js-sdk"
+import { ClientError } from "@mercurjs/client"
import { HttpTypes, LinkMethodRequest } from "@medusajs/types"
import {
QueryKey,
@@ -21,7 +21,7 @@ export const useCampaign = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminCampaignResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminCampaignResponse,
QueryKey
>,
@@ -42,7 +42,7 @@ export const useCampaigns = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminCampaignListResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminCampaignListResponse,
QueryKey
>,
@@ -61,7 +61,7 @@ export const useCampaigns = (
export const useCreateCampaign = (
options?: UseMutationOptions<
HttpTypes.AdminCampaignResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminCreateCampaign
>
) => {
@@ -79,7 +79,7 @@ export const useUpdateCampaign = (
id: string,
options?: UseMutationOptions<
HttpTypes.AdminCampaignResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminUpdateCampaign
>
) => {
@@ -101,7 +101,7 @@ export const useDeleteCampaign = (
id: string,
options?: UseMutationOptions<
HttpTypes.DeleteResponse<"campaign">,
- FetchError,
+ ClientError,
void
>
) => {
@@ -121,7 +121,7 @@ export const useAddOrRemoveCampaignPromotions = (
id: string,
options?: UseMutationOptions<
HttpTypes.AdminCampaignResponse,
- FetchError,
+ ClientError,
LinkMethodRequest
>
) => {
diff --git a/packages/admin/src/hooks/api/categories.tsx b/packages/admin/src/hooks/api/categories.tsx
index 1d34c4790..b1b7bec9e 100644
--- a/packages/admin/src/hooks/api/categories.tsx
+++ b/packages/admin/src/hooks/api/categories.tsx
@@ -1,4 +1,4 @@
-import { FetchError } from "@medusajs/js-sdk"
+import { ClientError } from "@mercurjs/client"
import { HttpTypes } from "@medusajs/types"
import {
QueryKey,
@@ -21,7 +21,7 @@ export const useProductCategory = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminProductCategoryResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminProductCategoryResponse,
QueryKey
>,
@@ -42,7 +42,7 @@ export const useProductCategories = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminProductCategoryListResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminProductCategoryListResponse,
QueryKey
>,
@@ -61,7 +61,7 @@ export const useProductCategories = (
export const useCreateProductCategory = (
options?: UseMutationOptions<
HttpTypes.AdminProductCategoryResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminCreateProductCategory
>
) => {
@@ -80,7 +80,7 @@ export const useUpdateProductCategory = (
id: string,
options?: UseMutationOptions<
HttpTypes.AdminProductCategoryResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminUpdateProductCategory
>
) => {
@@ -102,7 +102,7 @@ export const useDeleteProductCategory = (
id: string,
options?: UseMutationOptions<
HttpTypes.AdminProductCategoryDeleteResponse,
- FetchError,
+ ClientError,
void
>
) => {
@@ -124,7 +124,7 @@ export const useUpdateProductCategoryProducts = (
id: string,
options?: UseMutationOptions<
HttpTypes.AdminProductCategoryResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminUpdateProductCategoryProducts
>
) => {
diff --git a/packages/admin/src/hooks/api/claims.tsx b/packages/admin/src/hooks/api/claims.tsx
index 4fb5bbebc..45729e63e 100644
--- a/packages/admin/src/hooks/api/claims.tsx
+++ b/packages/admin/src/hooks/api/claims.tsx
@@ -1,4 +1,4 @@
-import { FetchError } from "@medusajs/js-sdk"
+import { ClientError } from "@mercurjs/client"
import { HttpTypes } from "@medusajs/types"
import {
QueryKey,
@@ -23,7 +23,7 @@ export const useClaim = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminClaimResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminClaimResponse,
QueryKey
>,
@@ -44,7 +44,7 @@ export const useClaims = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminClaimListParams,
- FetchError,
+ ClientError,
HttpTypes.AdminClaimListResponse,
QueryKey
>,
@@ -64,7 +64,7 @@ export const useCreateClaim = (
orderId: string,
options?: UseMutationOptions<
HttpTypes.AdminClaimResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminCreateClaim
>
) => {
@@ -93,7 +93,7 @@ export const useCreateClaim = (
export const useCancelClaim = (
id: string,
orderId: string,
- options?: UseMutationOptions<HttpTypes.AdminClaimResponse, FetchError>
+ options?: UseMutationOptions<HttpTypes.AdminClaimResponse, ClientError>
) => {
return useMutation({
mutationFn: () => sdk.admin.claim.cancel(id),
@@ -124,7 +124,7 @@ export const useAddClaimItems = (
orderId: string,
options?: UseMutationOptions<
HttpTypes.AdminClaimResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminAddClaimItems
>
) => {
@@ -151,7 +151,7 @@ export const useUpdateClaimItems = (
orderId: string,
options?: UseMutationOptions<
HttpTypes.AdminClaimResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminUpdateClaimItem & { actionId: string }
>
) => {
@@ -182,7 +182,7 @@ export const useRemoveClaimItem = (
orderId: string,
options?: UseMutationOptions<
HttpTypes.AdminReturnResponse,
- FetchError,
+ ClientError,
string
>
) => {
@@ -209,7 +209,7 @@ export const useAddClaimInboundItems = (
orderId: string,
options?: UseMutationOptions<
HttpTypes.AdminClaimReturnPreviewResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminAddClaimInboundItems
>
) => {
@@ -235,7 +235,7 @@ export const useUpdateClaimInboundItem = (
orderId: string,
options?: UseMutationOptions<
HttpTypes.AdminClaimResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminUpdateClaimInboundItem & { actionId: string }
>
) => {
@@ -264,7 +264,7 @@ export const useUpdateClaimInboundItem = (
export const useRemoveClaimInboundItem = (
id: string,
orderId: string,
- options?: UseMutationOptions<HttpTypes.AdminClaimResponse, FetchError, string>
+ options?: UseMutationOptions<HttpTypes.AdminClaimResponse, ClientError, string>
) => {
return useMutation({
mutationFn: (actionId: string) =>
@@ -293,7 +293,7 @@ export const useAddClaimInboundShipping = (
orderId: string,
options?: UseMutationOptions<
HttpTypes.AdminClaimResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminClaimAddInboundShipping
>
) => {
@@ -320,7 +320,7 @@ export const useUpdateClaimInboundShipping = (
orderId: string,
options?: UseMutationOptions<
HttpTypes.AdminClaimResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminClaimUpdateInboundShipping
>
) => {
@@ -348,7 +348,7 @@ export const useUpdateClaimInboundShipping = (
export const useDeleteClaimInboundShipping = (
id: string,
orderId: string,
- options?: UseMutationOptions<HttpTypes.AdminClaimResponse, FetchError, string>
+ options?: UseMutationOptions<HttpTypes.AdminClaimResponse, ClientError, string>
) => {
return useMutation({
mutationFn: (actionId: string) =>
@@ -373,7 +373,7 @@ export const useAddClaimOutboundItems = (
orderId: string,
options?: UseMutationOptions<
HttpTypes.AdminClaimResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminAddClaimOutboundItems
>
) => {
@@ -400,7 +400,7 @@ export const useUpdateClaimOutboundItems = (
orderId: string,
options?: UseMutationOptions<
HttpTypes.AdminClaimResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminUpdateClaimOutboundItem & { actionId: string }
>
) => {
@@ -429,7 +429,7 @@ export const useUpdateClaimOutboundItems = (
export const useRemoveClaimOutboundItem = (
id: string,
orderId: string,
- options?: UseMutationOptions<HttpTypes.AdminClaimResponse, FetchError, string>
+ options?: UseMutationOptions<HttpTypes.AdminClaimResponse, ClientError, string>
) => {
return useMutation({
mutationFn: (actionId: string) =>
@@ -454,7 +454,7 @@ export const useAddClaimOutboundShipping = (
orderId: string,
options?: UseMutationOptions<
HttpTypes.AdminClaimResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminClaimAddOutboundShipping
>
) => {
@@ -481,7 +481,7 @@ export const useUpdateClaimOutboundShipping = (
orderId: string,
options?: UseMutationOptions<
HttpTypes.AdminClaimResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminClaimUpdateOutboundShipping
>
) => {
@@ -509,7 +509,7 @@ export const useUpdateClaimOutboundShipping = (
export const useDeleteClaimOutboundShipping = (
id: string,
orderId: string,
- options?: UseMutationOptions<HttpTypes.AdminClaimResponse, FetchError, string>
+ options?: UseMutationOptions<HttpTypes.AdminClaimResponse, ClientError, string>
) => {
return useMutation({
mutationFn: (actionId: string) =>
@@ -534,7 +534,7 @@ export const useClaimConfirmRequest = (
orderId: string,
options?: UseMutationOptions<
HttpTypes.AdminClaimResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminRequestClaim
>
) => {
@@ -567,7 +567,7 @@ export const useClaimConfirmRequest = (
export const useCancelClaimRequest = (
id: string,
orderId: string,
- options?: UseMutationOptions<HttpTypes.AdminClaimResponse, FetchError>
+ options?: UseMutationOptions<HttpTypes.AdminClaimResponse, ClientError>
) => {
return useMutation({
mutationFn: () => sdk.admin.claim.cancelRequest(id),
diff --git a/packages/admin/src/hooks/api/collections.tsx b/packages/admin/src/hooks/api/collections.tsx
index 49e8aee34..18bbb4764 100644
--- a/packages/admin/src/hooks/api/collections.tsx
+++ b/packages/admin/src/hooks/api/collections.tsx
@@ -1,4 +1,4 @@
-import { FetchError } from "@medusajs/js-sdk"
+import { ClientError } from "@mercurjs/client"
import { FindParams, HttpTypes, PaginatedResponse } from "@medusajs/types"
import {
QueryKey,
@@ -20,7 +20,7 @@ export const useCollection = (
options?: Omit<
UseQueryOptions<
{ collection: HttpTypes.AdminCollection },
- FetchError,
+ ClientError,
{ collection: HttpTypes.AdminCollection },
QueryKey
>,
@@ -41,7 +41,7 @@ export const useCollections = (
options?: Omit<
UseQueryOptions<
PaginatedResponse<{ collections: HttpTypes.AdminCollection[] }>,
- FetchError,
+ ClientError,
PaginatedResponse<{ collections: HttpTypes.AdminCollection[] }>,
QueryKey
>,
@@ -61,7 +61,7 @@ export const useUpdateCollection = (
id: string,
options?: UseMutationOptions<
HttpTypes.AdminCollectionResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminUpdateCollection
>
) => {
@@ -83,7 +83,7 @@ export const useUpdateCollectionProducts = (
id: string,
options?: UseMutationOptions<
HttpTypes.AdminCollectionResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminUpdateCollectionProducts
>
) => {
@@ -111,7 +111,7 @@ export const useUpdateCollectionProducts = (
export const useCreateCollection = (
options?: UseMutationOptions<
HttpTypes.AdminCollectionResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminCreateCollection
>
) => {
@@ -130,7 +130,7 @@ export const useDeleteCollection = (
id: string,
options?: UseMutationOptions<
HttpTypes.AdminCollectionDeleteResponse,
- FetchError,
+ ClientError,
void
>
) => {
diff --git a/packages/admin/src/hooks/api/currencies.tsx b/packages/admin/src/hooks/api/currencies.tsx
index 2fb16a06d..f4152ca3c 100644
--- a/packages/admin/src/hooks/api/currencies.tsx
+++ b/packages/admin/src/hooks/api/currencies.tsx
@@ -1,4 +1,4 @@
-import { FetchError } from "@medusajs/js-sdk"
+import { ClientError } from "@mercurjs/client"
import { HttpTypes } from "@medusajs/types"
import { QueryKey, UseQueryOptions, useQuery } from "@tanstack/react-query"
@@ -13,7 +13,7 @@ export const useCurrencies = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminCurrencyListResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminCurrencyListResponse,
QueryKey
>,
@@ -35,7 +35,7 @@ export const useCurrency = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminCurrencyResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminCurrencyResponse,
QueryKey
>,
diff --git a/packages/admin/src/hooks/api/customers.tsx b/packages/admin/src/hooks/api/customers.tsx
index a4b8abf87..b33a027ea 100644
--- a/packages/admin/src/hooks/api/customers.tsx
+++ b/packages/admin/src/hooks/api/customers.tsx
@@ -1,4 +1,4 @@
-import { FetchError } from "@medusajs/js-sdk"
+import { ClientError } from "@mercurjs/client"
import { HttpTypes, PaginatedResponse } from "@medusajs/types"
import {
QueryKey,
@@ -24,7 +24,7 @@ export const useCustomer = (
options?: Omit<
UseQueryOptions<
{ customer: HttpTypes.AdminCustomer },
- FetchError,
+ ClientError,
{ customer: HttpTypes.AdminCustomer },
QueryKey
>,
@@ -45,7 +45,7 @@ export const useCustomers = (
options?: Omit<
UseQueryOptions<
PaginatedResponse<{ customers: HttpTypes.AdminCustomer[] }>,
- FetchError,
+ ClientError,
PaginatedResponse<{ customers: HttpTypes.AdminCustomer[] }>,
QueryKey
>,
@@ -64,7 +64,7 @@ export const useCustomers = (
export const useCreateCustomer = (
options?: UseMutationOptions<
{ customer: HttpTypes.AdminCustomer },
- FetchError,
+ ClientError,
HttpTypes.AdminCreateCustomer
>
) => {
@@ -82,7 +82,7 @@ export const useUpdateCustomer = (
id: string,
options?: UseMutationOptions<
{ customer: HttpTypes.AdminCustomer },
- FetchError,
+ ClientError,
HttpTypes.AdminUpdateCustomer & { email?: string }
>
) => {
@@ -102,7 +102,7 @@ export const useDeleteCustomer = (
id: string,
options?: UseMutationOptions<
HttpTypes.AdminCustomerDeleteResponse,
- FetchError,
+ ClientError,
void
>
) => {
@@ -124,7 +124,7 @@ export const useBatchCustomerCustomerGroups = (
id: string,
options?: UseMutationOptions<
HttpTypes.AdminCustomerResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminBatchLink
>
) => {
@@ -156,7 +156,7 @@ export const useCreateCustomerAddress = (
id: string,
options?: UseMutationOptions<
HttpTypes.AdminCustomerResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminCreateCustomerAddress
>
) => {
@@ -180,7 +180,7 @@ export const useUpdateCustomerAddress = (
addressId: string,
options?: UseMutationOptions<
HttpTypes.AdminCustomerResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminUpdateCustomerAddress
>
) => {
@@ -204,7 +204,7 @@ export const useDeleteCustomerAddress = (
id: string,
options?: UseMutationOptions<
HttpTypes.AdminCustomerResponse,
- FetchError,
+ ClientError,
string
>
) => {
@@ -229,7 +229,7 @@ export const useListCustomerAddresses = (
query?: Record<string, any>,
options?: UseQueryOptions<
HttpTypes.AdminCustomerResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminCustomerResponse,
QueryKey
>
@@ -248,7 +248,7 @@ export const useCustomerAddress = (
addressId: string,
options?: UseQueryOptions<
HttpTypes.AdminCustomerResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminCustomerResponse,
QueryKey
>
diff --git a/packages/admin/src/hooks/api/exchanges.tsx b/packages/admin/src/hooks/api/exchanges.tsx
index f28600f51..d6f57ea46 100644
--- a/packages/admin/src/hooks/api/exchanges.tsx
+++ b/packages/admin/src/hooks/api/exchanges.tsx
@@ -1,4 +1,4 @@
-import { FetchError } from "@medusajs/js-sdk"
+import { ClientError } from "@mercurjs/client"
import { HttpTypes } from "@medusajs/types"
import {
QueryKey,
@@ -22,7 +22,7 @@ export const useExchange = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminExchangeResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminExchangeResponse,
QueryKey
>,
@@ -43,7 +43,7 @@ export const useExchanges = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminExchangeListParams,
- FetchError,
+ ClientError,
HttpTypes.AdminExchangeListResponse,
QueryKey
>,
@@ -63,7 +63,7 @@ export const useCreateExchange = (
orderId: string,
options?: UseMutationOptions<
HttpTypes.AdminExchangeResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminCreateExchange
>
) => {
@@ -92,7 +92,7 @@ export const useCreateExchange = (
export const useCancelExchange = (
id: string,
orderId: string,
- options?: UseMutationOptions<HttpTypes.AdminExchangeResponse, FetchError>
+ options?: UseMutationOptions<HttpTypes.AdminExchangeResponse, ClientError>
) => {
return useMutation({
mutationFn: () => sdk.admin.exchange.cancel(id),
@@ -123,7 +123,7 @@ export const useAddExchangeInboundItems = (
orderId: string,
options?: UseMutationOptions<
HttpTypes.AdminExchangeResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminAddExchangeInboundItems
>
) => {
@@ -145,7 +145,7 @@ export const useUpdateExchangeInboundItem = (
orderId: string,
options?: UseMutationOptions<
HttpTypes.AdminExchangeResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminUpdateExchangeInboundItem & { actionId: string }
>
) => {
@@ -171,7 +171,7 @@ export const useRemoveExchangeInboundItem = (
orderId: string,
options?: UseMutationOptions<
HttpTypes.AdminExchangeResponse,
- FetchError,
+ ClientError,
string
>
) => {
@@ -202,7 +202,7 @@ export const useAddExchangeInboundShipping = (
orderId: string,
options?: UseMutationOptions<
HttpTypes.AdminExchangeResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminExchangeAddInboundShipping
>
) => {
@@ -224,7 +224,7 @@ export const useUpdateExchangeInboundShipping = (
orderId: string,
options?: UseMutationOptions<
HttpTypes.AdminExchangeResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminExchangeUpdateInboundShipping
>
) => {
@@ -249,7 +249,7 @@ export const useDeleteExchangeInboundShipping = (
orderId: string,
options?: UseMutationOptions<
HttpTypes.AdminExchangeResponse,
- FetchError,
+ ClientError,
string
>
) => {
@@ -272,7 +272,7 @@ export const useAddExchangeOutboundItems = (
orderId: string,
options?: UseMutationOptions<
HttpTypes.AdminExchangeResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminAddExchangeOutboundItems
>
) => {
@@ -294,7 +294,7 @@ export const useUpdateExchangeOutboundItems = (
orderId: string,
options?: UseMutationOptions<
HttpTypes.AdminExchangeResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminUpdateExchangeOutboundItem & { actionId: string }
>
) => {
@@ -320,7 +320,7 @@ export const useRemoveExchangeOutboundItem = (
orderId: string,
options?: UseMutationOptions<
HttpTypes.AdminExchangeResponse,
- FetchError,
+ ClientError,
string
>
) => {
@@ -347,7 +347,7 @@ export const useAddExchangeOutboundShipping = (
orderId: string,
options?: UseMutationOptions<
HttpTypes.AdminExchangeResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminExchangeAddOutboundShipping
>
) => {
@@ -369,7 +369,7 @@ export const useUpdateExchangeOutboundShipping = (
orderId: string,
options?: UseMutationOptions<
HttpTypes.AdminExchangeResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminExchangeUpdateOutboundShipping
>
) => {
@@ -394,7 +394,7 @@ export const useDeleteExchangeOutboundShipping = (
orderId: string,
options?: UseMutationOptions<
HttpTypes.AdminExchangeResponse,
- FetchError,
+ ClientError,
string
>
) => {
@@ -416,7 +416,7 @@ export const useExchangeConfirmRequest = (
orderId: string,
options?: UseMutationOptions<
HttpTypes.AdminExchangeResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminRequestExchange
>
) => {
@@ -449,7 +449,7 @@ export const useExchangeConfirmRequest = (
export const useCancelExchangeRequest = (
id: string,
orderId: string,
- options?: UseMutationOptions<HttpTypes.AdminExchangeResponse, FetchError>
+ options?: UseMutationOptions<HttpTypes.AdminExchangeResponse, ClientError>
) => {
return useMutation({
mutationFn: () => sdk.admin.exchange.cancelRequest(id),
diff --git a/packages/admin/src/hooks/api/fulfillment-providers.tsx b/packages/admin/src/hooks/api/fulfillment-providers.tsx
index caa406440..fe78f3e9a 100644
--- a/packages/admin/src/hooks/api/fulfillment-providers.tsx
+++ b/packages/admin/src/hooks/api/fulfillment-providers.tsx
@@ -1,4 +1,4 @@
-import type { FetchError } from "@medusajs/js-sdk"
+import type { ClientError } from "@mercurjs/client"
import type { HttpTypes } from "@medusajs/types"
import { type QueryKey, useQuery, type UseQueryOptions } from "@tanstack/react-query"
import type { ExtendedAdminFulfillmentProviderOptionsListResponse } from "@custom-types/fulfillment-providers/common"
@@ -21,7 +21,7 @@ export const useFulfillmentProviders = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminFulfillmentProviderListResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminFulfillmentProviderListResponse,
QueryKey
>,
@@ -42,7 +42,7 @@ export const useFulfillmentProviderOptions = (
options?: Omit<
UseQueryOptions<
ExtendedAdminFulfillmentProviderOptionsListResponse,
- FetchError,
+ ClientError,
ExtendedAdminFulfillmentProviderOptionsListResponse,
QueryKey
>,
diff --git a/packages/admin/src/hooks/api/fulfillment-sets.tsx b/packages/admin/src/hooks/api/fulfillment-sets.tsx
index bc32eac65..23488c836 100644
--- a/packages/admin/src/hooks/api/fulfillment-sets.tsx
+++ b/packages/admin/src/hooks/api/fulfillment-sets.tsx
@@ -1,4 +1,4 @@
-import { FetchError } from "@medusajs/js-sdk"
+import { ClientError } from "@mercurjs/client"
import { HttpTypes } from "@medusajs/types"
import {
QueryKey,
@@ -23,7 +23,7 @@ export const useDeleteFulfillmentSet = (
options?: Omit<
UseMutationOptions<
HttpTypes.AdminFulfillmentSetDeleteResponse,
- FetchError,
+ ClientError,
void
>,
"mutationFn"
@@ -60,7 +60,7 @@ export const useFulfillmentSetServiceZone = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminServiceZoneResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminServiceZoneResponse,
QueryKey
>,
@@ -86,7 +86,7 @@ export const useCreateFulfillmentSetServiceZone = (
options?: Omit<
UseMutationOptions<
HttpTypes.AdminFulfillmentSetResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminCreateFulfillmentSetServiceZone,
QueryKey
>,
@@ -116,7 +116,7 @@ export const useUpdateFulfillmentSetServiceZone = (
options?: Omit<
UseMutationOptions<
HttpTypes.AdminFulfillmentSetResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminUpdateFulfillmentSetServiceZone,
QueryKey
>,
@@ -150,7 +150,7 @@ export const useDeleteFulfillmentServiceZone = (
options?: Omit<
UseMutationOptions<
HttpTypes.AdminServiceZoneDeleteResponse,
- FetchError,
+ ClientError,
void
>,
"mutationFn"
diff --git a/packages/admin/src/hooks/api/fulfillment.tsx b/packages/admin/src/hooks/api/fulfillment.tsx
index e255351cb..33829d806 100644
--- a/packages/admin/src/hooks/api/fulfillment.tsx
+++ b/packages/admin/src/hooks/api/fulfillment.tsx
@@ -6,13 +6,13 @@ import { HttpTypes } from "@medusajs/types"
import { sdk } from "../../lib/client"
import { queryClient } from "../../lib/query-client"
import { ordersQueryKeys } from "./orders"
-import { FetchError } from "@medusajs/js-sdk"
+import { ClientError } from "@mercurjs/client"
const FULFILLMENTS_QUERY_KEY = "fulfillments" as const
export const fulfillmentsQueryKeys = queryKeysFactory(FULFILLMENTS_QUERY_KEY)
export const useCreateFulfillment = (
- options?: UseMutationOptions<any, FetchError, any>
+ options?: UseMutationOptions<any, ClientError, any>
) => {
return useMutation({
mutationFn: (payload: any) => sdk.admin.fulfillment.create(payload),
@@ -29,7 +29,7 @@ export const useCreateFulfillment = (
export const useCancelFulfillment = (
id: string,
- options?: UseMutationOptions<any, FetchError, any>
+ options?: UseMutationOptions<any, ClientError, any>
) => {
return useMutation({
mutationFn: () => sdk.admin.fulfillment.cancel(id),
@@ -48,7 +48,7 @@ export const useCreateFulfillmentShipment = (
fulfillmentId: string,
options?: UseMutationOptions<
{ fulfillment: HttpTypes.AdminFulfillment },
- FetchError,
+ ClientError,
HttpTypes.AdminCreateFulfillmentShipment
>
) => {
diff --git a/packages/admin/src/hooks/api/index.ts b/packages/admin/src/hooks/api/index.ts
index f88b0cad2..2b84038c2 100644
--- a/packages/admin/src/hooks/api/index.ts
+++ b/packages/admin/src/hooks/api/index.ts
@@ -25,6 +25,7 @@ export * from "./refund-reasons";
export * from "./regions";
export * from "./reservations";
export * from "./sales-channels";
+export * from "./sellers";
export * from "./shipping-options";
export * from "./shipping-option-types";
export * from "./shipping-profiles";
diff --git a/packages/admin/src/hooks/api/inventory.tsx b/packages/admin/src/hooks/api/inventory.tsx
index 3ba885311..26c620bcc 100644
--- a/packages/admin/src/hooks/api/inventory.tsx
+++ b/packages/admin/src/hooks/api/inventory.tsx
@@ -1,4 +1,4 @@
-import type { FetchError } from "@medusajs/js-sdk"
+import type { ClientError } from "@mercurjs/client"
import type { HttpTypes } from "@medusajs/types"
import {
type QueryKey,
@@ -29,7 +29,7 @@ export const useInventoryItems = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminInventoryItemListResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminInventoryItemListResponse,
QueryKey
>,
@@ -51,7 +51,7 @@ export const useInventoryItem = (
options?: Omit<
UseQueryOptions<
ExtendedAdminInventoryItemResponse,
- FetchError,
+ ClientError,
ExtendedAdminInventoryItemResponse,
QueryKey
>,
@@ -70,7 +70,7 @@ export const useInventoryItem = (
export const useCreateInventoryItem = (
options?: UseMutationOptions<
HttpTypes.AdminInventoryItemResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminCreateInventoryItem
>
) => {
@@ -91,7 +91,7 @@ export const useUpdateInventoryItem = (
id: string,
options?: UseMutationOptions<
HttpTypes.AdminInventoryItemResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminUpdateInventoryItem
>
) => {
@@ -115,7 +115,7 @@ export const useDeleteInventoryItem = (
id: string,
options?: UseMutationOptions<
HttpTypes.AdminInventoryItemDeleteResponse,
- FetchError,
+ ClientError,
void
>
) => {
@@ -139,7 +139,7 @@ export const useDeleteInventoryItemLevel = (
locationId: string,
options?: UseMutationOptions<
HttpTypes.AdminInventoryLevelDeleteResponse,
- FetchError,
+ ClientError,
void
>
) => {
@@ -168,7 +168,7 @@ export const useInventoryItemLevels = (
options?: Omit<
UseQueryOptions<
ExtendedInventoryItemLevelsResponse,
- FetchError,
+ ClientError,
ExtendedInventoryItemLevelsResponse,
QueryKey
>,
@@ -192,7 +192,7 @@ export const useUpdateInventoryLevel = (
locationId: string,
options?: UseMutationOptions<
HttpTypes.AdminInventoryItemResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminUpdateInventoryLevel
>
) => {
@@ -225,7 +225,7 @@ export const useBatchInventoryItemLocationLevels = (
inventoryItemId: string,
options?: UseMutationOptions<
HttpTypes.AdminBatchInventoryItemLocationLevelsResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminBatchInventoryItemLocationLevels
>
) => {
@@ -262,7 +262,7 @@ export const useBatchInventoryItemLocationLevels = (
export const useBatchInventoryItemsLocationLevels = (
options?: UseMutationOptions<
HttpTypes.AdminBatchInventoryItemsLocationLevelsResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminBatchInventoryItemsLocationLevels
>
) => {
diff --git a/packages/admin/src/hooks/api/invites.tsx b/packages/admin/src/hooks/api/invites.tsx
index 3edfd86eb..b2689de44 100644
--- a/packages/admin/src/hooks/api/invites.tsx
+++ b/packages/admin/src/hooks/api/invites.tsx
@@ -1,4 +1,4 @@
-import { FetchError } from "@medusajs/js-sdk"
+import { ClientError } from "@mercurjs/client"
import { HttpTypes } from "@medusajs/types"
import {
QueryKey,
@@ -19,7 +19,7 @@ export const useInvite = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminInviteResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminInviteResponse,
QueryKey
>,
@@ -40,7 +40,7 @@ export const useInvites = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminInviteListResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminInviteListResponse,
QueryKey
>,
@@ -59,7 +59,7 @@ export const useInvites = (
export const useCreateInvite = (
options?: UseMutationOptions<
HttpTypes.AdminInviteResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminCreateInvite
>
) => {
@@ -75,7 +75,7 @@ export const useCreateInvite = (
export const useResendInvite = (
id: string,
- options?: UseMutationOptions<HttpTypes.AdminInviteResponse, FetchError, void>
+ options?: UseMutationOptions<HttpTypes.AdminInviteResponse, ClientError, void>
) => {
return useMutation({
mutationFn: () => sdk.admin.invite.resend(id),
@@ -92,7 +92,7 @@ export const useDeleteInvite = (
id: string,
options?: UseMutationOptions<
HttpTypes.AdminInviteDeleteResponse,
- FetchError,
+ ClientError,
void
>
) => {
@@ -111,7 +111,7 @@ export const useAcceptInvite = (
inviteToken: string,
options?: UseMutationOptions<
HttpTypes.AdminAcceptInviteResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminAcceptInvite & { auth_token: string }
>
) => {
diff --git a/packages/admin/src/hooks/api/notification.tsx b/packages/admin/src/hooks/api/notification.tsx
index 481faf5af..ccb54fb92 100644
--- a/packages/admin/src/hooks/api/notification.tsx
+++ b/packages/admin/src/hooks/api/notification.tsx
@@ -3,7 +3,7 @@ import { QueryKey, UseQueryOptions, useQuery } from "@tanstack/react-query"
import { HttpTypes } from "@medusajs/types"
import { sdk } from "../../lib/client"
import { queryKeysFactory } from "../../lib/query-key-factory"
-import { FetchError } from "@medusajs/js-sdk"
+import { ClientError } from "@mercurjs/client"
const NOTIFICATION_QUERY_KEY = "notification" as const
export const notificationQueryKeys = queryKeysFactory(NOTIFICATION_QUERY_KEY)
@@ -14,7 +14,7 @@ export const useNotification = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminNotificationResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminNotificationResponse,
QueryKey
>,
@@ -35,7 +35,7 @@ export const useNotifications = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminNotificationListResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminNotificationListResponse,
QueryKey
>,
diff --git a/packages/admin/src/hooks/api/order-edits.tsx b/packages/admin/src/hooks/api/order-edits.tsx
index 144a0bde4..5345882a2 100644
--- a/packages/admin/src/hooks/api/order-edits.tsx
+++ b/packages/admin/src/hooks/api/order-edits.tsx
@@ -5,7 +5,7 @@ import { HttpTypes } from "@medusajs/types"
import { sdk } from "../../lib/client"
import { queryClient } from "../../lib/query-client"
import { ordersQueryKeys } from "./orders"
-import { FetchError } from "@medusajs/js-sdk"
+import { ClientError } from "@mercurjs/client"
import { reservationItemsQueryKeys } from "./reservations"
import { inventoryItemsQueryKeys } from "./inventory.tsx"
@@ -13,7 +13,7 @@ export const useCreateOrderEdit = (
orderId: string,
options?: UseMutationOptions<
HttpTypes.AdminOrderEditPreviewResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminInitiateOrderEditRequest
>
) => {
@@ -38,7 +38,7 @@ export const useRequestOrderEdit = (
id: string,
options?: UseMutationOptions<
HttpTypes.AdminOrderEditPreviewResponse,
- FetchError,
+ ClientError,
void
>
) => {
@@ -70,7 +70,7 @@ export const useConfirmOrderEdit = (
id: string,
options?: UseMutationOptions<
HttpTypes.AdminOrderEditPreviewResponse,
- FetchError,
+ ClientError,
void
>
) => {
@@ -113,7 +113,7 @@ export const useConfirmOrderEdit = (
export const useCancelOrderEdit = (
orderId: string,
- options?: UseMutationOptions<any, FetchError, any>
+ options?: UseMutationOptions<any, ClientError, any>
) => {
return useMutation({
mutationFn: () => sdk.admin.orderEdit.cancelRequest(orderId),
@@ -143,7 +143,7 @@ export const useAddOrderEditItems = (
id: string,
options?: UseMutationOptions<
HttpTypes.AdminOrderEditPreviewResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminAddOrderEditItems
>
) => {
@@ -167,7 +167,7 @@ export const useUpdateOrderEditOriginalItem = (
id: string,
options?: UseMutationOptions<
HttpTypes.AdminOrderEditPreviewResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminUpdateOrderEditItem & { itemId: string }
>
) => {
@@ -195,7 +195,7 @@ export const useUpdateOrderEditAddedItem = (
id: string,
options?: UseMutationOptions<
HttpTypes.AdminOrderEditPreviewResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminUpdateOrderEditItem & { actionId: string }
>
) => {
@@ -224,7 +224,7 @@ export const useRemoveOrderEditItem = (
id: string,
options?: UseMutationOptions<
HttpTypes.AdminOrderEditPreviewResponse,
- FetchError,
+ ClientError,
string
>
) => {
diff --git a/packages/admin/src/hooks/api/orders.tsx b/packages/admin/src/hooks/api/orders.tsx
index aaa068494..46f60d454 100644
--- a/packages/admin/src/hooks/api/orders.tsx
+++ b/packages/admin/src/hooks/api/orders.tsx
@@ -1,4 +1,4 @@
-import { FetchError } from "@medusajs/js-sdk"
+import { ClientError } from "@mercurjs/client"
import { CreateOrderCreditLineDTO, HttpTypes } from "@medusajs/types"
import {
QueryKey,
@@ -43,7 +43,7 @@ export const useOrder = (
id: string,
query?: Record<string, any>,
options?: Omit<
- UseQueryOptions<any, FetchError, any, QueryKey>,
+ UseQueryOptions<any, ClientError, any, QueryKey>,
"queryFn" | "queryKey"
>
) => {
@@ -60,7 +60,7 @@ export const useUpdateOrder = (
id: string,
options?: UseMutationOptions<
HttpTypes.AdminOrderResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminUpdateOrder
>
) => {
@@ -93,7 +93,7 @@ export const useOrderPreview = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminOrderPreviewResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminOrderPreviewResponse,
QueryKey
>,
@@ -114,7 +114,7 @@ export const useOrders = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminOrderListResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminOrderListResponse,
QueryKey
>,
@@ -136,7 +136,7 @@ export const useOrderShippingOptions = (
options?: Omit<
UseQueryOptions<
{ shipping_options: HttpTypes.AdminShippingOption[] },
- FetchError,
+ ClientError,
{ shipping_options: HttpTypes.AdminShippingOption[] },
QueryKey
>,
@@ -158,7 +158,7 @@ export const useOrderChanges = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminOrderChangesResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminOrderChangesResponse,
QueryKey
>,
@@ -180,7 +180,7 @@ export const useOrderLineItems = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminOrderLineItemsListResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminOrderLineItemsListResponse,
QueryKey
>,
@@ -200,7 +200,7 @@ export const useCreateOrderFulfillment = (
orderId: string,
options?: UseMutationOptions<
HttpTypes.AdminOrderResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminCreateOrderFulfillment
>
) => {
@@ -233,7 +233,7 @@ export const useCreateOrderFulfillment = (
export const useCancelOrderFulfillment = (
orderId: string,
fulfillmentId: string,
- options?: UseMutationOptions<any, FetchError, any>
+ options?: UseMutationOptions<any, ClientError, any>
) => {
return useMutation({
mutationFn: (payload: { no_notification?: boolean }) =>
@@ -266,7 +266,7 @@ export const useCreateOrderShipment = (
fulfillmentId: string,
options?: UseMutationOptions<
{ order: HttpTypes.AdminOrder },
- FetchError,
+ ClientError,
HttpTypes.AdminCreateOrderShipment
>
) => {
@@ -293,7 +293,7 @@ export const useMarkOrderFulfillmentAsDelivered = (
fulfillmentId: string,
options?: UseMutationOptions<
{ order: HttpTypes.AdminOrder },
- FetchError,
+ ClientError,
void
>
) => {
@@ -316,7 +316,7 @@ export const useMarkOrderFulfillmentAsDelivered = (
export const useCancelOrder = (
orderId: string,
- options?: UseMutationOptions<HttpTypes.AdminOrderResponse, FetchError, void>
+ options?: UseMutationOptions<HttpTypes.AdminOrderResponse, ClientError, void>
) => {
return useMutation({
mutationFn: () => sdk.admin.order.cancel(orderId),
@@ -339,7 +339,7 @@ export const useRequestTransferOrder = (
orderId: string,
options?: UseMutationOptions<
HttpTypes.AdminOrderResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminRequestOrderTransfer
>
) => {
@@ -363,7 +363,7 @@ export const useRequestTransferOrder = (
export const useCancelOrderTransfer = (
orderId: string,
- options?: UseMutationOptions<any, FetchError, void>
+ options?: UseMutationOptions<any, ClientError, void>
) => {
return useMutation({
mutationFn: () => sdk.admin.order.cancelTransfer(orderId),
@@ -386,7 +386,7 @@ export const useCreateOrderCreditLine = (
orderId: string,
options?: UseMutationOptions<
HttpTypes.AdminOrderResponse,
- FetchError,
+ ClientError,
Omit<CreateOrderCreditLineDTO, "order_id">
>
) => {
diff --git a/packages/admin/src/hooks/api/payment-collections.tsx b/packages/admin/src/hooks/api/payment-collections.tsx
index 21c3746a6..72c0e00da 100644
--- a/packages/admin/src/hooks/api/payment-collections.tsx
+++ b/packages/admin/src/hooks/api/payment-collections.tsx
@@ -1,4 +1,4 @@
-import { FetchError } from "@medusajs/js-sdk"
+import { ClientError } from "@mercurjs/client"
import { HttpTypes } from "@medusajs/types"
import { useMutation, UseMutationOptions } from "@tanstack/react-query"
import { sdk } from "../../lib/client"
@@ -15,7 +15,7 @@ export const useCreatePaymentCollection = (
orderId: string,
options?: UseMutationOptions<
HttpTypes.AdminPaymentCollectionResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminCreatePaymentCollection
>
) => {
@@ -45,7 +45,7 @@ export const useMarkPaymentCollectionAsPaid = (
paymentCollectionId: string,
options?: UseMutationOptions<
HttpTypes.AdminPaymentCollectionResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminMarkPaymentCollectionAsPaid
>
) => {
@@ -76,7 +76,7 @@ export const useDeletePaymentCollection = (
options?: Omit<
UseMutationOptions<
HttpTypes.AdminDeletePaymentCollectionResponse,
- FetchError,
+ ClientError,
string
>,
"mutationFn"
diff --git a/packages/admin/src/hooks/api/payments.tsx b/packages/admin/src/hooks/api/payments.tsx
index b6f953301..0be3ee8b3 100644
--- a/packages/admin/src/hooks/api/payments.tsx
+++ b/packages/admin/src/hooks/api/payments.tsx
@@ -10,7 +10,7 @@ import { sdk } from "../../lib/client"
import { queryClient } from "../../lib/query-client"
import { queryKeysFactory } from "../../lib/query-key-factory"
import { ordersQueryKeys } from "./orders"
-import { FetchError } from "@medusajs/js-sdk"
+import { ClientError } from "@mercurjs/client"
const PAYMENT_QUERY_KEY = "payment" as const
export const paymentQueryKeys = queryKeysFactory(PAYMENT_QUERY_KEY)
@@ -25,7 +25,7 @@ export const usePaymentProviders = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminGetPaymentProvidersParams,
- FetchError,
+ ClientError,
HttpTypes.AdminPaymentProviderListResponse,
QueryKey
>,
@@ -47,7 +47,7 @@ export const usePayment = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminPaymentResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminPaymentResponse,
QueryKey
>,
@@ -68,7 +68,7 @@ export const useCapturePayment = (
paymentId: string,
options?: UseMutationOptions<
HttpTypes.AdminPaymentResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminCapturePayment
>
) => {
@@ -94,7 +94,7 @@ export const useRefundPayment = (
paymentId: string,
options?: UseMutationOptions<
HttpTypes.AdminPaymentResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminRefundPayment
>
) => {
diff --git a/packages/admin/src/hooks/api/price-lists.tsx b/packages/admin/src/hooks/api/price-lists.tsx
index 1a4e2ac4f..950f28ca1 100644
--- a/packages/admin/src/hooks/api/price-lists.tsx
+++ b/packages/admin/src/hooks/api/price-lists.tsx
@@ -1,4 +1,4 @@
-import { FetchError } from "@medusajs/js-sdk"
+import { ClientError } from "@mercurjs/client"
import { HttpTypes } from "@medusajs/types"
import {
QueryKey,
@@ -22,7 +22,7 @@ export const usePriceList = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminPriceListResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminPriceListResponse,
QueryKey
>,
@@ -43,7 +43,7 @@ export const usePriceLists = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminPriceListListResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminPriceListListResponse,
QueryKey
>,
@@ -63,7 +63,7 @@ export const useCreatePriceList = (
query?: HttpTypes.AdminPriceListParams,
options?: UseMutationOptions<
HttpTypes.AdminPriceListResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminCreatePriceList
>
) => {
@@ -85,7 +85,7 @@ export const useUpdatePriceList = (
query?: HttpTypes.AdminPriceListParams,
options?: UseMutationOptions<
HttpTypes.AdminPriceListResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminUpdatePriceList
>
) => {
@@ -109,7 +109,7 @@ export const useDeletePriceList = (
id: string,
options?: UseMutationOptions<
HttpTypes.AdminPriceListDeleteResponse,
- FetchError,
+ ClientError,
void
>
) => {
@@ -129,7 +129,7 @@ export const useBatchPriceListPrices = (
query?: HttpTypes.AdminPriceListParams,
options?: UseMutationOptions<
HttpTypes.AdminPriceListBatchResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminBatchPriceListPrice
>
) => {
@@ -152,7 +152,7 @@ export const usePriceListLinkProducts = (
id: string,
options?: UseMutationOptions<
HttpTypes.AdminPriceListResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminLinkPriceListProducts
>
) => {
diff --git a/packages/admin/src/hooks/api/price-preferences.tsx b/packages/admin/src/hooks/api/price-preferences.tsx
index 0143ec301..42b71bd7a 100644
--- a/packages/admin/src/hooks/api/price-preferences.tsx
+++ b/packages/admin/src/hooks/api/price-preferences.tsx
@@ -1,4 +1,4 @@
-import { FetchError } from "@medusajs/js-sdk"
+import { ClientError } from "@mercurjs/client"
import { HttpTypes } from "@medusajs/types"
import {
QueryKey,
@@ -22,7 +22,7 @@ export const usePricePreference = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminPricePreferenceResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminPricePreferenceResponse,
QueryKey
>,
@@ -43,7 +43,7 @@ export const usePricePreferences = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminPricePreferenceListResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminPricePreferenceListResponse,
QueryKey
>,
@@ -64,7 +64,7 @@ export const useUpsertPricePreference = (
query?: HttpTypes.AdminPricePreferenceParams,
options?: UseMutationOptions<
HttpTypes.AdminPricePreferenceResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminUpdatePricePreference | HttpTypes.AdminCreatePricePreference
>
) => {
@@ -98,7 +98,7 @@ export const useDeletePricePreference = (
id: string,
options?: UseMutationOptions<
HttpTypes.AdminPricePreferenceDeleteResponse,
- FetchError,
+ ClientError,
void
>
) => {
diff --git a/packages/admin/src/hooks/api/product-types.tsx b/packages/admin/src/hooks/api/product-types.tsx
index fcc4c5adb..6c7672fc4 100644
--- a/packages/admin/src/hooks/api/product-types.tsx
+++ b/packages/admin/src/hooks/api/product-types.tsx
@@ -1,4 +1,4 @@
-import { FetchError } from "@medusajs/js-sdk"
+import { ClientError } from "@mercurjs/client"
import { HttpTypes } from "@medusajs/types"
import {
QueryKey,
@@ -20,7 +20,7 @@ export const useProductType = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminProductTypeResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminProductTypeResponse,
QueryKey
>,
@@ -41,7 +41,7 @@ export const useProductTypes = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminProductTypeListResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminProductTypeListResponse,
QueryKey
>,
@@ -60,7 +60,7 @@ export const useProductTypes = (
export const useCreateProductType = (
options?: UseMutationOptions<
HttpTypes.AdminProductTypeResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminCreateProductType
>
) => {
@@ -79,7 +79,7 @@ export const useUpdateProductType = (
id: string,
options?: UseMutationOptions<
HttpTypes.AdminProductTypeResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminUpdateProductType
>
) => {
@@ -101,7 +101,7 @@ export const useDeleteProductType = (
id: string,
options?: UseMutationOptions<
HttpTypes.AdminProductTypeDeleteResponse,
- FetchError,
+ ClientError,
void
>
) => {
diff --git a/packages/admin/src/hooks/api/product-variants.tsx b/packages/admin/src/hooks/api/product-variants.tsx
index 359bc54db..7ae62a149 100644
--- a/packages/admin/src/hooks/api/product-variants.tsx
+++ b/packages/admin/src/hooks/api/product-variants.tsx
@@ -1,7 +1,7 @@
import { QueryKey, useQuery, UseQueryOptions } from "@tanstack/react-query"
import { sdk } from "../../lib/client"
import { queryKeysFactory } from "../../lib/query-key-factory"
-import { FetchError } from "@medusajs/js-sdk"
+import { ClientError } from "@mercurjs/client"
const PRODUCT_VARIANT_QUERY_KEY = "product_variant" as const
export const productVariantQueryKeys = queryKeysFactory(
@@ -11,7 +11,7 @@ export const productVariantQueryKeys = queryKeysFactory(
export const useVariants = (
query?: Record<string, any>,
options?: Omit<
- UseQueryOptions<any, FetchError, any, QueryKey>,
+ UseQueryOptions<any, ClientError, any, QueryKey>,
"queryFn" | "queryKey"
>
) => {
diff --git a/packages/admin/src/hooks/api/products.tsx b/packages/admin/src/hooks/api/products.tsx
index 2b9c136a9..aa7dee028 100644
--- a/packages/admin/src/hooks/api/products.tsx
+++ b/packages/admin/src/hooks/api/products.tsx
@@ -1,4 +1,4 @@
-import { FetchError } from "@medusajs/js-sdk";
+import { ClientError } from "@mercurjs/client";
import { HttpTypes } from "@medusajs/types";
import {
QueryKey,
@@ -29,7 +29,7 @@ export const optionsQueryKeys = queryKeysFactory(OPTIONS_QUERY_KEY);
export const useCreateProductOption = (
productId: string,
- options?: UseMutationOptions<any, FetchError, any>
+ options?: UseMutationOptions<any, ClientError, any>
) => {
return useMutation({
mutationFn: (payload: HttpTypes.AdminCreateProductOption) =>
@@ -48,7 +48,7 @@ export const useCreateProductOption = (
export const useUpdateProductOption = (
productId: string,
optionId: string,
- options?: UseMutationOptions<any, FetchError, any>
+ options?: UseMutationOptions<any, ClientError, any>
) => {
return useMutation({
mutationFn: (payload: HttpTypes.AdminUpdateProductOption) =>
@@ -71,7 +71,7 @@ export const useUpdateProductOption = (
export const useDeleteProductOption = (
productId: string,
optionId: string,
- options?: UseMutationOptions<any, FetchError, void>
+ options?: UseMutationOptions<any, ClientError, void>
) => {
return useMutation({
mutationFn: () => sdk.admin.product.deleteOption(productId, optionId),
@@ -97,7 +97,7 @@ export const useProductVariant = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminProductVariantResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminProductVariantResponse,
QueryKey
>,
@@ -120,7 +120,7 @@ export const useProductVariants = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminProductVariantListResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminProductVariantListResponse,
QueryKey
>,
@@ -138,7 +138,7 @@ export const useProductVariants = (
export const useCreateProductVariant = (
productId: string,
- options?: UseMutationOptions<any, FetchError, any>
+ options?: UseMutationOptions<any, ClientError, any>
) => {
return useMutation({
mutationFn: (payload: HttpTypes.AdminCreateProductVariant) =>
@@ -157,7 +157,7 @@ export const useCreateProductVariant = (
export const useUpdateProductVariant = (
productId: string,
variantId: string,
- options?: UseMutationOptions<any, FetchError, any>
+ options?: UseMutationOptions<any, ClientError, any>
) => {
return useMutation({
mutationFn: (payload: HttpTypes.AdminUpdateProductVariant) =>
@@ -179,7 +179,7 @@ export const useUpdateProductVariant = (
export const useUpdateProductVariantsBatch = (
productId: string,
- options?: UseMutationOptions<any, FetchError, any>
+ options?: UseMutationOptions<any, ClientError, any>
) => {
return useMutation({
mutationFn: (
@@ -205,7 +205,7 @@ export const useProductVariantsInventoryItemsBatch = (
productId: string,
options?: UseMutationOptions<
HttpTypes.AdminBatchProductVariantInventoryItemResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminBatchProductVariantInventoryItemRequest
>
) => {
@@ -228,7 +228,7 @@ export const useProductVariantsInventoryItemsBatch = (
export const useDeleteVariant = (
productId: string,
variantId: string,
- options?: UseMutationOptions<any, FetchError, void>
+ options?: UseMutationOptions<any, ClientError, void>
) => {
return useMutation({
mutationFn: () => sdk.admin.product.deleteVariant(productId, variantId),
@@ -251,7 +251,7 @@ export const useDeleteVariantLazy = (
productId: string,
options?: UseMutationOptions<
HttpTypes.AdminProductVariantDeleteResponse,
- FetchError,
+ ClientError,
{ variantId: string }
>
) => {
@@ -279,7 +279,7 @@ export const useProduct = (
options?: Omit<
UseQueryOptions<
AdminProductResponse,
- FetchError,
+ ClientError,
AdminProductResponse,
QueryKey
>,
@@ -300,7 +300,7 @@ export const useProducts = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminProductListResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminProductListResponse,
QueryKey
>,
@@ -319,7 +319,7 @@ export const useProducts = (
export const useCreateProduct = (
options?: UseMutationOptions<
HttpTypes.AdminProductResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminCreateProduct
>
) => {
@@ -341,7 +341,7 @@ export const useUpdateProduct = (
id: string,
options?: UseMutationOptions<
AdminProductResponse,
- FetchError,
+ ClientError,
AdminProductUpdate
>
) => {
@@ -365,7 +365,7 @@ export const useDeleteProduct = (
id: string,
options?: UseMutationOptions<
HttpTypes.AdminProductDeleteResponse,
- FetchError,
+ ClientError,
void
>
) => {
@@ -385,7 +385,7 @@ export const useExportProducts = (
query?: HttpTypes.AdminProductListParams,
options?: UseMutationOptions<
HttpTypes.AdminExportProductResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminExportProductRequest
>
) => {
@@ -401,7 +401,7 @@ export const useExportProducts = (
export const useImportProducts = (
options?: UseMutationOptions<
HttpTypes.AdminImportProductResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminImportProductRequest
>
) => {
@@ -415,7 +415,7 @@ export const useImportProducts = (
};
export const useConfirmImportProducts = (
- options?: UseMutationOptions<{}, FetchError, string>
+ options?: UseMutationOptions<{}, ClientError, string>
) => {
return useMutation({
mutationFn: (payload) => sdk.admin.product.confirmImport(payload),
diff --git a/packages/admin/src/hooks/api/promotions.tsx b/packages/admin/src/hooks/api/promotions.tsx
index f5b8abe08..d638656dc 100644
--- a/packages/admin/src/hooks/api/promotions.tsx
+++ b/packages/admin/src/hooks/api/promotions.tsx
@@ -1,5 +1,5 @@
import { HttpTypes } from "@medusajs/types"
-import { FetchError } from "@medusajs/js-sdk"
+import { ClientError } from "@mercurjs/client"
import {
QueryKey,
useMutation,
@@ -43,7 +43,7 @@ export const usePromotion = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminPromotionResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminPromotionResponse,
QueryKey
>,
@@ -66,7 +66,7 @@ export const usePromotionRules = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminGetPromotionRuleParams,
- FetchError,
+ ClientError,
HttpTypes.AdminPromotionRuleListResponse,
QueryKey
>,
@@ -87,7 +87,7 @@ export const usePromotions = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminPromotionListResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminPromotionListResponse,
QueryKey
>,
@@ -110,7 +110,7 @@ export const usePromotionRuleAttributes = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminRuleAttributeOptionsListResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminRuleAttributeOptionsListResponse,
QueryKey
>,
@@ -142,7 +142,7 @@ export const usePromotionRuleValues = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminRuleValueOptionsListResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminRuleValueOptionsListResponse,
QueryKey
>,
@@ -167,7 +167,7 @@ export const useDeletePromotion = (
id: string,
options?: UseMutationOptions<
HttpTypes.DeleteResponse<"promotion">,
- FetchError,
+ ClientError,
void
>
) => {
@@ -188,7 +188,7 @@ export const useDeletePromotion = (
export const useCreatePromotion = (
options?: UseMutationOptions<
HttpTypes.AdminPromotionResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminCreatePromotion
>
) => {
@@ -207,7 +207,7 @@ export const useUpdatePromotion = (
id: string,
options?: UseMutationOptions<
HttpTypes.AdminPromotionResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminUpdatePromotion
>
) => {
@@ -227,7 +227,7 @@ export const usePromotionAddRules = (
ruleType: string,
options?: UseMutationOptions<
HttpTypes.AdminPromotionResponse,
- FetchError,
+ ClientError,
HttpTypes.BatchAddPromotionRulesReq
>
) => {
@@ -248,7 +248,7 @@ export const usePromotionRemoveRules = (
ruleType: string,
options?: UseMutationOptions<
HttpTypes.AdminPromotionResponse,
- FetchError,
+ ClientError,
HttpTypes.BatchRemovePromotionRulesReq
>
) => {
@@ -269,7 +269,7 @@ export const usePromotionUpdateRules = (
ruleType: string,
options?: UseMutationOptions<
HttpTypes.AdminPromotionResponse,
- FetchError,
+ ClientError,
HttpTypes.BatchUpdatePromotionRulesReq
>
) => {
diff --git a/packages/admin/src/hooks/api/refund-reasons.tsx b/packages/admin/src/hooks/api/refund-reasons.tsx
index 146fe4677..c46d188d6 100644
--- a/packages/admin/src/hooks/api/refund-reasons.tsx
+++ b/packages/admin/src/hooks/api/refund-reasons.tsx
@@ -1,4 +1,4 @@
-import { FetchError } from "@medusajs/js-sdk";
+import { ClientError } from "@mercurjs/client";
import type {
AdminRefundReasonDeleteResponse,
HttpTypes,
@@ -33,7 +33,7 @@ export const useRefundReasons = (
options?: Omit<
UseQueryOptions<
AdminRefundReasonListResponse,
- FetchError,
+ ClientError,
AdminRefundReasonListResponse
>,
"queryFn" | "queryKey"
@@ -57,7 +57,7 @@ export const useRefundReason = (
options?: Omit<
UseQueryOptions<
AdminRefundReasonResponse,
- FetchError,
+ ClientError,
AdminRefundReasonResponse
>,
"queryFn" | "queryKey"
@@ -82,7 +82,7 @@ export const useCreateRefundReason = (
query?: AdminRefundReasonParams,
options?: UseMutationOptions<
HttpTypes.RefundReasonResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminCreateRefundReason
>,
) => {
@@ -108,7 +108,7 @@ export const useUpdateRefundReason = (
id: string,
options?: UseMutationOptions<
AdminRefundReasonResponse,
- FetchError,
+ ClientError,
AdminUpdateRefundReason
>,
) => {
@@ -138,7 +138,7 @@ export const useUpdateRefundReason = (
export const useDeleteRefundReasonLazy = (
options?: UseMutationOptions<
HttpTypes.AdminRefundReasonDeleteResponse,
- FetchError,
+ ClientError,
string
>,
) => {
diff --git a/packages/admin/src/hooks/api/regions.tsx b/packages/admin/src/hooks/api/regions.tsx
index 55b68d8bc..36e147a9b 100644
--- a/packages/admin/src/hooks/api/regions.tsx
+++ b/packages/admin/src/hooks/api/regions.tsx
@@ -10,7 +10,7 @@ import { sdk } from "../../lib/client"
import { queryClient } from "../../lib/query-client"
import { queryKeysFactory } from "../../lib/query-key-factory"
import { pricePreferencesQueryKeys } from "./price-preferences"
-import { FetchError } from "@medusajs/js-sdk"
+import { ClientError } from "@mercurjs/client"
const REGIONS_QUERY_KEY = "regions" as const
export const regionsQueryKeys = queryKeysFactory(REGIONS_QUERY_KEY)
@@ -21,7 +21,7 @@ export const useRegion = (
options?: Omit<
UseQueryOptions<
{ region: HttpTypes.AdminRegion },
- FetchError,
+ ClientError,
{ region: HttpTypes.AdminRegion },
QueryKey
>,
@@ -42,7 +42,7 @@ export const useRegions = (
options?: Omit<
UseQueryOptions<
PaginatedResponse<{ regions: HttpTypes.AdminRegion[] }>,
- FetchError,
+ ClientError,
PaginatedResponse<{ regions: HttpTypes.AdminRegion[] }>,
QueryKey
>,
@@ -61,7 +61,7 @@ export const useRegions = (
export const useCreateRegion = (
options?: UseMutationOptions<
{ region: HttpTypes.AdminRegion },
- FetchError,
+ ClientError,
HttpTypes.AdminCreateRegion
>
) => {
@@ -87,7 +87,7 @@ export const useUpdateRegion = (
id: string,
options?: UseMutationOptions<
{ region: HttpTypes.AdminRegion },
- FetchError,
+ ClientError,
HttpTypes.AdminUpdateRegion
>
) => {
@@ -114,7 +114,7 @@ export const useDeleteRegion = (
id: string,
options?: UseMutationOptions<
HttpTypes.AdminRegionDeleteResponse,
- FetchError,
+ ClientError,
void
>
) => {
diff --git a/packages/admin/src/hooks/api/reservations.tsx b/packages/admin/src/hooks/api/reservations.tsx
index 6113ea245..54dc2b422 100644
--- a/packages/admin/src/hooks/api/reservations.tsx
+++ b/packages/admin/src/hooks/api/reservations.tsx
@@ -13,7 +13,7 @@ import {
inventoryItemLevelsQueryKeys,
inventoryItemsQueryKeys,
} from "./inventory.tsx"
-import { FetchError } from "@medusajs/js-sdk"
+import { ClientError } from "@mercurjs/client"
const RESERVATION_ITEMS_QUERY_KEY = "reservation_items" as const
export const reservationItemsQueryKeys = queryKeysFactory(
@@ -26,7 +26,7 @@ export const useReservationItem = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminReservationResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminReservationResponse,
QueryKey
>,
@@ -47,7 +47,7 @@ export const useReservationItems = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminGetReservationsParams,
- FetchError,
+ ClientError,
HttpTypes.AdminReservationListResponse,
QueryKey
>,
@@ -67,7 +67,7 @@ export const useUpdateReservationItem = (
id: string,
options?: UseMutationOptions<
HttpTypes.AdminReservationResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminUpdateReservation
>
) => {
@@ -96,7 +96,7 @@ export const useUpdateReservationItem = (
export const useCreateReservationItem = (
options?: UseMutationOptions<
HttpTypes.AdminReservationResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminCreateReservation
>
) => {
@@ -123,7 +123,7 @@ export const useDeleteReservationItem = (
id: string,
options?: UseMutationOptions<
HttpTypes.AdminReservationDeleteResponse,
- FetchError,
+ ClientError,
void
>
) => {
diff --git a/packages/admin/src/hooks/api/return-reasons.tsx b/packages/admin/src/hooks/api/return-reasons.tsx
index ee67cf9d5..6d74a090f 100644
--- a/packages/admin/src/hooks/api/return-reasons.tsx
+++ b/packages/admin/src/hooks/api/return-reasons.tsx
@@ -7,7 +7,7 @@ import {
useQuery,
} from "@tanstack/react-query"
-import { FetchError } from "@medusajs/js-sdk"
+import { ClientError } from "@mercurjs/client"
import { sdk } from "../../lib/client"
import { queryClient } from "../../lib/query-client"
import { queryKeysFactory } from "../../lib/query-key-factory"
@@ -20,7 +20,7 @@ export const useReturnReasons = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminReturnReasonListResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminReturnReasonListResponse,
QueryKey
>,
@@ -42,7 +42,7 @@ export const useReturnReason = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminReturnReasonResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminReturnReasonResponse,
QueryKey
>,
@@ -62,7 +62,7 @@ export const useCreateReturnReason = (
query?: HttpTypes.AdminReturnReasonParams,
options?: UseMutationOptions<
HttpTypes.AdminReturnReasonResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminCreateReturnReason
>
) => {
@@ -83,7 +83,7 @@ export const useUpdateReturnReason = (
query?: HttpTypes.AdminReturnReasonParams,
options?: UseMutationOptions<
HttpTypes.AdminReturnReasonResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminUpdateReturnReason
>
) => {
@@ -107,7 +107,7 @@ export const useDeleteReturnReason = (
id: string,
options?: UseMutationOptions<
HttpTypes.AdminReturnReasonDeleteResponse,
- FetchError,
+ ClientError,
void
>
) => {
diff --git a/packages/admin/src/hooks/api/returns.tsx b/packages/admin/src/hooks/api/returns.tsx
index e91fd911f..bd469aaff 100644
--- a/packages/admin/src/hooks/api/returns.tsx
+++ b/packages/admin/src/hooks/api/returns.tsx
@@ -7,7 +7,7 @@ import {
UseQueryOptions,
} from "@tanstack/react-query"
-import { FetchError } from "@medusajs/js-sdk"
+import { ClientError } from "@mercurjs/client"
import { sdk } from "../../lib/client"
import { queryClient } from "../../lib/query-client"
import { queryKeysFactory } from "../../lib/query-key-factory"
@@ -20,7 +20,7 @@ export const useReturn = (
id: string,
query?: Record<string, any>,
options?: Omit<
- UseQueryOptions<any, FetchError, any, QueryKey>,
+ UseQueryOptions<any, ClientError, any, QueryKey>,
"queryFn" | "queryKey"
>
) => {
@@ -38,7 +38,7 @@ export const useReturns = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminReturnFilters,
- FetchError,
+ ClientError,
HttpTypes.AdminReturnsResponse,
QueryKey
>,
@@ -58,7 +58,7 @@ export const useInitiateReturn = (
orderId: string,
options?: UseMutationOptions<
HttpTypes.AdminReturnResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminInitiateReturnRequest
>
) => {
@@ -86,7 +86,7 @@ export const useInitiateReturn = (
export const useCancelReturn = (
id: string,
orderId: string,
- options?: UseMutationOptions<HttpTypes.AdminReturnResponse, FetchError>
+ options?: UseMutationOptions<HttpTypes.AdminReturnResponse, ClientError>
) => {
return useMutation({
mutationFn: () => sdk.admin.return.cancel(id),
@@ -121,7 +121,7 @@ export const useConfirmReturnRequest = (
orderId: string,
options?: UseMutationOptions<
HttpTypes.AdminReturnResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminConfirmReturnRequest
>
) => {
@@ -152,7 +152,7 @@ export const useConfirmReturnRequest = (
export const useCancelReturnRequest = (
id: string,
orderId: string,
- options?: UseMutationOptions<HttpTypes.AdminReturnResponse, FetchError>
+ options?: UseMutationOptions<HttpTypes.AdminReturnResponse, ClientError>
) => {
return useMutation({
mutationFn: () => sdk.admin.return.cancelRequest(id),
@@ -185,7 +185,7 @@ export const useAddReturnItem = (
orderId: string,
options?: UseMutationOptions<
HttpTypes.AdminReturnResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminAddReturnItems
>
) => {
@@ -212,7 +212,7 @@ export const useUpdateReturnItem = (
orderId: string,
options?: UseMutationOptions<
HttpTypes.AdminReturnResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminUpdateReturnItems & { actionId: string }
>
) => {
@@ -243,7 +243,7 @@ export const useRemoveReturnItem = (
orderId: string,
options?: UseMutationOptions<
HttpTypes.AdminReturnResponse,
- FetchError,
+ ClientError,
string
>
) => {
@@ -274,7 +274,7 @@ export const useUpdateReturn = (
orderId: string,
options?: UseMutationOptions<
HttpTypes.AdminReturnResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminUpdateReturnRequest
>
) => {
@@ -302,7 +302,7 @@ export const useAddReturnShipping = (
orderId: string,
options?: UseMutationOptions<
HttpTypes.AdminReturnResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminAddReturnShipping
>
) => {
@@ -329,7 +329,7 @@ export const useUpdateReturnShipping = (
orderId: string,
options?: UseMutationOptions<
HttpTypes.AdminReturnResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminAddReturnShipping
>
) => {
@@ -359,7 +359,7 @@ export const useDeleteReturnShipping = (
orderId: string,
options?: UseMutationOptions<
HttpTypes.AdminReturnResponse,
- FetchError,
+ ClientError,
string
>
) => {
@@ -394,7 +394,7 @@ export const useInitiateReceiveReturn = (
orderId: string,
options?: UseMutationOptions<
HttpTypes.AdminReturnResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminInitiateReceiveReturn
>
) => {
@@ -421,7 +421,7 @@ export const useAddReceiveItems = (
orderId: string,
options?: UseMutationOptions<
HttpTypes.AdminReturnResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminReceiveItems
>
) => {
@@ -448,7 +448,7 @@ export const useUpdateReceiveItem = (
orderId: string,
options?: UseMutationOptions<
HttpTypes.AdminReturnResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminUpdateReceiveItems & { actionId: string }
>
) => {
@@ -479,7 +479,7 @@ export const useRemoveReceiveItems = (
orderId: string,
options?: UseMutationOptions<
HttpTypes.AdminReturnResponse,
- FetchError,
+ ClientError,
string
>
) => {
@@ -507,7 +507,7 @@ export const useAddDismissItems = (
orderId: string,
options?: UseMutationOptions<
HttpTypes.AdminReturnResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminDismissItems
>
) => {
@@ -534,7 +534,7 @@ export const useUpdateDismissItem = (
orderId: string,
options?: UseMutationOptions<
HttpTypes.AdminReturnResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminUpdateDismissItems & { actionId: string }
>
) => {
@@ -565,7 +565,7 @@ export const useRemoveDismissItem = (
orderId: string,
options?: UseMutationOptions<
HttpTypes.AdminReturnResponse,
- FetchError,
+ ClientError,
string
>
) => {
@@ -593,7 +593,7 @@ export const useConfirmReturnReceive = (
orderId: string,
options?: UseMutationOptions<
HttpTypes.AdminReturnResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminConfirmReceiveReturn
>
) => {
@@ -624,7 +624,7 @@ export const useConfirmReturnReceive = (
export const useCancelReceiveReturn = (
id: string,
orderId: string,
- options?: UseMutationOptions<HttpTypes.AdminReturnResponse, FetchError>
+ options?: UseMutationOptions<HttpTypes.AdminReturnResponse, ClientError>
) => {
return useMutation({
mutationFn: () => sdk.admin.return.cancelReceive(id),
diff --git a/packages/admin/src/hooks/api/sales-channels.tsx b/packages/admin/src/hooks/api/sales-channels.tsx
index 9fcec0150..af3d6f150 100644
--- a/packages/admin/src/hooks/api/sales-channels.tsx
+++ b/packages/admin/src/hooks/api/sales-channels.tsx
@@ -1,4 +1,4 @@
-import { FetchError } from "@medusajs/js-sdk"
+import { ClientError } from "@mercurjs/client"
import {
AdminSalesChannelListResponse,
AdminSalesChannelResponse,
@@ -24,7 +24,7 @@ export const useSalesChannel = (
options?: Omit<
UseQueryOptions<
AdminSalesChannelResponse,
- FetchError,
+ ClientError,
AdminSalesChannelResponse,
QueryKey
>,
@@ -45,7 +45,7 @@ export const useSalesChannels = (
options?: Omit<
UseQueryOptions<
AdminSalesChannelListResponse,
- FetchError,
+ ClientError,
AdminSalesChannelListResponse,
QueryKey
>,
@@ -64,7 +64,7 @@ export const useSalesChannels = (
export const useCreateSalesChannel = (
options?: UseMutationOptions<
AdminSalesChannelResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminCreateSalesChannel
>
) => {
@@ -84,7 +84,7 @@ export const useUpdateSalesChannel = (
id: string,
options?: UseMutationOptions<
AdminSalesChannelResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminUpdateSalesChannel
>
) => {
@@ -108,7 +108,7 @@ export const useDeleteSalesChannel = (
id: string,
options?: UseMutationOptions<
HttpTypes.AdminSalesChannelDeleteResponse,
- FetchError,
+ ClientError,
void
>
) => {
@@ -136,7 +136,7 @@ export const useDeleteSalesChannel = (
export const useDeleteSalesChannelLazy = (
options?: UseMutationOptions<
HttpTypes.AdminSalesChannelDeleteResponse,
- FetchError,
+ ClientError,
string
>
) => {
@@ -165,7 +165,7 @@ export const useSalesChannelRemoveProducts = (
id: string,
options?: UseMutationOptions<
AdminSalesChannelResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminBatchLink["remove"]
>
) => {
@@ -202,7 +202,7 @@ export const useSalesChannelAddProducts = (
id: string,
options?: UseMutationOptions<
AdminSalesChannelResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminBatchLink["add"]
>
) => {
diff --git a/packages/admin/src/hooks/api/sellers.tsx b/packages/admin/src/hooks/api/sellers.tsx
new file mode 100644
index 000000000..aadc07efd
--- /dev/null
+++ b/packages/admin/src/hooks/api/sellers.tsx
@@ -0,0 +1,57 @@
+import {
+ ClientError,
+ InferClientInput,
+ InferClientOutput,
+} from "@mercurjs/client"
+import { QueryKey, UseQueryOptions, useQuery } from "@tanstack/react-query"
+import { sdk } from "../../lib/client"
+import { queryKeysFactory } from "../../lib/query-key-factory"
+
+const SELLERS_QUERY_KEY = "sellers" as const
+export const sellersQueryKeys = queryKeysFactory(SELLERS_QUERY_KEY)
+
+export const useSeller = (
+ id: string,
+ query?: Omit<
+ InferClientInput<typeof sdk.admin.sellers.$id.query>,
+ "$id"
+ >,
+ options?: Omit<
+ UseQueryOptions<
+ InferClientOutput<typeof sdk.admin.sellers.$id.query>,
+ ClientError,
+ InferClientOutput<typeof sdk.admin.sellers.$id.query>,
+ QueryKey
+ >,
+ "queryKey" | "queryFn"
+ >
+) => {
+ const { data, ...rest } = useQuery({
+ queryFn: () => sdk.admin.sellers.$id.query({ $id: id, ...query }),
+ queryKey: sellersQueryKeys.detail(id),
+ ...options,
+ })
+
+ return { ...data, ...rest }
+}
+
+export const useSellers = (
+ query?: InferClientInput<typeof sdk.admin.sellers.query>,
+ options?: Omit<
+ UseQueryOptions<
+ InferClientOutput<typeof sdk.admin.sellers.query>,
+ ClientError,
+ InferClientOutput<typeof sdk.admin.sellers.query>,
+ QueryKey
+ >,
+ "queryKey" | "queryFn"
+ >
+) => {
+ const { data, ...rest } = useQuery({
+ queryFn: () => sdk.admin.sellers.query({ ...query }),
+ queryKey: sellersQueryKeys.list(query),
+ ...options,
+ })
+
+ return { ...data, ...rest }
+}
diff --git a/packages/admin/src/hooks/api/shipping-option-types.tsx b/packages/admin/src/hooks/api/shipping-option-types.tsx
index ad5b5eece..5b83fd313 100644
--- a/packages/admin/src/hooks/api/shipping-option-types.tsx
+++ b/packages/admin/src/hooks/api/shipping-option-types.tsx
@@ -1,4 +1,4 @@
-import { FetchError } from "@medusajs/js-sdk"
+import { ClientError } from "@mercurjs/client"
import { HttpTypes } from "@medusajs/types"
import {
QueryKey,
@@ -22,7 +22,7 @@ export const useShippingOptionType = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminShippingOptionTypeResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminShippingOptionTypeResponse,
QueryKey
>,
@@ -43,7 +43,7 @@ export const useShippingOptionTypes = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminShippingOptionTypeListResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminShippingOptionTypeListResponse,
QueryKey
>,
@@ -62,7 +62,7 @@ export const useShippingOptionTypes = (
export const useCreateShippingOptionType = (
options?: UseMutationOptions<
HttpTypes.AdminShippingOptionTypeResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminCreateShippingOptionType
>
) => {
@@ -83,7 +83,7 @@ export const useUpdateShippingOptionType = (
id: string,
options?: UseMutationOptions<
HttpTypes.AdminShippingOptionTypeResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminUpdateShippingOptionType
>
) => {
@@ -107,7 +107,7 @@ export const useDeleteShippingOptionType = (
id: string,
options?: UseMutationOptions<
HttpTypes.AdminShippingOptionTypeDeleteResponse,
- FetchError,
+ ClientError,
void
>
) => {
diff --git a/packages/admin/src/hooks/api/shipping-options.tsx b/packages/admin/src/hooks/api/shipping-options.tsx
index 0992f8033..220531e31 100644
--- a/packages/admin/src/hooks/api/shipping-options.tsx
+++ b/packages/admin/src/hooks/api/shipping-options.tsx
@@ -6,7 +6,7 @@ import {
UseQueryOptions,
} from "@tanstack/react-query"
-import { FetchError } from "@medusajs/js-sdk"
+import { ClientError } from "@mercurjs/client"
import { HttpTypes } from "@medusajs/types"
import { sdk } from "../../lib/client"
import { queryClient } from "../../lib/query-client"
@@ -42,7 +42,7 @@ export const useShippingOptions = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminShippingOptionListResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminShippingOptionListResponse,
QueryKey
>,
@@ -61,7 +61,7 @@ export const useShippingOptions = (
export const useCreateShippingOptions = (
options?: UseMutationOptions<
HttpTypes.AdminShippingOptionResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminCreateShippingOption
>
) => {
@@ -84,7 +84,7 @@ export const useUpdateShippingOptions = (
id: string,
options?: UseMutationOptions<
HttpTypes.AdminShippingOptionResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminUpdateShippingOption
>
) => {
@@ -107,7 +107,7 @@ export const useDeleteShippingOption = (
optionId: string,
options?: UseMutationOptions<
HttpTypes.AdminShippingOptionDeleteResponse,
- FetchError,
+ ClientError,
void
>
) => {
diff --git a/packages/admin/src/hooks/api/shipping-profiles.tsx b/packages/admin/src/hooks/api/shipping-profiles.tsx
index 571577ed7..a76727f57 100644
--- a/packages/admin/src/hooks/api/shipping-profiles.tsx
+++ b/packages/admin/src/hooks/api/shipping-profiles.tsx
@@ -6,7 +6,7 @@ import {
UseQueryOptions,
} from "@tanstack/react-query"
-import { FetchError } from "@medusajs/js-sdk"
+import { ClientError } from "@mercurjs/client"
import { HttpTypes } from "@medusajs/types"
import { sdk } from "../../lib/client"
import { queryClient } from "../../lib/query-client"
@@ -20,7 +20,7 @@ export const shippingProfileQueryKeys = queryKeysFactory(
export const useCreateShippingProfile = (
options?: UseMutationOptions<
HttpTypes.AdminShippingProfileResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminCreateShippingProfile
>
) => {
@@ -43,7 +43,7 @@ export const useShippingProfile = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminShippingProfileResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminShippingProfileResponse,
QueryKey
>,
@@ -64,7 +64,7 @@ export const useShippingProfiles = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminShippingProfileListResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminShippingProfileListResponse,
QueryKey
>,
@@ -84,7 +84,7 @@ export const useUpdateShippingProfile = (
id: string,
options?: UseMutationOptions<
HttpTypes.AdminShippingProfileResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminUpdateShippingProfile
>
) => {
@@ -110,7 +110,7 @@ export const useDeleteShippingProfile = (
id: string,
options?: UseMutationOptions<
HttpTypes.AdminShippingProfileDeleteResponse,
- FetchError,
+ ClientError,
void
>
) => {
diff --git a/packages/admin/src/hooks/api/stock-locations.tsx b/packages/admin/src/hooks/api/stock-locations.tsx
index 5e6cd7716..34ac87856 100644
--- a/packages/admin/src/hooks/api/stock-locations.tsx
+++ b/packages/admin/src/hooks/api/stock-locations.tsx
@@ -6,7 +6,7 @@ import {
useQuery,
} from "@tanstack/react-query"
-import { FetchError } from "@medusajs/js-sdk"
+import { ClientError } from "@mercurjs/client"
import { HttpTypes } from "@medusajs/types"
import { sdk } from "../../lib/client"
import { queryClient } from "../../lib/query-client"
@@ -24,7 +24,7 @@ export const useStockLocation = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminStockLocationResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminStockLocationResponse,
QueryKey
>,
@@ -45,7 +45,7 @@ export const useStockLocations = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminStockLocationListResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminStockLocationListResponse,
QueryKey
>,
@@ -64,7 +64,7 @@ export const useStockLocations = (
export const useCreateStockLocation = (
options?: UseMutationOptions<
HttpTypes.AdminStockLocationResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminCreateStockLocation
>
) => {
@@ -85,7 +85,7 @@ export const useUpdateStockLocation = (
id: string,
options?: UseMutationOptions<
HttpTypes.AdminStockLocationResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminUpdateStockLocation
>
) => {
@@ -109,7 +109,7 @@ export const useUpdateStockLocationSalesChannels = (
id: string,
options?: UseMutationOptions<
HttpTypes.AdminStockLocationResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminUpdateStockLocationSalesChannels
>
) => {
@@ -134,7 +134,7 @@ export const useDeleteStockLocation = (
id: string,
options?: UseMutationOptions<
HttpTypes.AdminStockLocationDeleteResponse,
- FetchError,
+ ClientError,
void
>
) => {
@@ -158,7 +158,7 @@ export const useCreateStockLocationFulfillmentSet = (
locationId: string,
options?: UseMutationOptions<
HttpTypes.AdminStockLocationResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminCreateStockLocationFulfillmentSet
>
) => {
@@ -180,7 +180,7 @@ export const useUpdateStockLocationFulfillmentProviders = (
id: string,
options?: UseMutationOptions<
HttpTypes.AdminStockLocationResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminBatchLink
>
) => {
diff --git a/packages/admin/src/hooks/api/store.tsx b/packages/admin/src/hooks/api/store.tsx
index fefbd3059..15bf882cd 100644
--- a/packages/admin/src/hooks/api/store.tsx
+++ b/packages/admin/src/hooks/api/store.tsx
@@ -1,4 +1,4 @@
-import { FetchError } from "@medusajs/js-sdk";
+import { ClientError } from "@mercurjs/client";
import type { HttpTypes } from "@medusajs/types";
import type {
@@ -30,7 +30,7 @@ export async function retrieveActiveStore(
const activeStore = response.stores?.[0];
if (!activeStore) {
- throw new FetchError("No active store found", "Not Found", 404);
+ throw new ClientError("No active store found", "Not Found", 404);
}
return { store: activeStore };
@@ -41,7 +41,7 @@ export const useStore = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminStoreResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminStoreResponse,
QueryKey
>,
@@ -64,7 +64,7 @@ export const useUpdateStore = (
id: string,
options?: MutationOptions<
HttpTypes.AdminStoreResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminUpdateStore
>,
) => {
diff --git a/packages/admin/src/hooks/api/tags.tsx b/packages/admin/src/hooks/api/tags.tsx
index 8a306c53e..a18779baf 100644
--- a/packages/admin/src/hooks/api/tags.tsx
+++ b/packages/admin/src/hooks/api/tags.tsx
@@ -1,4 +1,4 @@
-import { FetchError } from "@medusajs/js-sdk"
+import { ClientError } from "@mercurjs/client"
import { HttpTypes } from "@medusajs/types"
import {
QueryKey,
@@ -20,7 +20,7 @@ export const useProductTag = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminProductTagResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminProductTagResponse,
QueryKey
>,
@@ -41,7 +41,7 @@ export const useProductTags = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminProductTagListResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminProductTagListResponse,
QueryKey
>,
@@ -61,7 +61,7 @@ export const useCreateProductTag = (
query?: HttpTypes.AdminProductTagParams,
options?: UseMutationOptions<
HttpTypes.AdminProductTagResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminCreateProductTag
>
) => {
@@ -83,7 +83,7 @@ export const useUpdateProductTag = (
query?: HttpTypes.AdminProductTagParams,
options?: UseMutationOptions<
HttpTypes.AdminProductTagResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminUpdateProductTag
>
) => {
@@ -107,7 +107,7 @@ export const useDeleteProductTag = (
id: string,
options?: UseMutationOptions<
HttpTypes.AdminProductTagDeleteResponse,
- FetchError,
+ ClientError,
void
>
) => {
diff --git a/packages/admin/src/hooks/api/tax-rates.tsx b/packages/admin/src/hooks/api/tax-rates.tsx
index 8f615d12e..ac3296888 100644
--- a/packages/admin/src/hooks/api/tax-rates.tsx
+++ b/packages/admin/src/hooks/api/tax-rates.tsx
@@ -1,4 +1,4 @@
-import type { FetchError } from "@medusajs/js-sdk"
+import type { ClientError } from "@mercurjs/client"
import type { HttpTypes } from "@medusajs/types"
import type {
QueryKey,
@@ -24,7 +24,7 @@ export const useTaxRate = (
options?: Omit<
UseQueryOptions<
ExtendedAdminTaxRateResponse,
- FetchError,
+ ClientError,
ExtendedAdminTaxRateResponse,
QueryKey
>,
@@ -45,7 +45,7 @@ export const useTaxRates = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminTaxRateListResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminTaxRateListResponse,
QueryKey
>,
@@ -65,7 +65,7 @@ export const useUpdateTaxRate = (
id: string,
options?: UseMutationOptions<
HttpTypes.AdminTaxRateResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminUpdateTaxRate
>
) => {
@@ -88,7 +88,7 @@ export const useUpdateTaxRate = (
export const useCreateTaxRate = (
options?: UseMutationOptions<
HttpTypes.AdminTaxRateResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminCreateTaxRate
>
) => {
@@ -109,7 +109,7 @@ export const useDeleteTaxRate = (
id: string,
options?: UseMutationOptions<
HttpTypes.AdminTaxRateDeleteResponse,
- FetchError,
+ ClientError,
void
>
) => {
diff --git a/packages/admin/src/hooks/api/tax-regions.tsx b/packages/admin/src/hooks/api/tax-regions.tsx
index 8a7ceff93..6900e442d 100644
--- a/packages/admin/src/hooks/api/tax-regions.tsx
+++ b/packages/admin/src/hooks/api/tax-regions.tsx
@@ -1,4 +1,4 @@
-import { FetchError } from "@medusajs/js-sdk"
+import { ClientError } from "@mercurjs/client"
import { HttpTypes } from "@medusajs/types"
import {
QueryKey,
@@ -20,7 +20,7 @@ export const useTaxRegion = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminTaxRegionResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminTaxRegionResponse,
QueryKey
>,
@@ -41,7 +41,7 @@ export const useTaxRegions = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminTaxRegionListResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminTaxRegionListResponse,
QueryKey
>,
@@ -60,7 +60,7 @@ export const useTaxRegions = (
export const useCreateTaxRegion = (
options?: UseMutationOptions<
HttpTypes.AdminTaxRegionResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminCreateTaxRegion
>
) => {
@@ -79,7 +79,7 @@ export const useUpdateTaxRegion = (
query?: HttpTypes.AdminTaxRegionParams,
options?: UseMutationOptions<
HttpTypes.AdminTaxRegionResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminUpdateTaxRegion,
QueryKey
>
@@ -102,7 +102,7 @@ export const useDeleteTaxRegion = (
id: string,
options?: UseMutationOptions<
HttpTypes.AdminTaxRegionDeleteResponse,
- FetchError,
+ ClientError,
void
>
) => {
diff --git a/packages/admin/src/hooks/api/users.tsx b/packages/admin/src/hooks/api/users.tsx
index e6aa70ea4..ef7f5082d 100644
--- a/packages/admin/src/hooks/api/users.tsx
+++ b/packages/admin/src/hooks/api/users.tsx
@@ -1,4 +1,4 @@
-import { FetchError } from "@medusajs/js-sdk"
+import { ClientError } from "@mercurjs/client"
import { HttpTypes } from "@medusajs/types"
import {
QueryKey,
@@ -21,7 +21,7 @@ export const useMe = (
query?: HttpTypes.AdminUserParams,
options?: UseQueryOptions<
HttpTypes.AdminUserResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminUserResponse,
QueryKey
>
@@ -44,7 +44,7 @@ export const useUser = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminUserResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminUserResponse,
QueryKey
>,
@@ -65,7 +65,7 @@ export const useUsers = (
options?: Omit<
UseQueryOptions<
HttpTypes.AdminUserListResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminUserListResponse,
QueryKey
>,
@@ -85,7 +85,7 @@ export const useCreateUser = (
query?: HttpTypes.AdminUserParams,
options?: UseMutationOptions<
HttpTypes.AdminUserResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminCreateUser,
QueryKey
>
@@ -106,7 +106,7 @@ export const useUpdateUser = (
query?: HttpTypes.AdminUserParams,
options?: UseMutationOptions<
HttpTypes.AdminUserResponse,
- FetchError,
+ ClientError,
HttpTypes.AdminUpdateUser,
QueryKey
>
@@ -130,7 +130,7 @@ export const useDeleteUser = (
id: string,
options?: UseMutationOptions<
HttpTypes.AdminUserDeleteResponse,
- FetchError,
+ ClientError,
void
>
) => {
diff --git a/packages/admin/src/hooks/table/columns/use-seller-table-columns.tsx b/packages/admin/src/hooks/table/columns/use-seller-table-columns.tsx
index 41c86a449..f60a13f14 100644
--- a/packages/admin/src/hooks/table/columns/use-seller-table-columns.tsx
+++ b/packages/admin/src/hooks/table/columns/use-seller-table-columns.tsx
@@ -1,11 +1,11 @@
import { createColumnHelper } from "@tanstack/react-table";
import { useMemo } from "react";
-import { formatDate } from "../../../lib/date";
-import { VendorSeller } from "../../../types";
-import { SellerStatusBadge } from "../../../components/common/seller-status-badge";
+import { SellerStatusCell } from "../../../components/table/table-cells/seller/seller-status-cell/seller-status-cell";
+import { DateCell } from "@/components/table/table-cells/common/date-cell";
+import { SellerDTO } from "@mercurjs/types";
-const columnHelper = createColumnHelper<VendorSeller>();
+const columnHelper = createColumnHelper<SellerDTO>();
export const useSellersTableColumns = () => {
return useMemo(
@@ -21,18 +21,18 @@ export const useSellersTableColumns = () => {
cell: ({ row }) => row.original.name,
}),
columnHelper.display({
- id: "store_status",
- header: "Account Status",
- cell: ({ row }) => (
- <SellerStatusBadge status={row.original.store_status || "-"} />
- ),
+ id: "status",
+ header: "Status",
+ cell: ({ row }) => <SellerStatusCell status={row.original.status} />,
}),
columnHelper.display({
id: "created_at",
header: "Created",
- cell: ({ row }) => formatDate(row.original.created_at),
+ cell: ({ getValue }) => {
+ return <DateCell date={getValue()} />;
+ },
}),
],
- []
+ [],
);
};
diff --git a/packages/admin/src/hooks/use-view-configurations.tsx b/packages/admin/src/hooks/use-view-configurations.tsx
index 829cdfef4..b0c9379ed 100644
--- a/packages/admin/src/hooks/use-view-configurations.tsx
+++ b/packages/admin/src/hooks/use-view-configurations.tsx
@@ -1,6 +1,6 @@
import { useMemo } from "react"
import { toast } from "@medusajs/ui"
-import { FetchError } from "@medusajs/js-sdk"
+import { ClientError } from "@mercurjs/client"
import { useFeatureFlag } from "../providers/feature-flag-provider"
import {
useViewConfigurations as useViewConfigurationsBase,
@@ -15,7 +15,7 @@ import {
const handleError = (error: Error, message?: string) => {
let errorMessage = message
if (!errorMessage) {
- if (error instanceof FetchError) {
+ if (error instanceof ClientError) {
errorMessage = error.message
} else if (error.message) {
errorMessage = error.message
diff --git a/packages/admin/src/pages/api-key-management/api-key-management-detail/api-key-management-detail.tsx b/packages/admin/src/pages/api-key-management/api-key-management-detail/api-key-management-detail.tsx
index 45ea1335a..ef881faf3 100644
--- a/packages/admin/src/pages/api-key-management/api-key-management-detail/api-key-management-detail.tsx
+++ b/packages/admin/src/pages/api-key-management/api-key-management-detail/api-key-management-detail.tsx
@@ -3,7 +3,6 @@ import { useLoaderData, useParams } from "react-router-dom"
import { SingleColumnPageSkeleton } from "../../../components/common/skeleton"
import { SingleColumnPage } from "../../../components/layout/pages"
import { useApiKey } from "../../../hooks/api/api-keys"
-import { useExtension } from "../../../providers/extension-provider"
import { ApiKeyType } from "../common/constants"
import { ApiKeyGeneralSection } from "./components/api-key-general-section"
import { ApiKeySalesChannelSection } from "./components/api-key-sales-channel-section"
@@ -15,7 +14,6 @@ export const ApiKeyManagementDetail = () => {
>
const { id } = useParams()
- const { getWidgets } = useExtension()
const { api_key, isLoading, isError, error } = useApiKey(id!, {
initialData: initialData,
@@ -35,10 +33,6 @@ export const ApiKeyManagementDetail = () => {
<SingleColumnPage
hasOutlet
showJSON
- widgets={{
- before: getWidgets("api_key.details.before"),
- after: getWidgets("api_key.details.after"),
- }}
data={api_key}
data-testid={`${api_key.type}-api-key-detail-page`}
>
diff --git a/packages/admin/src/pages/api-key-management/api-key-management-list/api-key-management-list.tsx b/packages/admin/src/pages/api-key-management/api-key-management-list/api-key-management-list.tsx
index 3dbe91ebf..798144329 100644
--- a/packages/admin/src/pages/api-key-management/api-key-management-list/api-key-management-list.tsx
+++ b/packages/admin/src/pages/api-key-management/api-key-management-list/api-key-management-list.tsx
@@ -3,21 +3,15 @@ import { getApiKeyTypeFromPathname } from "../common/utils"
import { ApiKeyManagementListTable } from "./components/api-key-management-list-table"
import { SingleColumnPage } from "../../../components/layout/pages"
-import { useExtension } from "../../../providers/extension-provider"
export const ApiKeyManagementList = () => {
const { pathname } = useLocation()
- const { getWidgets } = useExtension()
const keyType = getApiKeyTypeFromPathname(pathname)
return (
<SingleColumnPage
hasOutlet
- widgets={{
- before: getWidgets("api_key.list.before"),
- after: getWidgets("api_key.list.after"),
- }}
data-testid="publishable-api-keys-list-page"
>
<ApiKeyManagementListTable keyType={keyType} />
diff --git a/packages/admin/src/pages/campaigns/campaign-detail/campaign-detail.tsx b/packages/admin/src/pages/campaigns/campaign-detail/campaign-detail.tsx
index 372d45d6f..df59c48bb 100644
--- a/packages/admin/src/pages/campaigns/campaign-detail/campaign-detail.tsx
+++ b/packages/admin/src/pages/campaigns/campaign-detail/campaign-detail.tsx
@@ -1,31 +1,28 @@
-import { useLoaderData, useParams } from "react-router-dom"
+import { useLoaderData, useParams } from "react-router-dom";
-import { useCampaign } from "../../../hooks/api/campaigns"
-import { CampaignBudget } from "./components/campaign-budget"
-import { CampaignGeneralSection } from "./components/campaign-general-section"
-import { CampaignPromotionSection } from "./components/campaign-promotion-section"
-import { CampaignSpend } from "./components/campaign-spend"
-import { campaignLoader } from "./loader"
+import { useCampaign } from "../../../hooks/api/campaigns";
+import { CampaignBudget } from "./components/campaign-budget";
+import { CampaignGeneralSection } from "./components/campaign-general-section";
+import { CampaignPromotionSection } from "./components/campaign-promotion-section";
+import { CampaignSpend } from "./components/campaign-spend";
+import { campaignLoader } from "./loader";
-import { TwoColumnPageSkeleton } from "../../../components/common/skeleton"
-import { TwoColumnPage } from "../../../components/layout/pages"
-import { useExtension } from "../../../providers/extension-provider"
-import { CampaignConfigurationSection } from "./components/campaign-configuration-section"
-import { CAMPAIGN_DETAIL_FIELDS } from "./constants"
+import { TwoColumnPageSkeleton } from "../../../components/common/skeleton";
+import { TwoColumnPage } from "../../../components/layout/pages";
+import { CampaignConfigurationSection } from "./components/campaign-configuration-section";
+import { CAMPAIGN_DETAIL_FIELDS } from "./constants";
export const CampaignDetail = () => {
const initialData = useLoaderData() as Awaited<
ReturnType<typeof campaignLoader>
- >
+ >;
- const { id } = useParams()
+ const { id } = useParams();
const { campaign, isLoading, isError, error } = useCampaign(
id!,
{ fields: CAMPAIGN_DETAIL_FIELDS },
- { initialData }
- )
-
- const { getWidgets } = useExtension()
+ { initialData },
+ );
if (isLoading || !campaign) {
return (
@@ -35,26 +32,15 @@ export const CampaignDetail = () => {
showJSON
showMetadata
/>
- )
+ );
}
if (isError) {
- throw error
+ throw error;
}
return (
- <TwoColumnPage
- widgets={{
- after: getWidgets("campaign.details.after"),
- before: getWidgets("campaign.details.before"),
- sideAfter: getWidgets("campaign.details.side.after"),
- sideBefore: getWidgets("campaign.details.side.before"),
- }}
- hasOutlet
- showJSON
- showMetadata
- data={campaign}
- >
+ <TwoColumnPage hasOutlet showJSON showMetadata data={campaign}>
<TwoColumnPage.Main>
<CampaignGeneralSection campaign={campaign} />
<CampaignPromotionSection campaign={campaign} />
@@ -65,5 +51,5 @@ export const CampaignDetail = () => {
<CampaignBudget campaign={campaign} />
</TwoColumnPage.Sidebar>
</TwoColumnPage>
- )
-}
+ );
+};
diff --git a/packages/admin/src/pages/campaigns/campaign-list/campaign-list.tsx b/packages/admin/src/pages/campaigns/campaign-list/campaign-list.tsx
index 0cdeab700..0890d3aa6 100644
--- a/packages/admin/src/pages/campaigns/campaign-list/campaign-list.tsx
+++ b/packages/admin/src/pages/campaigns/campaign-list/campaign-list.tsx
@@ -1,16 +1,9 @@
import { SingleColumnPage } from "../../../components/layout/pages"
-import { useExtension } from "../../../providers/extension-provider"
import { CampaignListTable } from "./components/campaign-list-table"
export const CampaignList = () => {
- const { getWidgets } = useExtension()
-
return (
<SingleColumnPage
- widgets={{
- after: getWidgets("campaign.list.after"),
- before: getWidgets("campaign.list.before"),
- }}
hasOutlet
>
<CampaignListTable />
diff --git a/packages/admin/src/pages/categories/categories-metadata/categories-metadata.tsx b/packages/admin/src/pages/categories/categories-metadata/categories-metadata.tsx
index 619d2e5f0..9c1efa4b8 100644
--- a/packages/admin/src/pages/categories/categories-metadata/categories-metadata.tsx
+++ b/packages/admin/src/pages/categories/categories-metadata/categories-metadata.tsx
@@ -6,7 +6,7 @@ import {
} from "@hooks/api"
import { MetadataForm } from "@components/forms/metadata-form"
import { RouteDrawer } from "@components/modals"
-import { FetchError } from "@medusajs/js-sdk"
+import { ClientError } from "@mercurjs/client"
export const CategoriesMetadata = () => {
const { id } = useParams()
@@ -20,7 +20,7 @@ export const CategoriesMetadata = () => {
const handleSubmit = async (
params: { metadata?: Record<string, unknown> | null },
- callbacks: { onSuccess?: () => void; onError?: (error: FetchError | string) => void }
+ callbacks: { onSuccess?: () => void; onError?: (error: ClientError | string) => void }
) => {
try {
const result = await mutateAsync({
@@ -30,7 +30,7 @@ export const CategoriesMetadata = () => {
return result
} catch (error) {
- const message = error instanceof FetchError ? error.message : 'An error occured'
+ const message = error instanceof ClientError ? error.message : 'An error occured'
callbacks.onError?.(message)
throw error
}
diff --git a/packages/admin/src/pages/categories/category-detail/category-detail.tsx b/packages/admin/src/pages/categories/category-detail/category-detail.tsx
index fc2b426e6..75f7e84ea 100644
--- a/packages/admin/src/pages/categories/category-detail/category-detail.tsx
+++ b/packages/admin/src/pages/categories/category-detail/category-detail.tsx
@@ -1,30 +1,27 @@
-import { useLoaderData, useParams } from "react-router-dom"
-import { useProductCategory } from "../../../hooks/api/categories"
-import { CategoryGeneralSection } from "./components/category-general-section"
-import { CategoryOrganizeSection } from "./components/category-organize-section"
-import { CategoryProductSection } from "./components/category-product-section"
-import { categoryLoader } from "./loader"
+import { useLoaderData, useParams } from "react-router-dom";
+import { useProductCategory } from "../../../hooks/api/categories";
+import { CategoryGeneralSection } from "./components/category-general-section";
+import { CategoryOrganizeSection } from "./components/category-organize-section";
+import { CategoryProductSection } from "./components/category-product-section";
+import { categoryLoader } from "./loader";
-import { TwoColumnPageSkeleton } from "../../../components/common/skeleton"
-import { TwoColumnPage } from "../../../components/layout/pages"
-import { useExtension } from "../../../providers/extension-provider"
+import { TwoColumnPageSkeleton } from "../../../components/common/skeleton";
+import { TwoColumnPage } from "../../../components/layout/pages";
export const CategoryDetail = () => {
- const { id } = useParams()
+ const { id } = useParams();
const initialData = useLoaderData() as Awaited<
ReturnType<typeof categoryLoader>
- >
-
- const { getWidgets } = useExtension()
+ >;
const { product_category, isLoading, isError, error } = useProductCategory(
id!,
undefined,
{
initialData,
- }
- )
+ },
+ );
if (isLoading || !product_category) {
return (
@@ -34,25 +31,15 @@ export const CategoryDetail = () => {
showJSON
showMetadata
/>
- )
+ );
}
if (isError) {
- throw error
+ throw error;
}
return (
- <TwoColumnPage
- widgets={{
- after: getWidgets("product_category.details.after"),
- before: getWidgets("product_category.details.before"),
- sideAfter: getWidgets("product_category.details.side.after"),
- sideBefore: getWidgets("product_category.details.side.before"),
- }}
- showJSON
- showMetadata
- data={product_category}
- >
+ <TwoColumnPage showJSON showMetadata data={product_category}>
<TwoColumnPage.Main>
<CategoryGeneralSection category={product_category} />
<CategoryProductSection category={product_category} />
@@ -61,5 +48,5 @@ export const CategoryDetail = () => {
<CategoryOrganizeSection category={product_category} />
</TwoColumnPage.Sidebar>
</TwoColumnPage>
- )
-}
+ );
+};
diff --git a/packages/admin/src/pages/categories/category-list/category-list.tsx b/packages/admin/src/pages/categories/category-list/category-list.tsx
index 8d06b910f..145eef625 100644
--- a/packages/admin/src/pages/categories/category-list/category-list.tsx
+++ b/packages/admin/src/pages/categories/category-list/category-list.tsx
@@ -1,16 +1,9 @@
import { SingleColumnPage } from "../../../components/layout/pages"
-import { useExtension } from "../../../providers/extension-provider"
import { CategoryListTable } from "./components/category-list-table"
export const CategoryList = () => {
- const { getWidgets } = useExtension()
-
return (
<SingleColumnPage
- widgets={{
- after: getWidgets("product_category.list.after"),
- before: getWidgets("product_category.list.before"),
- }}
hasOutlet
>
<CategoryListTable />
diff --git a/packages/admin/src/pages/categories/category-organize/components/organize-category-form/organize-category-form.tsx b/packages/admin/src/pages/categories/category-organize/components/organize-category-form/organize-category-form.tsx
index 097ddd157..8a3c5169d 100644
--- a/packages/admin/src/pages/categories/category-organize/components/organize-category-form/organize-category-form.tsx
+++ b/packages/admin/src/pages/categories/category-organize/components/organize-category-form/organize-category-form.tsx
@@ -2,7 +2,7 @@ import { useMutation } from "@tanstack/react-query"
import { UniqueIdentifier } from "@dnd-kit/core"
import { Spinner } from "@medusajs/icons"
-import { FetchError } from "@medusajs/js-sdk"
+import { ClientError } from "@mercurjs/client"
import { HttpTypes } from "@medusajs/types"
import { toast } from "@medusajs/ui"
import { useState } from "react"
@@ -72,7 +72,7 @@ export const OrganizeCategoryForm = () => {
previousValue,
}
},
- onError: (error: FetchError, _newValue, context) => {
+ onError: (error: ClientError, _newValue, context) => {
// Roll back to the previous value
queryClient.setQueryData(
categoriesQueryKeys.list(QUERY),
diff --git a/packages/admin/src/pages/collections/collection-detail/collection-detail.tsx b/packages/admin/src/pages/collections/collection-detail/collection-detail.tsx
index a9d1a9232..0141d5338 100644
--- a/packages/admin/src/pages/collections/collection-detail/collection-detail.tsx
+++ b/packages/admin/src/pages/collections/collection-detail/collection-detail.tsx
@@ -3,7 +3,6 @@ import { useLoaderData, useParams } from "react-router-dom"
import { SingleColumnPageSkeleton } from "../../../components/common/skeleton"
import { SingleColumnPage } from "../../../components/layout/pages"
import { useCollection } from "../../../hooks/api/collections"
-import { useExtension } from "../../../providers/extension-provider"
import { CollectionGeneralSection } from "./components/collection-general-section"
import { CollectionProductSection } from "./components/collection-product-section"
import { collectionLoader } from "./loader"
@@ -18,8 +17,6 @@ export const CollectionDetail = () => {
initialData,
})
- const { getWidgets } = useExtension()
-
if (isLoading || !collection) {
return <SingleColumnPageSkeleton sections={2} showJSON showMetadata />
}
@@ -30,10 +27,6 @@ export const CollectionDetail = () => {
return (
<SingleColumnPage
- widgets={{
- after: getWidgets("product_collection.details.after"),
- before: getWidgets("product_collection.details.before"),
- }}
showJSON
showMetadata
data={collection}
diff --git a/packages/admin/src/pages/collections/collection-list/collection-list.tsx b/packages/admin/src/pages/collections/collection-list/collection-list.tsx
index 43054e261..6f04eb41c 100644
--- a/packages/admin/src/pages/collections/collection-list/collection-list.tsx
+++ b/packages/admin/src/pages/collections/collection-list/collection-list.tsx
@@ -1,17 +1,9 @@
import { SingleColumnPage } from "../../../components/layout/pages"
-import { useExtension } from "../../../providers/extension-provider"
import { CollectionListTable } from "./components/collection-list-table"
export const CollectionList = () => {
- const { getWidgets } = useExtension()
-
return (
- <SingleColumnPage
- widgets={{
- after: getWidgets("product_collection.list.after"),
- before: getWidgets("product_collection.list.before"),
- }}
- >
+ <SingleColumnPage>
<CollectionListTable />
</SingleColumnPage>
)
diff --git a/packages/admin/src/pages/collections/collection-metadata/collection-metadata.tsx b/packages/admin/src/pages/collections/collection-metadata/collection-metadata.tsx
index e134284a8..337ac6f19 100644
--- a/packages/admin/src/pages/collections/collection-metadata/collection-metadata.tsx
+++ b/packages/admin/src/pages/collections/collection-metadata/collection-metadata.tsx
@@ -1,7 +1,7 @@
import { useParams } from "react-router-dom"
import { MetadataForm } from "@components/forms/metadata-form/metadata-form"
import { useCollection, useUpdateCollection } from "@hooks/api"
-import { FetchError } from "@medusajs/js-sdk"
+import { ClientError } from "@mercurjs/client"
export const CollectionMetadata = () => {
const { id } = useParams()
@@ -15,7 +15,7 @@ export const CollectionMetadata = () => {
const handleSubmit = async (
params: { metadata?: Record<string, unknown> | null },
- callbacks: { onSuccess?: () => void; onError?: (error: FetchError | string) => void }
+ callbacks: { onSuccess?: () => void; onError?: (error: ClientError | string) => void }
) => {
try {
const result = await mutateAsync({
@@ -25,7 +25,7 @@ export const CollectionMetadata = () => {
return result
} catch (error) {
- const message = error instanceof FetchError ? error.message : 'An error occurred'
+ const message = error instanceof ClientError ? error.message : 'An error occurred'
callbacks.onError?.(message)
throw error
}
diff --git a/packages/admin/src/pages/customers/customer-detail/customer-detail.tsx b/packages/admin/src/pages/customers/customer-detail/customer-detail.tsx
index 7d48897ab..ffdd597b6 100644
--- a/packages/admin/src/pages/customers/customer-detail/customer-detail.tsx
+++ b/packages/admin/src/pages/customers/customer-detail/customer-detail.tsx
@@ -3,7 +3,6 @@ import { useLoaderData, useParams } from "react-router-dom"
import { SingleColumnPageSkeleton } from "../../../components/common/skeleton"
import { TwoColumnPage } from "../../../components/layout/pages"
import { useCustomer } from "../../../hooks/api/customers"
-import { useExtension } from "../../../providers/extension-provider"
import { CustomerAddressSection } from "./components/customer-address-section/customer-address-section"
import { CustomerGeneralSection } from "./components/customer-general-section"
import { CustomerGroupSection } from "./components/customer-group-section"
@@ -22,8 +21,6 @@ export const CustomerDetail = () => {
{ initialData }
)
- const { getWidgets } = useExtension()
-
if (isLoading || !customer) {
return <SingleColumnPageSkeleton sections={2} showJSON showMetadata />
}
@@ -34,12 +31,6 @@ export const CustomerDetail = () => {
return (
<TwoColumnPage
- widgets={{
- before: getWidgets("customer.details.before"),
- after: getWidgets("customer.details.after"),
- sideAfter: getWidgets("customer.details.side.after"),
- sideBefore: getWidgets("customer.details.side.before"),
- }}
data={customer}
hasOutlet
showJSON
diff --git a/packages/admin/src/pages/customers/customer-list/customer-list.tsx b/packages/admin/src/pages/customers/customer-list/customer-list.tsx
index 89324be89..4c9e78f5a 100644
--- a/packages/admin/src/pages/customers/customer-list/customer-list.tsx
+++ b/packages/admin/src/pages/customers/customer-list/customer-list.tsx
@@ -1,17 +1,9 @@
import { SingleColumnPage } from "../../../components/layout/pages"
-import { useExtension } from "../../../providers/extension-provider"
import { CustomerListTable } from "./components/customer-list-table"
export const CustomersList = () => {
- const { getWidgets } = useExtension()
-
return (
- <SingleColumnPage
- widgets={{
- after: getWidgets("customer.list.after"),
- before: getWidgets("customer.list.before"),
- }}
- >
+ <SingleColumnPage>
<CustomerListTable />
</SingleColumnPage>
)
diff --git a/packages/admin/src/pages/customers/customer-metadata/customer-metadata.tsx b/packages/admin/src/pages/customers/customer-metadata/customer-metadata.tsx
index 7a2bc2604..79f2eafe0 100644
--- a/packages/admin/src/pages/customers/customer-metadata/customer-metadata.tsx
+++ b/packages/admin/src/pages/customers/customer-metadata/customer-metadata.tsx
@@ -1,6 +1,6 @@
import { useParams } from "react-router-dom"
-import { FetchError } from "@medusajs/js-sdk"
+import { ClientError } from "@mercurjs/client"
import { MetadataForm } from "@components/forms/metadata-form"
import { useCustomer, useUpdateCustomer } from "@hooks/api"
@@ -16,7 +16,7 @@ export const CustomerMetadata = () => {
const handleSubmit = async (
params: { metadata?: Record<string, unknown> | null },
- callbacks: { onSuccess?: () => void; onError?: (error: FetchError | string) => void }
+ callbacks: { onSuccess?: () => void; onError?: (error: ClientError | string) => void }
) => {
try {
const result = await mutateAsync({
@@ -26,7 +26,7 @@ export const CustomerMetadata = () => {
return result
} catch (error) {
- const message = error instanceof FetchError ? error.message : 'An error occurred'
+ const message = error instanceof ClientError ? error.message : 'An error occurred'
callbacks.onError?.(message)
throw error
}
diff --git a/packages/admin/src/pages/customers/customers-add-customer-group/components/add-customers-form/add-customer-groups-form.tsx b/packages/admin/src/pages/customers/customers-add-customer-group/components/add-customers-form/add-customer-groups-form.tsx
index 4952188e2..a47c05996 100644
--- a/packages/admin/src/pages/customers/customers-add-customer-group/components/add-customers-form/add-customer-groups-form.tsx
+++ b/packages/admin/src/pages/customers/customers-add-customer-group/components/add-customers-form/add-customer-groups-form.tsx
@@ -1,60 +1,60 @@
-import { zodResolver } from "@hookform/resolvers/zod"
-import { Button, Checkbox, Hint, Tooltip, toast } from "@medusajs/ui"
+import { zodResolver } from "@hookform/resolvers/zod";
+import { Button, Checkbox, Hint, Tooltip, toast } from "@medusajs/ui";
import {
OnChangeFn,
RowSelectionState,
createColumnHelper,
-} from "@tanstack/react-table"
-import { useEffect, useMemo, useState } from "react"
-import { useForm } from "react-hook-form"
-import { useTranslation } from "react-i18next"
-import * as zod from "zod"
+} from "@tanstack/react-table";
+import { useEffect, useMemo, useState } from "react";
+import { useForm } from "react-hook-form";
+import { useTranslation } from "react-i18next";
+import * as zod from "zod";
-import { HttpTypes } from "@medusajs/types"
+import { HttpTypes } from "@medusajs/types";
import {
RouteFocusModal,
useRouteModal,
-} from "../../../../../components/modals"
-import { _DataTable } from "../../../../../components/table/data-table"
-import { KeyboundForm } from "../../../../../components/utilities/keybound-form"
-import { useBatchCustomerCustomerGroups } from "../../../../../hooks/api"
-import { useCustomerGroups } from "../../../../../hooks/api/customer-groups"
-import { useCustomerGroupTableColumns } from "../../../../../hooks/table/columns/use-customer-group-table-columns"
-import { useCustomerGroupTableFilters } from "../../../../../hooks/table/filters/use-customer-group-table-filters"
-import { useCustomerGroupTableQuery } from "../../../../../hooks/table/query/use-customer-group-table-query"
-import { useDataTable } from "../../../../../hooks/use-data-table"
-import { FetchError } from "@medusajs/js-sdk"
+} from "../../../../../components/modals";
+import { _DataTable } from "../../../../../components/table/data-table";
+import { KeyboundForm } from "../../../../../components/utilities/keybound-form";
+import { useBatchCustomerCustomerGroups } from "../../../../../hooks/api";
+import { useCustomerGroups } from "../../../../../hooks/api/customer-groups";
+import { useCustomerGroupTableColumns } from "../../../../../hooks/table/columns/use-customer-group-table-columns";
+import { useCustomerGroupTableFilters } from "../../../../../hooks/table/filters/use-customer-group-table-filters";
+import { useCustomerGroupTableQuery } from "../../../../../hooks/table/query/use-customer-group-table-query";
+import { useDataTable } from "../../../../../hooks/use-data-table";
+import { ClientError } from "@mercurjs/client";
type AddCustomerGroupsFormProps = {
- customerId: string
-}
+ customerId: string;
+};
export const AddCustomerGroupsSchema = zod.object({
customer_group_ids: zod.array(zod.string()).min(1),
-})
+});
-const PAGE_SIZE = 10
+const PAGE_SIZE = 10;
export const AddCustomerGroupsForm = ({
customerId,
}: AddCustomerGroupsFormProps) => {
- const { t } = useTranslation()
- const { handleSuccess } = useRouteModal()
- const [isPending, setIsPending] = useState(false)
+ const { t } = useTranslation();
+ const { handleSuccess } = useRouteModal();
+ const [isPending, setIsPending] = useState(false);
const { mutateAsync: batchCustomerCustomerGroups } =
- useBatchCustomerCustomerGroups(customerId)
+ useBatchCustomerCustomerGroups(customerId);
const form = useForm<zod.infer<typeof AddCustomerGroupsSchema>>({
defaultValues: {
customer_group_ids: [],
},
resolver: zodResolver(AddCustomerGroupsSchema),
- })
+ });
- const { setValue } = form
+ const { setValue } = form;
- const [rowSelection, setRowSelection] = useState<RowSelectionState>({})
+ const [rowSelection, setRowSelection] = useState<RowSelectionState>({});
useEffect(() => {
setValue(
@@ -63,14 +63,14 @@ export const AddCustomerGroupsForm = ({
{
shouldDirty: true,
shouldTouch: true,
- }
- )
- }, [rowSelection, setValue])
+ },
+ );
+ }, [rowSelection, setValue]);
const { searchParams, raw } = useCustomerGroupTableQuery({
pageSize: PAGE_SIZE,
- })
- const filters = useCustomerGroupTableFilters()
+ });
+ const filters = useCustomerGroupTableFilters();
const {
customer_groups,
@@ -81,22 +81,22 @@ export const AddCustomerGroupsForm = ({
} = useCustomerGroups({
fields: "*customers",
...searchParams,
- })
+ });
const updater: OnChangeFn<RowSelectionState> = (fn) => {
- const state = typeof fn === "function" ? fn(rowSelection) : fn
+ const state = typeof fn === "function" ? fn(rowSelection) : fn;
- const ids = Object.keys(state)
+ const ids = Object.keys(state);
setValue("customer_group_ids", ids, {
shouldDirty: true,
shouldTouch: true,
- })
+ });
- setRowSelection(state)
- }
+ setRowSelection(state);
+ };
- const columns = useColumns()
+ const columns = useColumns();
const { table } = useDataTable({
data: customer_groups ?? [],
@@ -104,7 +104,7 @@ export const AddCustomerGroupsForm = ({
count,
enablePagination: true,
enableRowSelection: (row) => {
- return !row.original.customers?.map((c) => c.id).includes(customerId)
+ return !row.original.customers?.map((c) => c.id).includes(customerId);
},
getRowId: (row) => row.id,
pageSize: PAGE_SIZE,
@@ -112,12 +112,12 @@ export const AddCustomerGroupsForm = ({
state: rowSelection,
updater,
},
- })
+ });
const handleSubmit = form.handleSubmit(async (data) => {
- setIsPending(true)
+ setIsPending(true);
try {
- await batchCustomerCustomerGroups({ add: data.customer_group_ids })
+ await batchCustomerCustomerGroups({ add: data.customer_group_ids });
toast.success(
t("customers.groups.add.success", {
@@ -125,19 +125,19 @@ export const AddCustomerGroupsForm = ({
.map((id) => customer_groups?.find((g) => g.id === id))
.filter(Boolean)
.map((cg) => cg?.name),
- })
- )
+ }),
+ );
- handleSuccess(`/customers/${customerId}`)
+ handleSuccess(`/customers/${customerId}`);
} catch (e) {
- toast.error(e instanceof FetchError ? e.message : "An error occurred")
+ toast.error(e instanceof ClientError ? e.message : "An error occurred");
} finally {
- setIsPending(false)
+ setIsPending(false);
}
- })
+ });
if (isError) {
- throw error
+ throw error;
}
return (
@@ -148,15 +148,24 @@ export const AddCustomerGroupsForm = ({
data-testid="add-customer-groups-form-keybound"
>
<RouteFocusModal.Header data-testid="add-customer-groups-form-header">
- <div className="flex items-center justify-end gap-x-2" data-testid="add-customer-groups-form-header-errors">
+ <div
+ className="flex items-center justify-end gap-x-2"
+ data-testid="add-customer-groups-form-header-errors"
+ >
{form.formState.errors.customer_group_ids && (
- <Hint variant="error" data-testid="add-customer-groups-form-error-hint">
+ <Hint
+ variant="error"
+ data-testid="add-customer-groups-form-error-hint"
+ >
{form.formState.errors.customer_group_ids.message}
</Hint>
)}
</div>
</RouteFocusModal.Header>
- <RouteFocusModal.Body className="size-full overflow-hidden" data-testid="add-customer-groups-form-body">
+ <RouteFocusModal.Body
+ className="size-full overflow-hidden"
+ data-testid="add-customer-groups-form-body"
+ >
<_DataTable
table={table}
columns={columns}
@@ -179,7 +188,11 @@ export const AddCustomerGroupsForm = ({
</RouteFocusModal.Body>
<RouteFocusModal.Footer data-testid="add-customer-groups-form-footer">
<RouteFocusModal.Close asChild>
- <Button variant="secondary" size="small" data-testid="add-customer-groups-form-cancel-button">
+ <Button
+ variant="secondary"
+ size="small"
+ data-testid="add-customer-groups-form-cancel-button"
+ >
{t("actions.cancel")}
</Button>
</RouteFocusModal.Close>
@@ -195,14 +208,14 @@ export const AddCustomerGroupsForm = ({
</RouteFocusModal.Footer>
</KeyboundForm>
</RouteFocusModal.Form>
- )
-}
+ );
+};
-const columnHelper = createColumnHelper<HttpTypes.AdminCustomerGroup>()
+const columnHelper = createColumnHelper<HttpTypes.AdminCustomerGroup>();
const useColumns = () => {
- const { t } = useTranslation()
- const base = useCustomerGroupTableColumns()
+ const { t } = useTranslation();
+ const base = useCustomerGroupTableColumns();
const columns = useMemo(
() => [
@@ -220,11 +233,11 @@ const useColumns = () => {
table.toggleAllPageRowsSelected(!!value)
}
/>
- )
+ );
},
cell: ({ row }) => {
- const isPreSelected = !row.getCanSelect()
- const isSelected = row.getIsSelected() || isPreSelected
+ const isPreSelected = !row.getCanSelect();
+ const isSelected = row.getIsSelected() || isPreSelected;
const Component = (
<Checkbox
@@ -232,10 +245,10 @@ const useColumns = () => {
disabled={isPreSelected}
onCheckedChange={(value) => row.toggleSelected(!!value)}
onClick={(e) => {
- e.stopPropagation()
+ e.stopPropagation();
}}
/>
- )
+ );
if (isPreSelected) {
return (
@@ -245,16 +258,16 @@ const useColumns = () => {
>
{Component}
</Tooltip>
- )
+ );
}
- return Component
+ return Component;
},
}),
...base,
],
- [t, base]
- )
+ [t, base],
+ );
- return columns
-}
+ return columns;
+};
diff --git a/packages/admin/src/pages/inventory/inventory-detail/inventory-detail.tsx b/packages/admin/src/pages/inventory/inventory-detail/inventory-detail.tsx
index 846e81e0b..4d2ef6108 100644
--- a/packages/admin/src/pages/inventory/inventory-detail/inventory-detail.tsx
+++ b/packages/admin/src/pages/inventory/inventory-detail/inventory-detail.tsx
@@ -2,7 +2,6 @@ import { useLoaderData, useParams } from "react-router-dom"
import { INVENTORY_DETAIL_FIELDS } from "./constants"
import type { inventoryItemLoader } from "./loader"
import { useInventoryItem } from "@hooks/api"
-import { useExtension } from "@providers/extension-provider"
import { TwoColumnPageSkeleton } from "@components/common/skeleton"
import { TwoColumnPage } from "@components/layout/pages"
import { InventoryItemGeneralSection } from "./components/inventory-item-general-section"
@@ -33,8 +32,6 @@ export const InventoryDetail = () => {
}
)
- const { getWidgets } = useExtension()
-
if (isLoading || !inventory_item) {
return (
<TwoColumnPageSkeleton
@@ -53,12 +50,6 @@ export const InventoryDetail = () => {
return (
<div data-testid="inventory-detail-page">
<TwoColumnPage
- widgets={{
- after: getWidgets("inventory_item.details.after"),
- before: getWidgets("inventory_item.details.before"),
- sideAfter: getWidgets("inventory_item.details.side.after"),
- sideBefore: getWidgets("inventory_item.details.side.before"),
- }}
data={inventory_item}
showJSON
showMetadata
diff --git a/packages/admin/src/pages/inventory/inventory-list/inventory-list.tsx b/packages/admin/src/pages/inventory/inventory-list/inventory-list.tsx
index e16b1d650..9973f5627 100644
--- a/packages/admin/src/pages/inventory/inventory-list/inventory-list.tsx
+++ b/packages/admin/src/pages/inventory/inventory-list/inventory-list.tsx
@@ -1,18 +1,10 @@
import { SingleColumnPage } from "../../../components/layout/pages"
-import { useExtension } from "../../../providers/extension-provider"
import { InventoryListTable } from "./components/inventory-list-table"
export const InventoryItemListTable = () => {
- const { getWidgets } = useExtension()
-
return (
<div data-testid="inventory-page">
- <SingleColumnPage
- widgets={{
- after: getWidgets("inventory_item.list.after"),
- before: getWidgets("inventory_item.list.before"),
- }}
- >
+ <SingleColumnPage>
<InventoryListTable />
</SingleColumnPage>
</div>
diff --git a/packages/admin/src/pages/inventory/inventory-metadata/inventory-metadata.tsx b/packages/admin/src/pages/inventory/inventory-metadata/inventory-metadata.tsx
index 2e5d8d1d7..7c84714f5 100644
--- a/packages/admin/src/pages/inventory/inventory-metadata/inventory-metadata.tsx
+++ b/packages/admin/src/pages/inventory/inventory-metadata/inventory-metadata.tsx
@@ -1,37 +1,41 @@
-import { useParams } from "react-router-dom"
+import { useParams } from "react-router-dom";
-import { useInventoryItem, useUpdateInventoryItem } from "@hooks/api"
-import { MetadataForm } from "@components/forms/metadata-form"
-import { RouteDrawer } from "@components/modals"
-import { FetchError } from "@medusajs/js-sdk"
+import { useInventoryItem, useUpdateInventoryItem } from "@hooks/api";
+import { MetadataForm } from "@components/forms/metadata-form";
+import { RouteDrawer } from "@components/modals";
+import { ClientError } from "@mercurjs/client";
export const InventoryItemMetadata = () => {
- const { id } = useParams()
+ const { id } = useParams();
- const { inventory_item, isPending, isError, error } = useInventoryItem(id!)
- const { mutateAsync, isPending: isMutating } = useUpdateInventoryItem(id!)
+ const { inventory_item, isPending, isError, error } = useInventoryItem(id!);
+ const { mutateAsync, isPending: isMutating } = useUpdateInventoryItem(id!);
if (isError) {
- throw error
+ throw error;
}
const handleSubmit = async (
params: { metadata?: Record<string, unknown> | null },
- callbacks: { onSuccess?: () => void; onError?: (error: FetchError | string) => void }
+ callbacks: {
+ onSuccess?: () => void;
+ onError?: (error: ClientError | string) => void;
+ },
) => {
try {
const result = await mutateAsync({
metadata: params.metadata === undefined ? undefined : params.metadata,
- })
- callbacks.onSuccess?.()
+ });
+ callbacks.onSuccess?.();
- return result
+ return result;
} catch (error) {
- const message = error instanceof FetchError ? error.message : 'An error occurred'
- callbacks.onError?.(message)
- throw error
+ const message =
+ error instanceof ClientError ? error.message : "An error occurred";
+ callbacks.onError?.(message);
+ throw error;
}
- }
+ };
return (
<RouteDrawer data-testid="inventory-metadata-drawer">
@@ -42,5 +46,5 @@ export const InventoryItemMetadata = () => {
metadata={inventory_item?.metadata}
/>
</RouteDrawer>
- )
-}
+ );
+};
diff --git a/packages/admin/src/pages/locations/location-detail/location-detail.tsx b/packages/admin/src/pages/locations/location-detail/location-detail.tsx
index 3a1b671f8..fd6744af1 100644
--- a/packages/admin/src/pages/locations/location-detail/location-detail.tsx
+++ b/packages/admin/src/pages/locations/location-detail/location-detail.tsx
@@ -1,22 +1,21 @@
-import { useLoaderData, useParams } from "react-router-dom"
+import { useLoaderData, useParams } from "react-router-dom";
-import { useStockLocation } from "../../../hooks/api/stock-locations"
-import { LocationGeneralSection } from "./components/location-general-section"
-import LocationsSalesChannelsSection from "./components/location-sales-channels-section/locations-sales-channels-section"
-import { locationLoader } from "./loader"
+import { useStockLocation } from "../../../hooks/api/stock-locations";
+import { LocationGeneralSection } from "./components/location-general-section";
+import LocationsSalesChannelsSection from "./components/location-sales-channels-section/locations-sales-channels-section";
+import { locationLoader } from "./loader";
-import { TwoColumnPageSkeleton } from "../../../components/common/skeleton"
-import { TwoColumnPage } from "../../../components/layout/pages"
-import { useExtension } from "../../../providers/extension-provider"
-import LocationsFulfillmentProvidersSection from "./components/location-fulfillment-providers-section/location-fulfillment-providers-section"
-import { LOCATION_DETAILS_FIELD } from "./constants"
+import { TwoColumnPageSkeleton } from "../../../components/common/skeleton";
+import { TwoColumnPage } from "../../../components/layout/pages";
+import LocationsFulfillmentProvidersSection from "./components/location-fulfillment-providers-section/location-fulfillment-providers-section";
+import { LOCATION_DETAILS_FIELD } from "./constants";
export const LocationDetail = () => {
const initialData = useLoaderData() as Awaited<
ReturnType<typeof locationLoader>
- >
+ >;
- const { location_id } = useParams()
+ const { location_id } = useParams();
const {
stock_location: location,
isPending: isLoading,
@@ -25,29 +24,21 @@ export const LocationDetail = () => {
} = useStockLocation(
location_id!,
{ fields: LOCATION_DETAILS_FIELD },
- { initialData }
- )
-
- const { getWidgets } = useExtension()
+ { initialData },
+ );
if (isLoading || !location) {
return (
<TwoColumnPageSkeleton mainSections={3} sidebarSections={2} showJSON />
- )
+ );
}
if (isError) {
- throw error
+ throw error;
}
return (
<TwoColumnPage
- widgets={{
- after: getWidgets("location.details.after"),
- before: getWidgets("location.details.before"),
- sideAfter: getWidgets("location.details.side.after"),
- sideBefore: getWidgets("location.details.side.before"),
- }}
data={location}
showJSON
hasOutlet
@@ -61,5 +52,5 @@ export const LocationDetail = () => {
<LocationsFulfillmentProvidersSection location={location} />
</TwoColumnPage.Sidebar>
</TwoColumnPage>
- )
-}
+ );
+};
diff --git a/packages/admin/src/pages/locations/location-list/location-list.tsx b/packages/admin/src/pages/locations/location-list/location-list.tsx
index 49c0dd408..d654a7be2 100644
--- a/packages/admin/src/pages/locations/location-list/location-list.tsx
+++ b/packages/admin/src/pages/locations/location-list/location-list.tsx
@@ -1,28 +1,27 @@
-import { ShoppingBag, TruckFast } from "@medusajs/icons"
-import { Container, Heading } from "@medusajs/ui"
-import { useTranslation } from "react-i18next"
+import { ShoppingBag, TruckFast } from "@medusajs/icons";
+import { Container, Heading } from "@medusajs/ui";
+import { useTranslation } from "react-i18next";
-import { useStockLocations } from "../../../hooks/api/stock-locations"
-import { LOCATION_LIST_FIELDS } from "./constants"
-import { useLocationListTableColumns } from "./use-location-list-table-columns"
-import { useLocationListTableQuery } from "./use-location-list-table-query"
+import { useStockLocations } from "../../../hooks/api/stock-locations";
+import { LOCATION_LIST_FIELDS } from "./constants";
+import { useLocationListTableColumns } from "./use-location-list-table-columns";
+import { useLocationListTableQuery } from "./use-location-list-table-query";
-import { DataTable } from "../../../components/data-table"
-import { SidebarLink } from "../../../components/common/sidebar-link/sidebar-link"
-import { TwoColumnPage } from "../../../components/layout/pages"
-import { useExtension } from "../../../providers/extension-provider"
-import { keepPreviousData } from "@tanstack/react-query"
+import { DataTable } from "../../../components/data-table";
+import { SidebarLink } from "../../../components/common/sidebar-link/sidebar-link";
+import { TwoColumnPage } from "../../../components/layout/pages";
+import { keepPreviousData } from "@tanstack/react-query";
-const PAGE_SIZE = 20
-const PREFIX = "loc"
+const PAGE_SIZE = 20;
+const PREFIX = "loc";
export function LocationList() {
- const { t } = useTranslation()
+ const { t } = useTranslation();
const searchParams = useLocationListTableQuery({
pageSize: PAGE_SIZE,
prefix: PREFIX,
- })
+ });
const {
stock_locations: stockLocations = [],
@@ -37,28 +36,22 @@ export function LocationList() {
},
{
placeholderData: keepPreviousData,
- }
- )
+ },
+ );
- const columns = useLocationListTableColumns()
- const { getWidgets } = useExtension()
+ const columns = useLocationListTableColumns();
if (isError) {
- throw error
+ throw error;
}
return (
- <TwoColumnPage
- widgets={{
- after: getWidgets("location.list.after"),
- before: getWidgets("location.list.before"),
- sideAfter: getWidgets("location.list.side.after"),
- sideBefore: getWidgets("location.list.side.before"),
- }}
- showJSON
- >
+ <TwoColumnPage showJSON>
<TwoColumnPage.Main>
- <Container className="flex flex-col divide-y p-0" data-testid="location-list-container">
+ <Container
+ className="flex flex-col divide-y p-0"
+ data-testid="location-list-container"
+ >
<DataTable
data={stockLocations}
columns={columns}
@@ -96,23 +89,28 @@ export function LocationList() {
<LinksSection />
</TwoColumnPage.Sidebar>
</TwoColumnPage>
- )
+ );
}
const LinksSection = () => {
- const { t } = useTranslation()
+ const { t } = useTranslation();
return (
<Container className="p-0" data-testid="location-list-sidebar">
- <div className="flex items-center justify-between px-6 py-4" data-testid="location-list-sidebar-header">
- <Heading level="h2" data-testid="location-list-sidebar-heading">{t("stockLocations.sidebar.header")}</Heading>
+ <div
+ className="flex items-center justify-between px-6 py-4"
+ data-testid="location-list-sidebar-header"
+ >
+ <Heading level="h2" data-testid="location-list-sidebar-heading">
+ {t("stockLocations.sidebar.header")}
+ </Heading>
</div>
<SidebarLink
to="/settings/locations/shipping-profiles"
labelKey={t("stockLocations.sidebar.shippingProfiles.label")}
descriptionKey={t(
- "stockLocations.sidebar.shippingProfiles.description"
+ "stockLocations.sidebar.shippingProfiles.description",
)}
icon={<ShoppingBag />}
data-testid="location-list-sidebar-shipping-profiles-link"
@@ -121,11 +119,11 @@ const LinksSection = () => {
to="/settings/locations/shipping-option-types"
labelKey={t("stockLocations.sidebar.shippingOptionTypes.label")}
descriptionKey={t(
- "stockLocations.sidebar.shippingOptionTypes.description"
+ "stockLocations.sidebar.shippingOptionTypes.description",
)}
icon={<TruckFast />}
data-testid="location-list-sidebar-shipping-option-types-link"
/>
</Container>
- )
-}
+ );
+};
diff --git a/packages/admin/src/pages/locations/location-list/use-location-list-table-columns.tsx b/packages/admin/src/pages/locations/location-list/use-location-list-table-columns.tsx
index dafa4655a..51337f179 100644
--- a/packages/admin/src/pages/locations/location-list/use-location-list-table-columns.tsx
+++ b/packages/admin/src/pages/locations/location-list/use-location-list-table-columns.tsx
@@ -9,7 +9,7 @@ import {
import { useTranslation } from "react-i18next"
import { useMemo } from "react"
import { useNavigate } from "react-router-dom"
-import type { FetchError } from "@medusajs/js-sdk"
+import type { ClientError } from "@mercurjs/client"
import { sdk } from "@lib/client"
import { queryClient } from "@lib/query-client"
import { stockLocationsQueryKeys } from "@hooks/api"
@@ -55,7 +55,7 @@ export const useLocationListTableColumns = () => {
})
)
} catch (e) {
- toast.error((e as FetchError).message)
+ toast.error((e as ClientError).message)
}
}
diff --git a/packages/admin/src/pages/login/login.tsx b/packages/admin/src/pages/login/login.tsx
index 375a1037f..23f5c521a 100644
--- a/packages/admin/src/pages/login/login.tsx
+++ b/packages/admin/src/pages/login/login.tsx
@@ -7,7 +7,6 @@ import { Link, useLocation, useNavigate, useSearchParams } from "react-router-do
import * as z from "zod";
import AvatarBox from "@components/common/logo-box/avatar-box";
import { Form } from "@components/common/form";
-import { useExtension } from "@providers/extension-provider";
import { useSignInWithEmailPass } from "@hooks/api";
import { isFetchError } from "@lib/is-fetch-error";
@@ -20,7 +19,6 @@ export const Login = () => {
const { t } = useTranslation();
const location = useLocation();
const navigate = useNavigate();
- const { getWidgets } = useExtension();
const [searchParams] = useSearchParams()
@@ -98,9 +96,6 @@ export const Login = () => {
</Text>
</div>
<div className="flex w-full flex-col gap-y-3">
- {getWidgets("login.before").map((Component, i) => {
- return <Component key={i} />;
- })}
<Form {...form}>
<form
onSubmit={handleSubmit}
@@ -183,9 +178,6 @@ export const Login = () => {
</Button>
</form>
</Form>
- {getWidgets("login.after").map((Component, i) => {
- return <Component key={i} />;
- })}
</div>
<span
className="txt-small my-6 text-ui-fg-muted"
diff --git a/packages/admin/src/pages/orders/order-detail/components/order-payment-section/order-payment-section.tsx b/packages/admin/src/pages/orders/order-detail/components/order-payment-section/order-payment-section.tsx
index 499b40b49..1cedfcbb2 100644
--- a/packages/admin/src/pages/orders/order-detail/components/order-payment-section/order-payment-section.tsx
+++ b/packages/admin/src/pages/orders/order-detail/components/order-payment-section/order-payment-section.tsx
@@ -1,14 +1,19 @@
-import { ActionMenu } from '@components/common/action-menu';
-import DisplayId from '@components/common/display-id/display-id';
-import { useCapturePayment } from '@hooks/api';
-import { formatCurrency } from '@lib/format-currency';
-import { getLocaleAmount, getStylizedAmount } from '@lib/money-amount-helpers';
-import { getOrderPaymentStatus } from '@lib/order-helpers';
-import { getPaymentsFromOrder } from '@lib/orders';
-import { getTotalCaptured, getTotalPending } from '@lib/payment';
-import { getLoyaltyPlugin } from '@lib/plugins';
-import { ArrowDownRightMini, DocumentText, XCircle } from '@medusajs/icons';
-import type { AdminOrder, AdminPayment, HttpTypes, OrderCreditLineDTO } from '@medusajs/types';
+import { ActionMenu } from "@components/common/action-menu";
+import DisplayId from "@components/common/display-id/display-id";
+import { useCapturePayment } from "@hooks/api";
+import { formatCurrency } from "@lib/format-currency";
+import { getLocaleAmount, getStylizedAmount } from "@lib/money-amount-helpers";
+import { getOrderPaymentStatus } from "@lib/order-helpers";
+import { getPaymentsFromOrder } from "@lib/orders";
+import { getTotalCaptured, getTotalPending } from "@lib/payment";
+import { getLoyaltyPlugin } from "@lib/plugins";
+import { ArrowDownRightMini, DocumentText, XCircle } from "@medusajs/icons";
+import type {
+ AdminOrder,
+ AdminPayment,
+ HttpTypes,
+ OrderCreditLineDTO,
+} from "@medusajs/types";
import {
Badge,
Button,
@@ -18,21 +23,20 @@ import {
Text,
toast,
Tooltip,
- usePrompt
-} from '@medusajs/ui';
-import { format } from 'date-fns';
-import { Trans, useTranslation } from 'react-i18next';
+ usePrompt,
+} from "@medusajs/ui";
+import { format } from "date-fns";
+import { Trans, useTranslation } from "react-i18next";
type OrderPaymentSectionProps = {
order: HttpTypes.AdminOrder;
- plugins: HttpTypes.AdminPlugin[];
};
-export const OrderPaymentSection = ({ order, plugins }: OrderPaymentSectionProps) => {
+export const OrderPaymentSection = ({ order }: OrderPaymentSectionProps) => {
const payments = getPaymentsFromOrder(order);
const refunds = payments
- .map(payment => payment?.refunds)
+ .map((payment) => payment?.refunds)
.flat(1)
.filter(Boolean) as HttpTypes.AdminRefund[];
@@ -45,7 +49,6 @@ export const OrderPaymentSection = ({ order, plugins }: OrderPaymentSectionProps
<PaymentBreakdown
order={order}
- plugins={plugins}
payments={payments}
refunds={refunds}
currencyCode={order.currency_code}
@@ -65,11 +68,8 @@ const Header = ({ order }: { order: HttpTypes.AdminOrder }) => {
className="flex items-center justify-between px-6 py-4"
data-testid="order-payment-header"
>
- <Heading
- level="h2"
- data-testid="order-payment-heading"
- >
- {t('orders.payment.title')}
+ <Heading level="h2" data-testid="order-payment-heading">
+ {t("orders.payment.title")}
</Heading>
<StatusBadge
@@ -85,7 +85,7 @@ const Header = ({ order }: { order: HttpTypes.AdminOrder }) => {
const Refund = ({
refund,
- currencyCode
+ currencyCode,
}: {
refund: HttpTypes.AdminRefund;
currencyCode: string;
@@ -114,18 +114,11 @@ const Refund = ({
<div className="flex shrink-0 flex-row items-center gap-x-3">
<ArrowDownRightMini className="text-ui-fg-muted" />
<div>
- <Text
- size="small"
- leading="compact"
- weight="plus"
- >
- {t('orders.payment.refund')}
+ <Text size="small" leading="compact" weight="plus">
+ {t("orders.payment.refund")}
</Text>
- <Text
- size="small"
- leading="compact"
- >
- {format(new Date(refund.created_at), 'dd MMM, yyyy, HH:mm:ss')}
+ <Text size="small" leading="compact">
+ {format(new Date(refund.created_at), "dd MMM, yyyy, HH:mm:ss")}
</Text>
</div>
</div>
@@ -135,10 +128,7 @@ const Refund = ({
</div>
</div>
<div className="flex shrink-0 items-center justify-end gap-4">
- <Text
- size="small"
- leading="compact"
- >
+ <Text size="small" leading="compact">
- {getLocaleAmount(refund.amount as number, currencyCode)}
</Text>
<div className="h-7 w-5" />
@@ -151,7 +141,7 @@ const Payment = ({
order,
payment,
refunds,
- currencyCode
+ currencyCode,
}: {
order: HttpTypes.AdminOrder;
payment: HttpTypes.AdminPayment;
@@ -164,13 +154,13 @@ const Payment = ({
const handleCapture = async () => {
const res = await prompt({
- title: t('orders.payment.capture'),
- description: t('orders.payment.capturePayment', {
- amount: formatCurrency(payment.amount as number, currencyCode)
+ title: t("orders.payment.capture"),
+ description: t("orders.payment.capturePayment", {
+ amount: formatCurrency(payment.amount as number, currencyCode),
}),
- confirmText: t('actions.confirm'),
- cancelText: t('actions.cancel'),
- variant: 'confirmation'
+ confirmText: t("actions.confirm"),
+ cancelText: t("actions.cancel"),
+ variant: "confirmation",
});
if (!res) {
@@ -182,36 +172,38 @@ const Payment = ({
{
onSuccess: () => {
toast.success(
- t('orders.payment.capturePaymentSuccess', {
- amount: formatCurrency(payment.amount as number, currencyCode)
- })
+ t("orders.payment.capturePaymentSuccess", {
+ amount: formatCurrency(payment.amount as number, currencyCode),
+ }),
);
},
- onError: error => {
+ onError: (error) => {
toast.error(error.message);
- }
- }
+ },
+ },
);
};
const getPaymentStatusAttributes = (payment: AdminPayment) => {
if (payment.canceled_at) {
- return ['Canceled', 'red'];
+ return ["Canceled", "red"];
} else if (payment.captured_at) {
- return ['Captured', 'green'];
+ return ["Captured", "green"];
} else {
- return ['Pending', 'orange'];
+ return ["Pending", "orange"];
}
};
const [status, color] = getPaymentStatusAttributes(payment) as [
string,
- 'green' | 'orange' | 'red'
+ "green" | "orange" | "red",
];
- const showCapture = payment.captured_at === null && payment.canceled_at === null;
+ const showCapture =
+ payment.captured_at === null && payment.canceled_at === null;
- const totalRefunded = payment.refunds?.reduce((acc, next) => next.amount + acc, 0) ?? 0;
+ const totalRefunded =
+ payment.refunds?.reduce((acc, next) => next.amount + acc, 0) ?? 0;
return (
<div
@@ -238,8 +230,8 @@ const Payment = ({
data-testid={`order-payment-${payment.id}-date`}
>
{payment.created_at
- ? format(new Date(payment.created_at), 'dd MMM, yyyy, HH:mm:ss')
- : '-'}
+ ? format(new Date(payment.created_at), "dd MMM, yyyy, HH:mm:ss")
+ : "-"}
</Text>
</div>
<div className="hidden items-center justify-end sm:flex">
@@ -275,14 +267,16 @@ const Payment = ({
{
actions: [
{
- label: t('orders.payment.createRefund'),
+ label: t("orders.payment.createRefund"),
icon: <XCircle />,
to: `/orders/${order.id}/refund?paymentId=${payment.id}`,
disabled:
- !payment.captured_at || !!payment.canceled_at || totalRefunded >= payment.amount
- }
- ]
- }
+ !payment.captured_at ||
+ !!payment.canceled_at ||
+ totalRefunded >= payment.amount,
+ },
+ ],
+ },
]}
data-testid={`order-payment-${payment.id}-action-menu`}
/>
@@ -294,18 +288,10 @@ const Payment = ({
>
<div className="flex items-center gap-x-2">
<ArrowDownRightMini className="shrink-0 text-ui-fg-muted" />
- <Text
- size="small"
- leading="compact"
- >
+ <Text size="small" leading="compact">
<Trans
i18nKey="orders.payment.isReadyToBeCaptured"
- components={[
- <DisplayId
- key={payment.id}
- id={payment.id}
- />
- ]}
+ components={[<DisplayId key={payment.id} id={payment.id} />]}
/>
</Text>
</div>
@@ -317,17 +303,17 @@ const Payment = ({
onClick={handleCapture}
data-testid={`order-payment-${payment.id}-capture-button`}
>
- <span className="hidden sm:block">{t('orders.payment.capture')}</span>
- <span className="sm:hidden">{t('orders.payment.capture_short')}</span>
+ <span className="hidden sm:block">
+ {t("orders.payment.capture")}
+ </span>
+ <span className="sm:hidden">
+ {t("orders.payment.capture_short")}
+ </span>
</Button>
</div>
)}
- {refunds.map(refund => (
- <Refund
- key={refund.id}
- refund={refund}
- currencyCode={currencyCode}
- />
+ {refunds.map((refund) => (
+ <Refund key={refund.id} refund={refund} currencyCode={currencyCode} />
))}
</div>
);
@@ -336,19 +322,19 @@ const Payment = ({
const CreditLine = ({
creditLine,
currencyCode,
- plugins
}: {
creditLine: OrderCreditLineDTO;
currencyCode: string;
- plugins: HttpTypes.AdminPlugin[];
}) => {
- const loyaltyPlugin = getLoyaltyPlugin(plugins);
-
if (!loyaltyPlugin) {
return null;
}
- const prettyReference = creditLine.reference?.split('_').join(' ').split('-').join(' ');
+ const prettyReference = creditLine.reference
+ ?.split("_")
+ .join(" ")
+ .split("-")
+ .join(" ");
const prettyReferenceId = creditLine.reference_id ? (
<DisplayId id={creditLine.reference_id} />
@@ -364,41 +350,24 @@ const CreditLine = ({
weight="plus"
className="truncate"
>
- {loyaltyPlugin ? (
- <Text
- size="small"
- leading="compact"
- weight="plus"
- >
- Store credit refund
- </Text>
- ) : (
- <DisplayId id={creditLine.id} />
- )}
+ <DisplayId id={creditLine.id} />
</Text>
- <Text
- size="small"
- leading="compact"
- >
+ <Text size="small" leading="compact">
{creditLine.created_at
- ? format(new Date(creditLine.created_at), 'dd MMM, yyyy, HH:mm:ss')
- : '-'}
+ ? format(
+ new Date(creditLine.created_at),
+ "dd MMM, yyyy, HH:mm:ss",
+ )
+ : "-"}
</Text>
</div>
<div className="hidden items-center justify-end sm:flex">
- <Text
- size="small"
- leading="compact"
- className="capitalize"
- >
+ <Text size="small" leading="compact" className="capitalize">
{prettyReference} ({prettyReferenceId})
</Text>
</div>
<div className="flex items-center justify-end">
- <Text
- size="small"
- leading="compact"
- >
+ <Text size="small" leading="compact">
{getLocaleAmount(creditLine.amount as number, currencyCode)}
</Text>
</div>
@@ -412,40 +381,41 @@ const PaymentBreakdown = ({
payments,
refunds,
currencyCode,
- plugins
}: {
order: HttpTypes.AdminOrder;
payments: HttpTypes.AdminPayment[];
refunds: HttpTypes.AdminRefund[];
currencyCode: string;
- plugins: HttpTypes.AdminPlugin[];
}) => {
/**
* Refunds that are not associated with a payment.
*/
- const orderRefunds = refunds.filter(refund => refund.payment_id === null);
+ const orderRefunds = refunds.filter((refund) => refund.payment_id === null);
const creditLines = order.credit_lines ?? [];
- const creditLineRefunds = creditLines.filter(creditLine => (creditLine.amount as number) < 0);
+ const creditLineRefunds = creditLines.filter(
+ (creditLine) => (creditLine.amount as number) < 0,
+ );
const entries = [...orderRefunds, ...payments, ...creditLineRefunds]
.sort((a, b) => {
return (
- new Date(a.created_at as string).getTime() - new Date(b.created_at as string).getTime()
+ new Date(a.created_at as string).getTime() -
+ new Date(b.created_at as string).getTime()
);
})
- .map(entry => {
- let type = entry.id.startsWith('pay_') ? 'payment' : 'refund';
+ .map((entry) => {
+ let type = entry.id.startsWith("pay_") ? "payment" : "refund";
- if (entry.id.startsWith('ordcl_')) {
- type = 'credit_line_refund';
+ if (entry.id.startsWith("ordcl_")) {
+ type = "credit_line_refund";
}
return { event: entry, type };
}) as (
- | { type: 'payment'; event: HttpTypes.AdminPayment }
- | { type: 'refund'; event: HttpTypes.AdminRefund }
+ | { type: "payment"; event: HttpTypes.AdminPayment }
+ | { type: "refund"; event: HttpTypes.AdminRefund }
| {
- type: 'credit_line_refund';
+ type: "credit_line_refund";
event: OrderCreditLineDTO;
}
)[];
@@ -457,17 +427,19 @@ const PaymentBreakdown = ({
>
{entries.map(({ type, event }) => {
switch (type) {
- case 'payment':
+ case "payment":
return (
<Payment
key={event.id}
order={order}
payment={event}
- refunds={refunds.filter(refund => refund.payment_id === event.id)}
+ refunds={refunds.filter(
+ (refund) => refund.payment_id === event.id,
+ )}
currencyCode={currencyCode}
/>
);
- case 'refund':
+ case "refund":
return (
<Refund
key={event.id}
@@ -475,13 +447,12 @@ const PaymentBreakdown = ({
currencyCode={currencyCode}
/>
);
- case 'credit_line_refund':
+ case "credit_line_refund":
return (
<CreditLine
key={event.id}
creditLine={event}
currencyCode={currencyCode}
- plugins={plugins}
/>
);
}
@@ -503,41 +474,28 @@ const Total = ({ order }: { order: AdminOrder }) => {
className="flex items-center justify-between"
data-testid="order-payment-total-paid"
>
- <Text
- size="small"
- weight="plus"
- leading="compact"
- >
- {t('orders.payment.totalPaidByCustomer')}
+ <Text size="small" weight="plus" leading="compact">
+ {t("orders.payment.totalPaidByCustomer")}
</Text>
- <Text
- size="small"
- weight="plus"
- leading="compact"
- >
- {getStylizedAmount(getTotalCaptured(order.payment_collections), order.currency_code)}
+ <Text size="small" weight="plus" leading="compact">
+ {getStylizedAmount(
+ getTotalCaptured(order.payment_collections),
+ order.currency_code,
+ )}
</Text>
</div>
- {order.status !== 'canceled' && totalPending > 0 && (
+ {order.status !== "canceled" && totalPending > 0 && (
<div
className="flex items-center justify-between"
data-testid="order-payment-total-pending"
>
- <Text
- size="small"
- weight="plus"
- leading="compact"
- >
+ <Text size="small" weight="plus" leading="compact">
Total pending
</Text>
- <Text
- size="small"
- weight="plus"
- leading="compact"
- >
+ <Text size="small" weight="plus" leading="compact">
{getStylizedAmount(totalPending, order.currency_code)}
</Text>
</div>
diff --git a/packages/admin/src/pages/orders/order-detail/components/order-summary-section/order-summary-section.tsx b/packages/admin/src/pages/orders/order-detail/components/order-summary-section/order-summary-section.tsx
index 9bdcb01b5..54ff3aec3 100644
--- a/packages/admin/src/pages/orders/order-detail/components/order-summary-section/order-summary-section.tsx
+++ b/packages/admin/src/pages/orders/order-detail/components/order-summary-section/order-summary-section.tsx
@@ -66,13 +66,9 @@ import { formatPercentage } from "../../../../../lib/percentage-helpers.ts";
type OrderSummarySectionProps = {
order: AdminOrder;
- plugins: AdminPlugin[];
};
-export const OrderSummarySection = ({
- order,
- plugins,
-}: OrderSummarySectionProps) => {
+export const OrderSummarySection = ({ order }: OrderSummarySectionProps) => {
const { t } = useTranslation();
const prompt = usePrompt();
@@ -194,7 +190,7 @@ export const OrderSummarySection = ({
<Header order={order} orderPreview={orderPreview} />
<ItemBreakdown order={order} reservations={reservations!} />
<CostBreakdown order={order} />
- <DiscountAndTotalBreakdown order={order} plugins={plugins} />
+ <DiscountAndTotalBreakdown order={order} />
<Total order={order} />
{(showAllocateButton || showReturns || showPayment || showRefund) && (
@@ -779,17 +775,14 @@ const CostBreakdown = ({
const DiscountAndTotalBreakdown = ({
order,
- plugins,
}: {
order: AdminOrder & { region?: AdminRegion | null };
- plugins: AdminPlugin[];
}) => {
const { t } = useTranslation();
const [isDiscountOpen, setIsDiscountOpen] = useState(false);
const [isCreditLinesOpen, setIsCreditLinesOpen] = useState(false);
const creditLines = order.credit_lines ?? [];
- const loyaltyPlugin = getLoyaltyPlugin(plugins);
const discounts = useMemo(() => {
const discounts: {
@@ -887,11 +880,7 @@ const DiscountAndTotalBreakdown = ({
onClick={() => setIsCreditLinesOpen((o) => !o)}
className="flex cursor-pointer items-center gap-1"
>
- <span>
- {loyaltyPlugin
- ? t("orders.giftCardsStoreCreditLines")
- : t("orders.creditLines.title")}
- </span>
+ <span>{t("orders.creditLines.title")}</span>
<TriangleDownMini
style={{
transform: `rotate(${isCreditLinesOpen ? 0 : -90}deg)`,
diff --git a/packages/admin/src/pages/orders/order-detail/order-detail.tsx b/packages/admin/src/pages/orders/order-detail/order-detail.tsx
index 81b344171..c1a5d25ae 100644
--- a/packages/admin/src/pages/orders/order-detail/order-detail.tsx
+++ b/packages/admin/src/pages/orders/order-detail/order-detail.tsx
@@ -3,8 +3,6 @@ import { useLoaderData, useParams } from "react-router-dom";
import { TwoColumnPageSkeleton } from "../../../components/common/skeleton";
import { TwoColumnPage } from "../../../components/layout/pages";
import { useOrder, useOrderPreview } from "../../../hooks/api/orders";
-import { usePlugins } from "../../../hooks/api/plugins";
-import { useExtension } from "../../../providers/extension-provider";
import { ActiveOrderClaimSection } from "./components/active-order-claim-section";
import { ActiveOrderExchangeSection } from "./components/active-order-exchange-section";
import { ActiveOrderReturnSection } from "./components/active-order-return-section";
@@ -25,8 +23,6 @@ export const OrderDetail = () => {
>;
const { id } = useParams();
- const { getWidgets } = useExtension();
- const { plugins = [] } = usePlugins();
const { order, isLoading, isError, error } = useOrder(
id!,
@@ -35,7 +31,7 @@ export const OrderDetail = () => {
},
{
initialData,
- }
+ },
);
// TODO: Retrieve endpoints don't have an order ability, so a JS sort until this is available
@@ -54,7 +50,7 @@ export const OrderDetail = () => {
}
const { order: orderPreview, isLoading: isPreviewLoading } = useOrderPreview(
- id!
+ id!,
);
if (isLoading || !order || isPreviewLoading) {
@@ -69,12 +65,6 @@ export const OrderDetail = () => {
return (
<TwoColumnPage
- widgets={{
- after: getWidgets("order.details.after"),
- before: getWidgets("order.details.before"),
- sideAfter: getWidgets("order.details.side.after"),
- sideBefore: getWidgets("order.details.side.before"),
- }}
data={order}
showJSON
showMetadata
@@ -87,8 +77,8 @@ export const OrderDetail = () => {
<ActiveOrderExchangeSection orderPreview={orderPreview!} />
<ActiveOrderReturnSection orderPreview={orderPreview!} />
<OrderGeneralSection order={order} />
- <OrderSummarySection order={order} plugins={plugins} />
- <OrderPaymentSection order={order} plugins={plugins} />
+ <OrderSummarySection order={order} />
+ <OrderPaymentSection order={order} />
<OrderFulfillmentSection order={order} />
</TwoColumnPage.Main>
<TwoColumnPage.Sidebar data-testid="order-detail-sidebar">
diff --git a/packages/admin/src/pages/orders/order-list/components/order-list-table/configurable-order-list-table.tsx b/packages/admin/src/pages/orders/order-list/components/order-list-table/configurable-order-list-table.tsx
deleted file mode 100644
index 3110a2205..000000000
--- a/packages/admin/src/pages/orders/order-list/components/order-list-table/configurable-order-list-table.tsx
+++ /dev/null
@@ -1,17 +0,0 @@
-import { useTranslation } from "react-i18next"
-import { ConfigurableDataTable } from "../../../../../components/table/configurable-data-table"
-import { useOrderTableAdapter } from "./order-table-adapter"
-
-export const ConfigurableOrderListTable = () => {
- const { t } = useTranslation()
- const orderAdapter = useOrderTableAdapter()
-
- return (
- <ConfigurableDataTable
- adapter={orderAdapter}
- heading={t("orders.domain")}
- layout="fill"
- data-testid="orders-configurable-table"
- />
- )
-}
diff --git a/packages/admin/src/pages/orders/order-list/components/order-list-table/order-list-table.tsx b/packages/admin/src/pages/orders/order-list/components/order-list-table/order-list-table.tsx
index a20b01460..895932513 100644
--- a/packages/admin/src/pages/orders/order-list/components/order-list-table/order-list-table.tsx
+++ b/packages/admin/src/pages/orders/order-list/components/order-list-table/order-list-table.tsx
@@ -1,39 +1,30 @@
-import { _DataTable } from '@components/table/data-table';
-import { useOrders } from '@hooks/api';
-import { useOrderTableColumns } from '@hooks/table/columns';
-import { useOrderTableQuery } from '@hooks/table/query';
-import { useDataTable } from '@hooks/use-data-table';
-import { Container, Heading } from '@medusajs/ui';
-import { useFeatureFlag } from '@providers/feature-flag-provider';
-import { DEFAULT_FIELDS } from '@routes/orders/order-detail/constants';
-import { keepPreviousData } from '@tanstack/react-query';
-import { useTranslation } from 'react-i18next';
+import { _DataTable } from "@components/table/data-table";
+import { useOrders } from "@hooks/api";
+import { useOrderTableColumns } from "@hooks/table/columns";
+import { useOrderTableQuery } from "@hooks/table/query";
+import { useDataTable } from "@hooks/use-data-table";
+import { Container, Heading } from "@medusajs/ui";
+import { keepPreviousData } from "@tanstack/react-query";
+import { useTranslation } from "react-i18next";
-import { ConfigurableOrderListTable } from './configurable-order-list-table';
-import { useOrderLegacyTableFilters } from './use-order-legacy-table-filters';
+import { useOrderLegacyTableFilters } from "./use-order-legacy-table-filters";
const PAGE_SIZE = 20;
export const OrderListTable = () => {
const { t } = useTranslation();
- const isViewConfigEnabled = useFeatureFlag('view_configurations');
-
- if (isViewConfigEnabled) {
- return <ConfigurableOrderListTable />;
- }
const { searchParams, raw } = useOrderTableQuery({
- pageSize: PAGE_SIZE
+ pageSize: PAGE_SIZE,
});
const { orders, count, isError, error, isLoading } = useOrders(
{
- fields: DEFAULT_FIELDS,
- ...searchParams
+ ...searchParams,
},
{
- placeholderData: keepPreviousData
- }
+ placeholderData: keepPreviousData,
+ },
);
const filters = useOrderLegacyTableFilters();
@@ -44,7 +35,7 @@ export const OrderListTable = () => {
columns,
enablePagination: true,
count,
- pageSize: PAGE_SIZE
+ pageSize: PAGE_SIZE,
});
if (isError) {
@@ -52,35 +43,32 @@ export const OrderListTable = () => {
}
return (
- <Container
- className="divide-y p-0"
- data-testid="orders-container"
- >
+ <Container className="divide-y p-0" data-testid="orders-container">
<div
className="flex items-center justify-between px-6 py-4"
data-testid="orders-header"
>
- <Heading data-testid="orders-heading">{t('orders.domain')}</Heading>
+ <Heading data-testid="orders-heading">{t("orders.domain")}</Heading>
</div>
<div data-testid="orders-table-wrapper">
<_DataTable
columns={columns}
table={table}
pagination
- navigateTo={row => `/orders/${row.original.id}`}
+ navigateTo={(row) => `/orders/${row.original.id}`}
filters={filters}
count={count}
search
isLoading={isLoading}
pageSize={PAGE_SIZE}
orderBy={[
- { key: 'display_id', label: t('orders.fields.displayId') },
- { key: 'created_at', label: t('fields.createdAt') },
- { key: 'updated_at', label: t('fields.updatedAt') }
+ { key: "display_id", label: t("orders.fields.displayId") },
+ { key: "created_at", label: t("fields.createdAt") },
+ { key: "updated_at", label: t("fields.updatedAt") },
]}
queryObject={raw}
noRecords={{
- message: t('orders.list.noRecordsMessage')
+ message: t("orders.list.noRecordsMessage"),
}}
/>
</div>
diff --git a/packages/admin/src/pages/orders/order-list/order-list.tsx b/packages/admin/src/pages/orders/order-list/order-list.tsx
index c436a623b..9408dc24e 100644
--- a/packages/admin/src/pages/orders/order-list/order-list.tsx
+++ b/packages/admin/src/pages/orders/order-list/order-list.tsx
@@ -1,17 +1,10 @@
import { OrderListTable } from "./components/order-list-table"
import { SingleColumnPage } from "../../../components/layout/pages"
-import { useExtension } from "../../../providers/extension-provider"
export const OrderList = () => {
- const { getWidgets } = useExtension()
-
return (
<SingleColumnPage
- widgets={{
- after: getWidgets("order.list.after"),
- before: getWidgets("order.list.before"),
- }}
hasOutlet={false}
data-testid="orders-list-page"
>
diff --git a/packages/admin/src/pages/orders/order-metadata/order-metadata.tsx b/packages/admin/src/pages/orders/order-metadata/order-metadata.tsx
index 25022d39f..6cc6d0515 100644
--- a/packages/admin/src/pages/orders/order-metadata/order-metadata.tsx
+++ b/packages/admin/src/pages/orders/order-metadata/order-metadata.tsx
@@ -1,7 +1,7 @@
import { useParams } from "react-router-dom"
import { MetadataForm } from "@components/forms/metadata-form/metadata-form"
import { useOrder, useUpdateOrder } from "@hooks/api"
-import { FetchError } from "@medusajs/js-sdk"
+import { ClientError } from "@mercurjs/client"
export const OrderMetadata = () => {
const { id } = useParams()
@@ -18,7 +18,7 @@ export const OrderMetadata = () => {
const handleSubmit = async (
params: { metadata?: Record<string, unknown> | null },
- callbacks: { onSuccess?: () => void; onError?: (error: FetchError | string) => void }
+ callbacks: { onSuccess?: () => void; onError?: (error: ClientError | string) => void }
) => {
try {
const result = await mutateAsync({
@@ -28,7 +28,7 @@ export const OrderMetadata = () => {
return result
} catch (error) {
- const message = error instanceof FetchError ? error.message : 'An error occurred'
+ const message = error instanceof ClientError ? error.message : 'An error occurred'
callbacks.onError?.(message)
throw error
}
diff --git a/packages/admin/src/pages/price-lists/price-list-detail/price-list-detail.tsx b/packages/admin/src/pages/price-lists/price-list-detail/price-list-detail.tsx
index 326e93a99..04293383c 100644
--- a/packages/admin/src/pages/price-lists/price-list-detail/price-list-detail.tsx
+++ b/packages/admin/src/pages/price-lists/price-list-detail/price-list-detail.tsx
@@ -1,41 +1,30 @@
-import { useParams } from "react-router-dom"
+import { useParams } from "react-router-dom";
-import { usePriceList } from "../../../hooks/api/price-lists"
-import { PriceListConfigurationSection } from "./components/price-list-configuration-section"
-import { PriceListGeneralSection } from "./components/price-list-general-section"
-import { PriceListProductSection } from "./components/price-list-product-section"
+import { usePriceList } from "../../../hooks/api/price-lists";
+import { PriceListConfigurationSection } from "./components/price-list-configuration-section";
+import { PriceListGeneralSection } from "./components/price-list-general-section";
+import { PriceListProductSection } from "./components/price-list-product-section";
-import { TwoColumnPageSkeleton } from "../../../components/common/skeleton"
-import { TwoColumnPage } from "../../../components/layout/pages"
-import { useExtension } from "../../../providers/extension-provider"
+import { TwoColumnPageSkeleton } from "../../../components/common/skeleton";
+import { TwoColumnPage } from "../../../components/layout/pages";
export const PriceListDetails = () => {
- const { id } = useParams()
+ const { id } = useParams();
- const { price_list, isLoading, isError, error } = usePriceList(id!)
- const { getWidgets } = useExtension()
+ const { price_list, isLoading, isError, error } = usePriceList(id!);
if (isLoading || !price_list) {
return (
<TwoColumnPageSkeleton mainSections={2} sidebarSections={1} showJSON />
- )
+ );
}
if (isError) {
- throw error
+ throw error;
}
return (
- <TwoColumnPage
- widgets={{
- after: getWidgets("price_list.details.after"),
- before: getWidgets("price_list.details.before"),
- sideAfter: getWidgets("price_list.details.side.after"),
- sideBefore: getWidgets("price_list.details.side.before"),
- }}
- data={price_list}
- showJSON
- >
+ <TwoColumnPage data={price_list} showJSON>
<TwoColumnPage.Main>
<PriceListGeneralSection priceList={price_list} />
<PriceListProductSection priceList={price_list} />
@@ -44,5 +33,5 @@ export const PriceListDetails = () => {
<PriceListConfigurationSection priceList={price_list} />
</TwoColumnPage.Sidebar>
</TwoColumnPage>
- )
-}
+ );
+};
diff --git a/packages/admin/src/pages/price-lists/price-list-list/price-list-list.tsx b/packages/admin/src/pages/price-lists/price-list-list/price-list-list.tsx
index b9e8a947e..92bee16d9 100644
--- a/packages/admin/src/pages/price-lists/price-list-list/price-list-list.tsx
+++ b/packages/admin/src/pages/price-lists/price-list-list/price-list-list.tsx
@@ -1,17 +1,9 @@
import { SingleColumnPage } from "../../../components/layout/pages"
-import { useExtension } from "../../../providers/extension-provider"
import { PriceListListTable } from "./components/price-list-list-table"
export const PriceListList = () => {
- const { getWidgets } = useExtension()
-
return (
- <SingleColumnPage
- widgets={{
- after: getWidgets("price_list.list.after"),
- before: getWidgets("price_list.list.before"),
- }}
- >
+ <SingleColumnPage>
<PriceListListTable />
</SingleColumnPage>
)
diff --git a/packages/admin/src/pages/product-tags/product-tag-detail/product-tag-detail.tsx b/packages/admin/src/pages/product-tags/product-tag-detail/product-tag-detail.tsx
index 39c88ee71..8ad880e14 100644
--- a/packages/admin/src/pages/product-tags/product-tag-detail/product-tag-detail.tsx
+++ b/packages/admin/src/pages/product-tags/product-tag-detail/product-tag-detail.tsx
@@ -3,7 +3,7 @@ import { useLoaderData, useParams } from "react-router-dom"
import { SingleColumnPageSkeleton } from "../../../components/common/skeleton"
import { SingleColumnPage } from "../../../components/layout/pages"
import { useProductTag } from "../../../hooks/api"
-import { useExtension } from "../../../providers/extension-provider"
+
import { ProductTagGeneralSection } from "./components/product-tag-general-section"
import { ProductTagProductSection } from "./components/product-tag-product-section"
import { productTagLoader } from "./loader"
@@ -15,8 +15,6 @@ export const ProductTagDetail = () => {
ReturnType<typeof productTagLoader>
>
- const { getWidgets } = useExtension()
-
const { product_tag, isPending, isError, error } = useProductTag(
id!,
undefined,
@@ -35,10 +33,6 @@ export const ProductTagDetail = () => {
return (
<SingleColumnPage
- widgets={{
- after: getWidgets("product_tag.details.after"),
- before: getWidgets("product_tag.details.before"),
- }}
showJSON
showMetadata
data={product_tag}
diff --git a/packages/admin/src/pages/product-tags/product-tag-list/product-tag-list.tsx b/packages/admin/src/pages/product-tags/product-tag-list/product-tag-list.tsx
index cb14d031c..2ce4380ab 100644
--- a/packages/admin/src/pages/product-tags/product-tag-list/product-tag-list.tsx
+++ b/packages/admin/src/pages/product-tags/product-tag-list/product-tag-list.tsx
@@ -1,19 +1,12 @@
import { SingleColumnPage } from "../../../components/layout/pages"
-import { useExtension } from "../../../providers/extension-provider"
import { ProductTagListTable } from "./components/product-tag-list-table"
export const ProductTagList = () => {
- const { getWidgets } = useExtension()
-
return (
<SingleColumnPage
showMetadata={false}
showJSON={false}
hasOutlet
- widgets={{
- after: getWidgets("product_tag.list.after"),
- before: getWidgets("product_tag.list.before"),
- }}
>
<ProductTagListTable />
</SingleColumnPage>
diff --git a/packages/admin/src/pages/product-tags/product-tag-metadata/product-tag-metadata.tsx b/packages/admin/src/pages/product-tags/product-tag-metadata/product-tag-metadata.tsx
index 734cefb9d..51d1c0a8c 100644
--- a/packages/admin/src/pages/product-tags/product-tag-metadata/product-tag-metadata.tsx
+++ b/packages/admin/src/pages/product-tags/product-tag-metadata/product-tag-metadata.tsx
@@ -1,7 +1,7 @@
import { useParams } from "react-router-dom"
import { MetadataForm } from "@components/forms/metadata-form/metadata-form"
import { useProductTag, useUpdateProductTag } from "@hooks/api"
-import { FetchError } from "@medusajs/js-sdk"
+import { ClientError } from "@mercurjs/client"
export const ProductTagMetadata = () => {
const { id } = useParams()
@@ -16,7 +16,7 @@ export const ProductTagMetadata = () => {
const handleSubmit = async (
params: { metadata?: Record<string, unknown> | null },
- callbacks: { onSuccess?: () => void; onError?: (error: FetchError | string) => void }
+ callbacks: { onSuccess?: () => void; onError?: (error: ClientError | string) => void }
) => {
try {
const result = await mutateAsync({
@@ -26,7 +26,7 @@ export const ProductTagMetadata = () => {
return result
} catch (error) {
- const message = error instanceof FetchError ? error.message : 'An error occurred'
+ const message = error instanceof ClientError ? error.message : 'An error occurred'
callbacks.onError?.(message)
throw error
}
diff --git a/packages/admin/src/pages/product-types/product-type-detail/product-type-detail.tsx b/packages/admin/src/pages/product-types/product-type-detail/product-type-detail.tsx
index c405e38eb..52c302ea6 100644
--- a/packages/admin/src/pages/product-types/product-type-detail/product-type-detail.tsx
+++ b/packages/admin/src/pages/product-types/product-type-detail/product-type-detail.tsx
@@ -3,7 +3,7 @@ import { useLoaderData, useParams } from "react-router-dom"
import { SingleColumnPageSkeleton } from "../../../components/common/skeleton"
import { SingleColumnPage } from "../../../components/layout/pages"
import { useProductType } from "../../../hooks/api/product-types"
-import { useExtension } from "../../../providers/extension-provider"
+
import { ProductTypeGeneralSection } from "./components/product-type-general-section"
import { ProductTypeProductSection } from "./components/product-type-product-section"
import { productTypeLoader } from "./loader"
@@ -22,8 +22,6 @@ export const ProductTypeDetail = () => {
}
)
- const { getWidgets } = useExtension()
-
if (isPending || !product_type) {
return <SingleColumnPageSkeleton sections={2} showJSON showMetadata />
}
@@ -34,10 +32,6 @@ export const ProductTypeDetail = () => {
return (
<SingleColumnPage
- widgets={{
- after: getWidgets("product_type.details.after"),
- before: getWidgets("product_type.details.before"),
- }}
showJSON
showMetadata
data={product_type}
diff --git a/packages/admin/src/pages/product-types/product-type-list/product-type-list.tsx b/packages/admin/src/pages/product-types/product-type-list/product-type-list.tsx
index 7bca2c2b5..731c68b5a 100644
--- a/packages/admin/src/pages/product-types/product-type-list/product-type-list.tsx
+++ b/packages/admin/src/pages/product-types/product-type-list/product-type-list.tsx
@@ -1,17 +1,9 @@
import { SingleColumnPage } from "../../../components/layout/pages"
-import { useExtension } from "../../../providers/extension-provider"
import { ProductTypeListTable } from "./components/product-type-list-table"
export const ProductTypeList = () => {
- const { getWidgets } = useExtension()
-
return (
- <SingleColumnPage
- widgets={{
- after: getWidgets("product_type.list.after"),
- before: getWidgets("product_type.list.before"),
- }}
- >
+ <SingleColumnPage>
<ProductTypeListTable />
</SingleColumnPage>
)
diff --git a/packages/admin/src/pages/product-types/product-type-metadata/product-type-metadata.tsx b/packages/admin/src/pages/product-types/product-type-metadata/product-type-metadata.tsx
index fc7372ee9..c3112136e 100644
--- a/packages/admin/src/pages/product-types/product-type-metadata/product-type-metadata.tsx
+++ b/packages/admin/src/pages/product-types/product-type-metadata/product-type-metadata.tsx
@@ -1,7 +1,7 @@
import { useParams } from "react-router-dom"
import { MetadataForm } from "@components/forms/metadata-form/metadata-form"
import { useProductType, useUpdateProductType } from "@hooks/api"
-import { FetchError } from "@medusajs/js-sdk"
+import { ClientError } from "@mercurjs/client"
export const ProductTypeMetadata = () => {
const { id } = useParams()
@@ -15,7 +15,7 @@ export const ProductTypeMetadata = () => {
const handleSubmit = async (
params: { metadata?: Record<string, unknown> | null },
- callbacks: { onSuccess?: () => void; onError?: (error: FetchError | string) => void }
+ callbacks: { onSuccess?: () => void; onError?: (error: ClientError | string) => void }
) => {
try {
const result = await mutateAsync({
@@ -25,7 +25,7 @@ export const ProductTypeMetadata = () => {
return result
} catch (error) {
- const message = error instanceof FetchError ? error.message : 'An error occurred'
+ const message = error instanceof ClientError ? error.message : 'An error occurred'
callbacks.onError?.(message)
throw error
}
diff --git a/packages/admin/src/pages/product-variants/product-variant-detail/product-variant-detail.tsx b/packages/admin/src/pages/product-variants/product-variant-detail/product-variant-detail.tsx
index f5f279256..ea2bc0a15 100644
--- a/packages/admin/src/pages/product-variants/product-variant-detail/product-variant-detail.tsx
+++ b/packages/admin/src/pages/product-variants/product-variant-detail/product-variant-detail.tsx
@@ -4,7 +4,7 @@ import { useProductVariant } from "../../../hooks/api/products"
import { TwoColumnPageSkeleton } from "../../../components/common/skeleton"
import { TwoColumnPage } from "../../../components/layout/pages"
-import { useExtension } from "../../../providers/extension-provider"
+
import { VariantGeneralSection } from "./components/variant-general-section"
import {
InventorySectionPlaceholder,
@@ -29,8 +29,6 @@ export const ProductVariantDetail = () => {
}
)
- const { getWidgets } = useExtension()
-
if (isLoading || !variant) {
return (
<TwoColumnPageSkeleton
@@ -52,12 +50,6 @@ export const ProductVariantDetail = () => {
hasOutlet
showJSON
showMetadata
- widgets={{
- after: getWidgets("product_variant.details.after"),
- before: getWidgets("product_variant.details.before"),
- sideAfter: getWidgets("product_variant.details.side.after"),
- sideBefore: getWidgets("product_variant.details.side.before"),
- }}
>
<TwoColumnPage.Main>
<VariantGeneralSection variant={variant} />
diff --git a/packages/admin/src/pages/product-variants/product-variant-metadata/product-variant-metadata.tsx b/packages/admin/src/pages/product-variants/product-variant-metadata/product-variant-metadata.tsx
index 1949492f7..17af7e017 100644
--- a/packages/admin/src/pages/product-variants/product-variant-metadata/product-variant-metadata.tsx
+++ b/packages/admin/src/pages/product-variants/product-variant-metadata/product-variant-metadata.tsx
@@ -1,7 +1,7 @@
import { useParams } from "react-router-dom"
import { MetadataForm } from "@components/forms/metadata-form/metadata-form"
import { useProductVariant, useUpdateProductVariant } from "@hooks/api"
-import { FetchError } from "@medusajs/js-sdk"
+import { ClientError } from "@mercurjs/client"
export const ProductVariantMetadata = () => {
const { id, variant_id } = useParams()
@@ -22,7 +22,7 @@ export const ProductVariantMetadata = () => {
const handleSubmit = async (
params: { metadata?: Record<string, unknown> | null },
- callbacks: { onSuccess?: () => void; onError?: (error: FetchError | string) => void }
+ callbacks: { onSuccess?: () => void; onError?: (error: ClientError | string) => void }
) => {
try {
const result = await mutateAsync({
@@ -32,7 +32,7 @@ export const ProductVariantMetadata = () => {
return result
} catch (error) {
- const message = error instanceof FetchError ? error.message : 'An error occurred'
+ const message = error instanceof ClientError ? error.message : 'An error occurred'
callbacks.onError?.(message)
throw error
}
diff --git a/packages/admin/src/pages/products/product-attributes/components/product-attributes-form/product-attributes-form.tsx b/packages/admin/src/pages/products/product-attributes/components/product-attributes-form/product-attributes-form.tsx
index 1ddca9e65..39696e57e 100644
--- a/packages/admin/src/pages/products/product-attributes/components/product-attributes-form/product-attributes-form.tsx
+++ b/packages/admin/src/pages/products/product-attributes/components/product-attributes-form/product-attributes-form.tsx
@@ -1,32 +1,29 @@
-import { HttpTypes } from "@medusajs/types"
-import { Button, Input } from "@medusajs/ui"
-import { useTranslation } from "react-i18next"
-import * as zod from "zod"
-import { Form } from "../../../../../components/common/form"
-import { CountrySelect } from "../../../../../components/inputs/country-select"
-import { RouteDrawer, useRouteModal } from "../../../../../components/modals"
-import { KeyboundForm } from "../../../../../components/utilities/keybound-form"
-import {
- FormExtensionZone,
- useExtendableForm,
-} from "../../../../../dashboard-app"
-import { useUpdateProduct } from "../../../../../hooks/api/products"
-import { useExtension } from "../../../../../providers/extension-provider"
+import { HttpTypes } from "@medusajs/types";
+import { Button, Input } from "@medusajs/ui";
+import { useTranslation } from "react-i18next";
+import * as zod from "zod";
+import { Form } from "../../../../../components/common/form";
+import { CountrySelect } from "../../../../../components/inputs/country-select";
+import { RouteDrawer, useRouteModal } from "../../../../../components/modals";
+import { KeyboundForm } from "../../../../../components/utilities/keybound-form";
+import { useUpdateProduct } from "../../../../../hooks/api/products";
+import { zodResolver } from "@hookform/resolvers/zod";
+import { useForm } from "react-hook-form";
type ProductAttributesFormProps = {
- product: HttpTypes.AdminProduct
-}
+ product: HttpTypes.AdminProduct;
+};
const dimension = zod
.union([zod.string(), zod.number()])
.transform((value) => {
if (value === "") {
- return null
+ return null;
}
- return Number(value)
+ return Number(value);
})
.optional()
- .nullable()
+ .nullable();
const ProductAttributesSchema = zod.object({
weight: dimension,
@@ -36,19 +33,15 @@ const ProductAttributesSchema = zod.object({
mid_code: zod.string().optional(),
hs_code: zod.string().optional(),
origin_country: zod.string().optional(),
-})
+});
export const ProductAttributesForm = ({
product,
}: ProductAttributesFormProps) => {
- const { t } = useTranslation()
- const { handleSuccess } = useRouteModal()
- const { getFormConfigs, getFormFields } = useExtension()
+ const { t } = useTranslation();
+ const { handleSuccess } = useRouteModal();
- const configs = getFormConfigs("product", "attributes")
- const fields = getFormFields("product", "attributes")
-
- const form = useExtendableForm({
+ const form = useForm({
defaultValues: {
height: product.height ? product.height : null,
width: product.width ? product.width : null,
@@ -58,12 +51,10 @@ export const ProductAttributesForm = ({
hs_code: product.hs_code || "",
origin_country: product.origin_country || "",
},
- schema: ProductAttributesSchema,
- configs: configs,
- data: product,
- })
+ resolver: zodResolver(ProductAttributesSchema),
+ });
- const { mutateAsync, isPending } = useUpdateProduct(product.id)
+ const { mutateAsync, isPending } = useUpdateProduct(product.id);
const handleSubmit = form.handleSubmit(async (data) => {
await mutateAsync(
@@ -78,37 +69,49 @@ export const ProductAttributesForm = ({
},
{
onSuccess: () => {
- handleSuccess()
+ handleSuccess();
},
- }
- )
- })
+ },
+ );
+ });
return (
<RouteDrawer.Form form={form} data-testid="product-attributes-form">
- <KeyboundForm onSubmit={handleSubmit} className="flex h-full flex-col" data-testid="product-attributes-keybound-form">
+ <KeyboundForm
+ onSubmit={handleSubmit}
+ className="flex h-full flex-col"
+ data-testid="product-attributes-keybound-form"
+ >
<RouteDrawer.Body data-testid="product-attributes-form-body">
- <div className="flex h-full flex-col gap-y-8" data-testid="product-attributes-form-fields">
- <div className="flex flex-col gap-y-4" data-testid="product-attributes-form-main-fields">
+ <div
+ className="flex h-full flex-col gap-y-8"
+ data-testid="product-attributes-form-fields"
+ >
+ <div
+ className="flex flex-col gap-y-4"
+ data-testid="product-attributes-form-main-fields"
+ >
<Form.Field
control={form.control}
name="width"
render={({ field: { onChange, value, ...field } }) => {
return (
<Form.Item data-testid="product-attributes-form-width-item">
- <Form.Label data-testid="product-attributes-form-width-label">{t("fields.width")}</Form.Label>
+ <Form.Label data-testid="product-attributes-form-width-label">
+ {t("fields.width")}
+ </Form.Label>
<Form.Control data-testid="product-attributes-form-width-control">
<Input
type="number"
min={0}
value={value || ""}
onChange={(e) => {
- const value = e.target.value
+ const value = e.target.value;
if (value === "") {
- onChange(null)
+ onChange(null);
} else {
- onChange(parseFloat(value))
+ onChange(parseFloat(value));
}
}}
{...field}
@@ -117,7 +120,7 @@ export const ProductAttributesForm = ({
</Form.Control>
<Form.ErrorMessage data-testid="product-attributes-form-width-error" />
</Form.Item>
- )
+ );
}}
/>
<Form.Field
@@ -126,19 +129,21 @@ export const ProductAttributesForm = ({
render={({ field: { onChange, value, ...field } }) => {
return (
<Form.Item data-testid="product-attributes-form-height-item">
- <Form.Label data-testid="product-attributes-form-height-label">{t("fields.height")}</Form.Label>
+ <Form.Label data-testid="product-attributes-form-height-label">
+ {t("fields.height")}
+ </Form.Label>
<Form.Control data-testid="product-attributes-form-height-control">
<Input
type="number"
min={0}
value={value || ""}
onChange={(e) => {
- const value = e.target.value
+ const value = e.target.value;
if (value === "") {
- onChange(null)
+ onChange(null);
} else {
- onChange(Number(value))
+ onChange(Number(value));
}
}}
{...field}
@@ -147,7 +152,7 @@ export const ProductAttributesForm = ({
</Form.Control>
<Form.ErrorMessage data-testid="product-attributes-form-height-error" />
</Form.Item>
- )
+ );
}}
/>
<Form.Field
@@ -156,19 +161,21 @@ export const ProductAttributesForm = ({
render={({ field: { onChange, value, ...field } }) => {
return (
<Form.Item data-testid="product-attributes-form-length-item">
- <Form.Label data-testid="product-attributes-form-length-label">{t("fields.length")}</Form.Label>
+ <Form.Label data-testid="product-attributes-form-length-label">
+ {t("fields.length")}
+ </Form.Label>
<Form.Control data-testid="product-attributes-form-length-control">
<Input
type="number"
min={0}
value={value || ""}
onChange={(e) => {
- const value = e.target.value
+ const value = e.target.value;
if (value === "") {
- onChange(null)
+ onChange(null);
} else {
- onChange(Number(value))
+ onChange(Number(value));
}
}}
{...field}
@@ -177,7 +184,7 @@ export const ProductAttributesForm = ({
</Form.Control>
<Form.ErrorMessage data-testid="product-attributes-form-length-error" />
</Form.Item>
- )
+ );
}}
/>
<Form.Field
@@ -186,19 +193,21 @@ export const ProductAttributesForm = ({
render={({ field: { onChange, value, ...field } }) => {
return (
<Form.Item data-testid="product-attributes-form-weight-item">
- <Form.Label data-testid="product-attributes-form-weight-label">{t("fields.weight")}</Form.Label>
+ <Form.Label data-testid="product-attributes-form-weight-label">
+ {t("fields.weight")}
+ </Form.Label>
<Form.Control data-testid="product-attributes-form-weight-control">
<Input
type="number"
min={0}
value={value || ""}
onChange={(e) => {
- const value = e.target.value
+ const value = e.target.value;
if (value === "") {
- onChange(null)
+ onChange(null);
} else {
- onChange(Number(value))
+ onChange(Number(value));
}
}}
{...field}
@@ -207,7 +216,7 @@ export const ProductAttributesForm = ({
</Form.Control>
<Form.ErrorMessage data-testid="product-attributes-form-weight-error" />
</Form.Item>
- )
+ );
}}
/>
<Form.Field
@@ -216,13 +225,18 @@ export const ProductAttributesForm = ({
render={({ field }) => {
return (
<Form.Item data-testid="product-attributes-form-mid-code-item">
- <Form.Label data-testid="product-attributes-form-mid-code-label">{t("fields.midCode")}</Form.Label>
+ <Form.Label data-testid="product-attributes-form-mid-code-label">
+ {t("fields.midCode")}
+ </Form.Label>
<Form.Control data-testid="product-attributes-form-mid-code-control">
- <Input {...field} data-testid="product-attributes-form-mid-code-input" />
+ <Input
+ {...field}
+ data-testid="product-attributes-form-mid-code-input"
+ />
</Form.Control>
<Form.ErrorMessage data-testid="product-attributes-form-mid-code-error" />
</Form.Item>
- )
+ );
}}
/>
<Form.Field
@@ -231,13 +245,18 @@ export const ProductAttributesForm = ({
render={({ field }) => {
return (
<Form.Item data-testid="product-attributes-form-hs-code-item">
- <Form.Label data-testid="product-attributes-form-hs-code-label">{t("fields.hsCode")}</Form.Label>
+ <Form.Label data-testid="product-attributes-form-hs-code-label">
+ {t("fields.hsCode")}
+ </Form.Label>
<Form.Control data-testid="product-attributes-form-hs-code-control">
- <Input {...field} data-testid="product-attributes-form-hs-code-input" />
+ <Input
+ {...field}
+ data-testid="product-attributes-form-hs-code-input"
+ />
</Form.Control>
<Form.ErrorMessage data-testid="product-attributes-form-hs-code-error" />
</Form.Item>
- )
+ );
}}
/>
<Form.Field
@@ -246,32 +265,51 @@ export const ProductAttributesForm = ({
render={({ field }) => {
return (
<Form.Item data-testid="product-attributes-form-origin-country-item">
- <Form.Label data-testid="product-attributes-form-origin-country-label">{t("fields.countryOfOrigin")}</Form.Label>
+ <Form.Label data-testid="product-attributes-form-origin-country-label">
+ {t("fields.countryOfOrigin")}
+ </Form.Label>
<Form.Control data-testid="product-attributes-form-origin-country-control">
- <CountrySelect {...field} data-testid="product-attributes-form-origin-country-select" />
+ <CountrySelect
+ {...field}
+ data-testid="product-attributes-form-origin-country-select"
+ />
</Form.Control>
<Form.ErrorMessage data-testid="product-attributes-form-origin-country-error" />
</Form.Item>
- )
+ );
}}
/>
- <FormExtensionZone fields={fields} form={form} data-testid="product-attributes-form-extension-zone" />
</div>
</div>
</RouteDrawer.Body>
<RouteDrawer.Footer data-testid="product-attributes-form-footer">
- <div className="flex items-center justify-end gap-x-2" data-testid="product-attributes-form-footer-actions">
- <RouteDrawer.Close asChild data-testid="product-attributes-form-cancel-button-wrapper">
- <Button size="small" variant="secondary" data-testid="product-attributes-form-cancel-button">
+ <div
+ className="flex items-center justify-end gap-x-2"
+ data-testid="product-attributes-form-footer-actions"
+ >
+ <RouteDrawer.Close
+ asChild
+ data-testid="product-attributes-form-cancel-button-wrapper"
+ >
+ <Button
+ size="small"
+ variant="secondary"
+ data-testid="product-attributes-form-cancel-button"
+ >
{t("actions.cancel")}
</Button>
</RouteDrawer.Close>
- <Button size="small" type="submit" isLoading={isPending} data-testid="product-attributes-form-save-button">
+ <Button
+ size="small"
+ type="submit"
+ isLoading={isPending}
+ data-testid="product-attributes-form-save-button"
+ >
{t("actions.save")}
</Button>
</div>
</RouteDrawer.Footer>
</KeyboundForm>
</RouteDrawer.Form>
- )
-}
+ );
+};
diff --git a/packages/admin/src/pages/products/product-create/components/product-create-form/product-create-form.tsx b/packages/admin/src/pages/products/product-create/components/product-create-form/product-create-form.tsx
index 8e260c745..398e9a331 100644
--- a/packages/admin/src/pages/products/product-create/components/product-create-form/product-create-form.tsx
+++ b/packages/admin/src/pages/products/product-create/components/product-create-form/product-create-form.tsx
@@ -1,28 +1,26 @@
-import { HttpTypes } from "@medusajs/types"
-import { Button, ProgressStatus, ProgressTabs, toast } from "@medusajs/ui"
-import { useEffect, useMemo, useState } from "react"
-import { useWatch } from "react-hook-form"
-import { useTranslation } from "react-i18next"
+import { HttpTypes } from "@medusajs/types";
+import { Button, ProgressStatus, ProgressTabs, toast } from "@medusajs/ui";
+import { useEffect, useMemo, useState } from "react";
+import { useForm, useWatch } from "react-hook-form";
+import { useTranslation } from "react-i18next";
import {
RouteFocusModal,
useRouteModal,
-} from "../../../../../components/modals"
-import { KeyboundForm } from "../../../../../components/utilities/keybound-form"
-import { useExtendableForm } from "../../../../../dashboard-app/forms/hooks"
-import { useCreateProduct } from "../../../../../hooks/api/products"
-import { sdk } from "../../../../../lib/client"
-import { useExtension } from "../../../../../providers/extension-provider"
+} from "../../../../../components/modals";
+import { KeyboundForm } from "../../../../../components/utilities/keybound-form";
+import { useCreateProduct } from "../../../../../hooks/api/products";
+import { sdk } from "../../../../../lib/client";
import {
PRODUCT_CREATE_FORM_DEFAULTS,
ProductCreateSchema,
-} from "../../constants"
-import { normalizeProductFormValues } from "../../utils"
-import { ProductCreateDetailsForm } from "../product-create-details-form"
-import { ProductCreateInventoryKitForm } from "../product-create-inventory-kit-form"
-import { ProductCreateOrganizeForm } from "../product-create-organize-form"
-import { ProductCreateVariantsForm } from "../product-create-variants-form"
-import { useDocumentDirection } from "../../../../../hooks/use-document-direction"
-
+} from "../../constants";
+import { normalizeProductFormValues } from "../../utils";
+import { ProductCreateDetailsForm } from "../product-create-details-form";
+import { ProductCreateInventoryKitForm } from "../product-create-inventory-kit-form";
+import { ProductCreateOrganizeForm } from "../product-create-organize-form";
+import { ProductCreateVariantsForm } from "../product-create-variants-form";
+import { useDocumentDirection } from "../../../../../hooks/use-document-direction";
+import { zodResolver } from "@hookform/resolvers/zod";
enum Tab {
DETAILS = "details",
ORGANIZE = "organize",
@@ -30,16 +28,16 @@ enum Tab {
INVENTORY = "inventory",
}
-type TabState = Record<Tab, ProgressStatus>
+type TabState = Record<Tab, ProgressStatus>;
-const SAVE_DRAFT_BUTTON = "save-draft-button"
+const SAVE_DRAFT_BUTTON = "save-draft-button";
type ProductCreateFormProps = {
- defaultChannel?: HttpTypes.AdminSalesChannel
- regions: HttpTypes.AdminRegion[]
- store: HttpTypes.AdminStore
- pricePreferences: HttpTypes.AdminPricePreference[]
-}
+ defaultChannel?: HttpTypes.AdminSalesChannel;
+ regions: HttpTypes.AdminRegion[];
+ store: HttpTypes.AdminStore;
+ pricePreferences: HttpTypes.AdminPricePreference[];
+};
export const ProductCreateForm = ({
defaultChannel,
@@ -47,45 +45,42 @@ export const ProductCreateForm = ({
store,
pricePreferences,
}: ProductCreateFormProps) => {
- const [tab, setTab] = useState<Tab>(Tab.DETAILS)
+ const [tab, setTab] = useState<Tab>(Tab.DETAILS);
const [tabState, setTabState] = useState<TabState>({
[Tab.DETAILS]: "in-progress",
[Tab.ORGANIZE]: "not-started",
[Tab.VARIANTS]: "not-started",
[Tab.INVENTORY]: "not-started",
- })
-
- const { t } = useTranslation()
- const { handleSuccess } = useRouteModal()
- const { getFormConfigs } = useExtension()
- const configs = getFormConfigs("product", "create")
- const direction = useDocumentDirection()
- const form = useExtendableForm({
+ });
+
+ const { t } = useTranslation();
+ const { handleSuccess } = useRouteModal();
+ const direction = useDocumentDirection();
+ const form = useForm({
defaultValues: {
...PRODUCT_CREATE_FORM_DEFAULTS,
sales_channels: defaultChannel
? [{ id: defaultChannel.id, name: defaultChannel.name }]
: [],
},
- schema: ProductCreateSchema,
- configs,
- })
+ resolver: zodResolver(ProductCreateSchema),
+ });
- const { mutateAsync, isPending } = useCreateProduct()
+ const { mutateAsync, isPending } = useCreateProduct();
const regionsCurrencyMap = useMemo(() => {
if (!regions?.length) {
- return {}
+ return {};
}
return regions.reduce(
(acc, reg) => {
- acc[reg.id] = reg.currency_code
- return acc
+ acc[reg.id] = reg.currency_code;
+ return acc;
},
- {} as Record<string, string>
- )
- }, [regions])
+ {} as Record<string, string>,
+ );
+ }, [regions]);
/**
* TODO: Important to revisit this - use variants watch so high in the tree can cause needless rerenders of the entire page
@@ -95,52 +90,52 @@ export const ProductCreateForm = ({
const watchedVariants = useWatch({
control: form.control,
name: "variants",
- })
+ });
const showInventoryTab = useMemo(
() => watchedVariants.some((v) => v.manage_inventory && v.inventory_kit),
- [watchedVariants]
- )
+ [watchedVariants],
+ );
const handleSubmit = form.handleSubmit(async (values, e) => {
- let isDraftSubmission = false
+ let isDraftSubmission = false;
if (e?.nativeEvent instanceof SubmitEvent) {
- const submitter = e?.nativeEvent?.submitter as HTMLButtonElement
- isDraftSubmission = submitter.dataset.name === SAVE_DRAFT_BUTTON
+ const submitter = e?.nativeEvent?.submitter as HTMLButtonElement;
+ isDraftSubmission = submitter.dataset.name === SAVE_DRAFT_BUTTON;
}
- const media = values.media || []
- const payload = { ...values, media: undefined }
+ const media = values.media || [];
+ const payload = { ...values, media: undefined };
- let uploadedMedia: (HttpTypes.AdminFile & { isThumbnail: boolean })[] = []
+ let uploadedMedia: (HttpTypes.AdminFile & { isThumbnail: boolean })[] = [];
try {
if (media.length) {
- const thumbnailReq = media.find((m) => m.isThumbnail)
- const otherMediaReq = media.filter((m) => !m.isThumbnail)
+ const thumbnailReq = media.find((m) => m.isThumbnail);
+ const otherMediaReq = media.filter((m) => !m.isThumbnail);
- const fileReqs = []
+ const fileReqs = [];
if (thumbnailReq) {
fileReqs.push(
- sdk.admin.upload
- .create({ files: [thumbnailReq.file] })
- .then((r) => r.files.map((f) => ({ ...f, isThumbnail: true })))
- )
+ sdk.admin.uploads
+ .mutate({ files: [thumbnailReq.file] })
+ .then((r) => r.files.map((f) => ({ ...f, isThumbnail: true }))),
+ );
}
if (otherMediaReq?.length) {
fileReqs.push(
- sdk.admin.upload
- .create({
+ sdk.admin.uploads
+ .mutate({
files: otherMediaReq.map((m) => m.file),
})
- .then((r) => r.files.map((f) => ({ ...f, isThumbnail: false })))
- )
+ .then((r) => r.files.map((f) => ({ ...f, isThumbnail: false }))),
+ );
}
- uploadedMedia = (await Promise.all(fileReqs)).flat()
+ uploadedMedia = (await Promise.all(fileReqs)).flat();
}
} catch (error) {
if (error instanceof Error) {
- toast.error(error.message)
+ toast.error(error.message);
}
}
@@ -156,62 +151,62 @@ export const ProductCreateForm = ({
toast.success(
t("products.create.successToast", {
title: data.product.title,
- })
- )
+ }),
+ );
- handleSuccess(`../${data.product.id}`)
+ handleSuccess(`../${data.product.id}`);
},
onError: (error) => {
- toast.error(error.message)
+ toast.error(error.message);
},
- }
- )
- })
+ },
+ );
+ });
const onNext = async (currentTab: Tab) => {
- const valid = await form.trigger()
+ const valid = await form.trigger();
if (!valid) {
- return
+ return;
}
if (currentTab === Tab.DETAILS) {
- setTab(Tab.ORGANIZE)
+ setTab(Tab.ORGANIZE);
}
if (currentTab === Tab.ORGANIZE) {
- setTab(Tab.VARIANTS)
+ setTab(Tab.VARIANTS);
}
if (currentTab === Tab.VARIANTS) {
- setTab(Tab.INVENTORY)
+ setTab(Tab.INVENTORY);
}
- }
+ };
useEffect(() => {
- const currentState = { ...tabState }
+ const currentState = { ...tabState };
if (tab === Tab.DETAILS) {
- currentState[Tab.DETAILS] = "in-progress"
+ currentState[Tab.DETAILS] = "in-progress";
}
if (tab === Tab.ORGANIZE) {
- currentState[Tab.DETAILS] = "completed"
- currentState[Tab.ORGANIZE] = "in-progress"
+ currentState[Tab.DETAILS] = "completed";
+ currentState[Tab.ORGANIZE] = "in-progress";
}
if (tab === Tab.VARIANTS) {
- currentState[Tab.DETAILS] = "completed"
- currentState[Tab.ORGANIZE] = "completed"
- currentState[Tab.VARIANTS] = "in-progress"
+ currentState[Tab.DETAILS] = "completed";
+ currentState[Tab.ORGANIZE] = "completed";
+ currentState[Tab.VARIANTS] = "in-progress";
}
if (tab === Tab.INVENTORY) {
- currentState[Tab.DETAILS] = "completed"
- currentState[Tab.ORGANIZE] = "completed"
- currentState[Tab.VARIANTS] = "completed"
- currentState[Tab.INVENTORY] = "in-progress"
+ currentState[Tab.DETAILS] = "completed";
+ currentState[Tab.ORGANIZE] = "completed";
+ currentState[Tab.VARIANTS] = "completed";
+ currentState[Tab.INVENTORY] = "in-progress";
}
- setTabState({ ...currentState })
+ setTabState({ ...currentState });
// eslint-disable-next-line react-hooks/exhaustive-deps -- we only want this effect to run when the tab changes
- }, [tab])
+ }, [tab]);
return (
<RouteFocusModal.Form form={form}>
@@ -224,21 +219,21 @@ export const ProductCreateForm = ({
e.target instanceof HTMLTextAreaElement &&
!(e.metaKey || e.ctrlKey)
) {
- return
+ return;
}
- e.preventDefault()
+ e.preventDefault();
if (e.metaKey || e.ctrlKey) {
if (tab !== Tab.VARIANTS) {
- e.preventDefault()
- e.stopPropagation()
- onNext(tab)
+ e.preventDefault();
+ e.stopPropagation();
+ onNext(tab);
- return
+ return;
}
- handleSubmit()
+ handleSubmit();
}
}
}}
@@ -249,20 +244,26 @@ export const ProductCreateForm = ({
dir={direction}
value={tab}
onValueChange={async (tab) => {
- const valid = await form.trigger()
+ const valid = await form.trigger();
if (!valid) {
- return
+ return;
}
- setTab(tab as Tab)
+ setTab(tab as Tab);
}}
className="flex h-full flex-col overflow-hidden"
data-testid="product-create-form-tabs"
>
<RouteFocusModal.Header>
- <div className="-my-2 w-full border-l" data-testid="product-create-form-tabs-header">
- <ProgressTabs.List className="justify-start-start flex w-full items-center" data-testid="product-create-form-tabs-list">
+ <div
+ className="-my-2 w-full border-l"
+ data-testid="product-create-form-tabs-header"
+ >
+ <ProgressTabs.List
+ className="justify-start-start flex w-full items-center"
+ data-testid="product-create-form-tabs-list"
+ >
<ProgressTabs.Trigger
status={tabState[Tab.DETAILS]}
value={Tab.DETAILS}
@@ -300,7 +301,10 @@ export const ProductCreateForm = ({
</ProgressTabs.List>
</div>
</RouteFocusModal.Header>
- <RouteFocusModal.Body className="size-full overflow-hidden" data-testid="product-create-form-body">
+ <RouteFocusModal.Body
+ className="size-full overflow-hidden"
+ data-testid="product-create-form-body"
+ >
<ProgressTabs.Content
className="size-full overflow-y-auto"
value={Tab.DETAILS}
@@ -339,9 +343,16 @@ export const ProductCreateForm = ({
</RouteFocusModal.Body>
</ProgressTabs>
<RouteFocusModal.Footer data-testid="product-create-form-footer">
- <div className="flex items-center justify-end gap-x-2" data-testid="product-create-form-footer-actions">
+ <div
+ className="flex items-center justify-end gap-x-2"
+ data-testid="product-create-form-footer-actions"
+ >
<RouteFocusModal.Close asChild>
- <Button variant="secondary" size="small" data-testid="product-create-form-cancel-button">
+ <Button
+ variant="secondary"
+ size="small"
+ data-testid="product-create-form-cancel-button"
+ >
{t("actions.cancel")}
</Button>
</RouteFocusModal.Close>
@@ -365,15 +376,15 @@ export const ProductCreateForm = ({
</RouteFocusModal.Footer>
</KeyboundForm>
</RouteFocusModal.Form>
- )
-}
+ );
+};
type PrimaryButtonProps = {
- tab: Tab
- next: (tab: Tab) => void
- isLoading?: boolean
- showInventoryTab: boolean
-}
+ tab: Tab;
+ next: (tab: Tab) => void;
+ isLoading?: boolean;
+ showInventoryTab: boolean;
+};
const PrimaryButton = ({
tab,
@@ -381,7 +392,7 @@ const PrimaryButton = ({
isLoading,
showInventoryTab,
}: PrimaryButtonProps) => {
- const { t } = useTranslation()
+ const { t } = useTranslation();
if (
(tab === Tab.VARIANTS && !showInventoryTab) ||
@@ -399,7 +410,7 @@ const PrimaryButton = ({
>
{t("actions.publish")}
</Button>
- )
+ );
}
return (
@@ -413,5 +424,5 @@ const PrimaryButton = ({
>
{t("actions.continue")}
</Button>
- )
-}
+ );
+};
diff --git a/packages/admin/src/pages/products/product-detail/product-detail.tsx b/packages/admin/src/pages/products/product-detail/product-detail.tsx
index 9702aadce..de0c648be 100644
--- a/packages/admin/src/pages/products/product-detail/product-detail.tsx
+++ b/packages/admin/src/pages/products/product-detail/product-detail.tsx
@@ -3,7 +3,7 @@ import { useLoaderData, useParams } from "react-router-dom";
import { TwoColumnPageSkeleton } from "../../../components/common/skeleton";
import { TwoColumnPage } from "../../../components/layout/pages";
import { useProduct } from "../../../hooks/api/products";
-import { useExtension } from "../../../providers/extension-provider";
+
import { ProductAdditionalAttributeSection } from "./components/product-additional-attribute-section";
import { ProductAttributeSection } from "./components/product-attribute-section";
import { ProductGeneralSection } from "./components/product-general-section";
@@ -30,13 +30,6 @@ export const ProductDetail = () => {
},
);
- const { getWidgets } = useExtension();
-
- const after = getWidgets("product.details.after");
- const before = getWidgets("product.details.before");
- const sideAfter = getWidgets("product.details.side.after");
- const sideBefore = getWidgets("product.details.side.before");
-
if (isLoading || !product) {
return (
<TwoColumnPageSkeleton
@@ -55,12 +48,6 @@ export const ProductDetail = () => {
return (
<div data-testid="product-detail-page">
<TwoColumnPage
- widgets={{
- after,
- before,
- sideAfter,
- sideBefore,
- }}
showJSON
showMetadata
data={product}
diff --git a/packages/admin/src/pages/products/product-edit/components/edit-product-form/edit-product-form.tsx b/packages/admin/src/pages/products/product-edit/components/edit-product-form/edit-product-form.tsx
index 1aeec6662..379ead2e7 100644
--- a/packages/admin/src/pages/products/product-edit/components/edit-product-form/edit-product-form.tsx
+++ b/packages/admin/src/pages/products/product-edit/components/edit-product-form/edit-product-form.tsx
@@ -8,12 +8,11 @@ import { Form } from "../../../../../components/common/form";
import { SwitchBox } from "../../../../../components/common/switch-box";
import { RouteDrawer, useRouteModal } from "../../../../../components/modals";
import { KeyboundForm } from "../../../../../components/utilities/keybound-form";
-import { FormExtensionZone } from "../../../../../dashboard-app";
-import { useExtendableForm } from "../../../../../dashboard-app/forms/hooks";
import { useUpdateProduct } from "../../../../../hooks/api/products";
import { useDocumentDirection } from "../../../../../hooks/use-document-direction";
import { transformNullableFormData } from "../../../../../lib/form-helpers";
-import { useExtension } from "../../../../../providers/extension-provider";
+import { useForm } from "react-hook-form";
+import { zodResolver } from "@hookform/resolvers/zod";
type EditProductFormProps = {
product: HttpTypes.AdminProduct;
@@ -33,11 +32,8 @@ export const EditProductForm = ({ product }: EditProductFormProps) => {
const { t } = useTranslation();
const { handleSuccess } = useRouteModal();
const direction = useDocumentDirection();
- const { getFormFields, getFormConfigs } = useExtension();
- const fields = getFormFields("product", "edit");
- const configs = getFormConfigs("product", "edit");
- const form = useExtendableForm({
+ const form = useForm({
defaultValues: {
status: product.status,
title: product.title,
@@ -47,9 +43,7 @@ export const EditProductForm = ({ product }: EditProductFormProps) => {
description: product.description || "",
discountable: product.discountable,
},
- schema: EditProductSchema,
- configs: configs,
- data: product,
+ resolver: zodResolver(EditProductSchema),
});
const { mutateAsync, isPending } = useUpdateProduct(product.id);
@@ -298,11 +292,6 @@ export const EditProductForm = ({ product }: EditProductFormProps) => {
description={t("products.discountableHint")}
data-testid="product-edit-form-discountable-switch"
/>
- <FormExtensionZone
- fields={fields}
- form={form}
- data-testid="product-edit-form-extension-zone"
- />
</div>
</RouteDrawer.Body>
<RouteDrawer.Footer data-testid="product-edit-form-footer">
diff --git a/packages/admin/src/pages/products/product-list/components/product-list-table/configurable-product-list-table.tsx b/packages/admin/src/pages/products/product-list/components/product-list-table/configurable-product-list-table.tsx
deleted file mode 100644
index a314648b4..000000000
--- a/packages/admin/src/pages/products/product-list/components/product-list-table/configurable-product-list-table.tsx
+++ /dev/null
@@ -1,26 +0,0 @@
-import { useTranslation } from "react-i18next"
-import { Outlet, useLocation } from "react-router-dom"
-
-import { ConfigurableDataTable } from "../../../../../components/table/configurable-data-table"
-import { useProductTableAdapter } from "./product-table-adapter"
-
-export const ConfigurableProductListTable = () => {
- const { t } = useTranslation()
- const location = useLocation()
- const adapter = useProductTableAdapter()
-
- return (
- <>
- <ConfigurableDataTable
- adapter={adapter}
- heading={t("products.domain")}
- actions={[
- { label: t("actions.export"), to: `export${location.search}` },
- { label: t("actions.import"), to: `import${location.search}` },
- { label: t("actions.create"), to: "create" },
- ]}
- />
- <Outlet />
- </>
- )
-}
diff --git a/packages/admin/src/pages/products/product-list/components/product-list-table/product-list-table.tsx b/packages/admin/src/pages/products/product-list/components/product-list-table/product-list-table.tsx
index 05af2fab9..41df7871c 100644
--- a/packages/admin/src/pages/products/product-list/components/product-list-table/product-list-table.tsx
+++ b/packages/admin/src/pages/products/product-list/components/product-list-table/product-list-table.tsx
@@ -1,43 +1,35 @@
-import { PencilSquare, Trash } from "@medusajs/icons"
-import { Button, Container, Heading, toast, usePrompt } from "@medusajs/ui"
-import { keepPreviousData } from "@tanstack/react-query"
-import { createColumnHelper } from "@tanstack/react-table"
-import { useMemo } from "react"
-import { useTranslation } from "react-i18next"
-import { Link, Outlet, useLoaderData, useLocation } from "react-router-dom"
-
-import { HttpTypes } from "@medusajs/types"
-import { ActionMenu } from "../../../../../components/common/action-menu"
-import { _DataTable } from "../../../../../components/table/data-table"
+import { PencilSquare, Trash } from "@medusajs/icons";
+import { Button, Container, Heading, toast, usePrompt } from "@medusajs/ui";
+import { keepPreviousData } from "@tanstack/react-query";
+import { createColumnHelper } from "@tanstack/react-table";
+import { useMemo } from "react";
+import { useTranslation } from "react-i18next";
+import { Link, Outlet, useLoaderData, useLocation } from "react-router-dom";
+
+import { HttpTypes } from "@medusajs/types";
+import { ActionMenu } from "../../../../../components/common/action-menu";
+import { _DataTable } from "../../../../../components/table/data-table";
import {
useDeleteProduct,
useProducts,
-} from "../../../../../hooks/api/products"
-import { useProductTableColumns } from "../../../../../hooks/table/columns/use-product-table-columns"
-import { useProductTableFilters } from "../../../../../hooks/table/filters/use-product-table-filters"
-import { useProductTableQuery } from "../../../../../hooks/table/query/use-product-table-query"
-import { useDataTable } from "../../../../../hooks/use-data-table"
-import { productsLoader } from "../../loader"
-import { useFeatureFlag } from "../../../../../providers/feature-flag-provider"
-import { ConfigurableProductListTable } from "./configurable-product-list-table"
+} from "../../../../../hooks/api/products";
+import { useProductTableColumns } from "../../../../../hooks/table/columns/use-product-table-columns";
+import { useProductTableFilters } from "../../../../../hooks/table/filters/use-product-table-filters";
+import { useProductTableQuery } from "../../../../../hooks/table/query/use-product-table-query";
+import { useDataTable } from "../../../../../hooks/use-data-table";
+import { productsLoader } from "../../loader";
-const PAGE_SIZE = 20
+const PAGE_SIZE = 20;
export const ProductListTable = () => {
- const { t } = useTranslation()
- const location = useLocation()
- const isViewConfigEnabled = useFeatureFlag("view_configurations")
-
- // If feature flag is enabled, use the new configurable table
- if (isViewConfigEnabled) {
- return <ConfigurableProductListTable />
- }
+ const { t } = useTranslation();
+ const location = useLocation();
const initialData = useLoaderData() as Awaited<
ReturnType<ReturnType<typeof productsLoader>>
- >
+ >;
- const { searchParams, raw } = useProductTableQuery({ pageSize: PAGE_SIZE })
+ const { searchParams, raw } = useProductTableQuery({ pageSize: PAGE_SIZE });
const { products, count, isLoading, isError, error } = useProducts(
{
...searchParams,
@@ -46,11 +38,11 @@ export const ProductListTable = () => {
{
initialData,
placeholderData: keepPreviousData,
- }
- )
+ },
+ );
- const filters = useProductTableFilters()
- const columns = useColumns()
+ const filters = useProductTableFilters();
+ const columns = useColumns();
const { table } = useDataTable({
data: (products ?? []) as HttpTypes.AdminProduct[],
@@ -59,25 +51,60 @@ export const ProductListTable = () => {
enablePagination: true,
pageSize: PAGE_SIZE,
getRowId: (row) => row.id,
- })
+ });
if (isError) {
- throw error
+ throw error;
}
return (
<Container className="divide-y p-0" data-testid="products-list-table">
- <div className="flex items-center justify-between px-6 py-4" data-testid="products-list-header">
- <Heading level="h2" data-testid="products-list-title">{t("products.domain")}</Heading>
- <div className="flex items-center justify-center gap-x-2" data-testid="products-list-actions">
- <Button size="small" variant="secondary" asChild data-testid="products-export-button">
- <Link to={`export${location.search}`} data-testid="products-export-link">{t("actions.export")}</Link>
+ <div
+ className="flex items-center justify-between px-6 py-4"
+ data-testid="products-list-header"
+ >
+ <Heading level="h2" data-testid="products-list-title">
+ {t("products.domain")}
+ </Heading>
+ <div
+ className="flex items-center justify-center gap-x-2"
+ data-testid="products-list-actions"
+ >
+ <Button
+ size="small"
+ variant="secondary"
+ asChild
+ data-testid="products-export-button"
+ >
+ <Link
+ to={`export${location.search}`}
+ data-testid="products-export-link"
+ >
+ {t("actions.export")}
+ </Link>
</Button>
- <Button size="small" variant="secondary" asChild data-testid="products-import-button">
- <Link to={`import${location.search}`} data-testid="products-import-link">{t("actions.import")}</Link>
+ <Button
+ size="small"
+ variant="secondary"
+ asChild
+ data-testid="products-import-button"
+ >
+ <Link
+ to={`import${location.search}`}
+ data-testid="products-import-link"
+ >
+ {t("actions.import")}
+ </Link>
</Button>
- <Button size="small" variant="secondary" asChild data-testid="products-create-button">
- <Link to="create" data-testid="products-create-link">{t("actions.create")}</Link>
+ <Button
+ size="small"
+ variant="secondary"
+ asChild
+ data-testid="products-create-button"
+ >
+ <Link to="create" data-testid="products-create-link">
+ {t("actions.create")}
+ </Link>
</Button>
</div>
</div>
@@ -105,13 +132,13 @@ export const ProductListTable = () => {
</div>
<Outlet />
</Container>
- )
-}
+ );
+};
const ProductActions = ({ product }: { product: HttpTypes.AdminProduct }) => {
- const { t } = useTranslation()
- const prompt = usePrompt()
- const { mutateAsync } = useDeleteProduct(product.id)
+ const { t } = useTranslation();
+ const prompt = usePrompt();
+ const { mutateAsync } = useDeleteProduct(product.id);
const handleDelete = async () => {
const res = await prompt({
@@ -121,10 +148,10 @@ const ProductActions = ({ product }: { product: HttpTypes.AdminProduct }) => {
}),
confirmText: t("actions.delete"),
cancelText: t("actions.cancel"),
- })
+ });
if (!res) {
- return
+ return;
}
await mutateAsync(undefined, {
@@ -133,15 +160,15 @@ const ProductActions = ({ product }: { product: HttpTypes.AdminProduct }) => {
description: t("products.toasts.delete.success.description", {
title: product.title,
}),
- })
+ });
},
onError: (e) => {
toast.error(t("products.toasts.delete.error.header"), {
description: e.message,
- })
+ });
},
- })
- }
+ });
+ };
return (
<ActionMenu
@@ -167,13 +194,13 @@ const ProductActions = ({ product }: { product: HttpTypes.AdminProduct }) => {
]}
data-testid={`product-actions-${product.id}`}
/>
- )
-}
+ );
+};
-const columnHelper = createColumnHelper<HttpTypes.AdminProduct>()
+const columnHelper = createColumnHelper<HttpTypes.AdminProduct>();
const useColumns = () => {
- const base = useProductTableColumns()
+ const base = useProductTableColumns();
const columns = useMemo(
() => [
@@ -181,17 +208,20 @@ const useColumns = () => {
columnHelper.display({
id: "actions",
header: () => (
- <div className="flex h-full w-full items-center" data-testid="products-table-header-actions">
+ <div
+ className="flex h-full w-full items-center"
+ data-testid="products-table-header-actions"
+ >
<span data-testid="products-table-header-actions-text"></span>
</div>
),
cell: ({ row }) => {
- return <ProductActions product={row.original} />
+ return <ProductActions product={row.original} />;
},
}),
],
- [base]
- )
+ [base],
+ );
- return columns
-}
+ return columns;
+};
diff --git a/packages/admin/src/pages/products/product-list/product-list.tsx b/packages/admin/src/pages/products/product-list/product-list.tsx
index c1886050f..7b8a5ab0f 100644
--- a/packages/admin/src/pages/products/product-list/product-list.tsx
+++ b/packages/admin/src/pages/products/product-list/product-list.tsx
@@ -1,18 +1,10 @@
import { SingleColumnPage } from "../../../components/layout/pages"
-import { useExtension } from "../../../providers/extension-provider"
import { ProductListTable } from "./components/product-list-table"
export const ProductList = () => {
- const { getWidgets } = useExtension()
-
return (
<div data-testid="products-page">
- <SingleColumnPage
- widgets={{
- after: getWidgets("product.list.after"),
- before: getWidgets("product.list.before"),
- }}
- >
+ <SingleColumnPage>
<ProductListTable />
</SingleColumnPage>
</div>
diff --git a/packages/admin/src/pages/products/product-metadata/product-metadata.tsx b/packages/admin/src/pages/products/product-metadata/product-metadata.tsx
index 58d0a9e03..1d960127d 100644
--- a/packages/admin/src/pages/products/product-metadata/product-metadata.tsx
+++ b/packages/admin/src/pages/products/product-metadata/product-metadata.tsx
@@ -1,7 +1,7 @@
import { useParams } from "react-router-dom"
import { MetadataForm } from "@components/forms/metadata-form/metadata-form"
import { useProduct, useUpdateProduct } from "@hooks/api"
-import { FetchError } from "@medusajs/js-sdk"
+import { ClientError } from "@mercurjs/client"
export const ProductMetadata = () => {
const { id } = useParams()
@@ -15,7 +15,7 @@ export const ProductMetadata = () => {
const handleSubmit = async (
params: { metadata?: Record<string, unknown> | null },
- callbacks: { onSuccess?: () => void; onError?: (error: FetchError | string) => void }
+ callbacks: { onSuccess?: () => void; onError?: (error: ClientError | string) => void }
) => {
try {
const result = await mutateAsync({
@@ -25,7 +25,7 @@ export const ProductMetadata = () => {
return result
} catch (error) {
- const message = error instanceof FetchError ? error.message : 'An error occurred'
+ const message = error instanceof ClientError ? error.message : 'An error occurred'
callbacks.onError?.(message)
throw error
}
diff --git a/packages/admin/src/pages/products/product-organization/components/product-organization-form/product-organization-form.tsx b/packages/admin/src/pages/products/product-organization/components/product-organization-form/product-organization-form.tsx
index 78f1b8c7e..e8e6b3325 100644
--- a/packages/admin/src/pages/products/product-organization/components/product-organization-form/product-organization-form.tsx
+++ b/packages/admin/src/pages/products/product-organization/components/product-organization-form/product-organization-form.tsx
@@ -1,86 +1,77 @@
-import { HttpTypes } from "@medusajs/types"
-import { Button, toast } from "@medusajs/ui"
-import { useTranslation } from "react-i18next"
-import * as zod from "zod"
+import { HttpTypes } from "@medusajs/types";
+import { Button, toast } from "@medusajs/ui";
+import { useTranslation } from "react-i18next";
+import * as zod from "zod";
-import { Form } from "../../../../../components/common/form"
-import { Combobox } from "../../../../../components/inputs/combobox"
-import { RouteDrawer, useRouteModal } from "../../../../../components/modals"
-import { KeyboundForm } from "../../../../../components/utilities/keybound-form"
-import {
- FormExtensionZone,
- useExtendableForm,
-} from "../../../../../dashboard-app"
-import { useUpdateProduct } from "../../../../../hooks/api/products"
-import { useComboboxData } from "../../../../../hooks/use-combobox-data"
-import { sdk } from "../../../../../lib/client"
-import { useExtension } from "../../../../../providers/extension-provider"
-import { CategoryCombobox } from "../../../common/components/category-combobox"
+import { Form } from "../../../../../components/common/form";
+import { Combobox } from "../../../../../components/inputs/combobox";
+import { RouteDrawer, useRouteModal } from "../../../../../components/modals";
+import { KeyboundForm } from "../../../../../components/utilities/keybound-form";
+
+import { useUpdateProduct } from "../../../../../hooks/api/products";
+import { useComboboxData } from "../../../../../hooks/use-combobox-data";
+import { sdk } from "../../../../../lib/client";
+import { CategoryCombobox } from "../../../common/components/category-combobox";
+import { useForm } from "react-hook-form";
+import { zodResolver } from "@hookform/resolvers/zod";
type ProductOrganizationFormProps = {
- product: HttpTypes.AdminProduct
-}
+ product: HttpTypes.AdminProduct;
+};
const ProductOrganizationSchema = zod.object({
type_id: zod.string().nullable(),
collection_id: zod.string().nullable(),
category_ids: zod.array(zod.string()),
tag_ids: zod.array(zod.string()),
-})
+});
export const ProductOrganizationForm = ({
product,
}: ProductOrganizationFormProps) => {
- const { t } = useTranslation()
- const { handleSuccess } = useRouteModal()
- const { getFormConfigs, getFormFields } = useExtension()
-
- const configs = getFormConfigs("product", "organize")
- const fields = getFormFields("product", "organize")
+ const { t } = useTranslation();
+ const { handleSuccess } = useRouteModal();
const collections = useComboboxData({
queryKey: ["product_collections"],
- queryFn: (params) => sdk.admin.productCollection.list(params),
+ queryFn: (params) => sdk.admin.collections.query(params),
getOptions: (data) =>
data.collections.map((collection) => ({
label: collection.title!,
value: collection.id!,
})),
- })
+ });
const types = useComboboxData({
queryKey: ["product_types"],
- queryFn: (params) => sdk.admin.productType.list(params),
+ queryFn: (params) => sdk.admin.productTypes.query(params),
getOptions: (data) =>
data.product_types.map((type) => ({
label: type.value,
value: type.id,
})),
- })
+ });
const tags = useComboboxData({
queryKey: ["product_tags"],
- queryFn: (params) => sdk.admin.productTag.list(params),
+ queryFn: (params) => sdk.admin.productTags.query(params),
getOptions: (data) =>
data.product_tags.map((tag) => ({
label: tag.value,
value: tag.id,
})),
- })
-
- const form = useExtendableForm({
+ });
+ const form = useForm({
defaultValues: {
type_id: product.type_id ?? "",
collection_id: product.collection_id ?? "",
category_ids: product.categories?.map((c) => c.id) || [],
tag_ids: product.tags?.map((t) => t.id) || [],
},
- schema: ProductOrganizationSchema,
- configs: configs,
- data: product,
- })
+ resolver: zodResolver(ProductOrganizationSchema),
+ });
- const { mutateAsync, isPending } = useUpdateProduct(product.id)
+ const { mutateAsync, isPending } = useUpdateProduct(product.id);
const handleSubmit = form.handleSubmit(async (data) => {
await mutateAsync(
@@ -95,29 +86,39 @@ export const ProductOrganizationForm = ({
toast.success(
t("products.organization.edit.toasts.success", {
title: product.title,
- })
- )
- handleSuccess()
+ }),
+ );
+ handleSuccess();
},
onError: (error) => {
- toast.error(error.message)
+ toast.error(error.message);
},
- }
- )
- })
+ },
+ );
+ });
return (
<RouteDrawer.Form form={form} data-testid="product-organization-form">
- <KeyboundForm onSubmit={handleSubmit} className="flex h-full flex-col" data-testid="product-organization-keybound-form">
+ <KeyboundForm
+ onSubmit={handleSubmit}
+ className="flex h-full flex-col"
+ data-testid="product-organization-keybound-form"
+ >
<RouteDrawer.Body data-testid="product-organization-form-body">
- <div className="flex h-full flex-col gap-y-4" data-testid="product-organization-form-fields">
+ <div
+ className="flex h-full flex-col gap-y-4"
+ data-testid="product-organization-form-fields"
+ >
<Form.Field
control={form.control}
name="type_id"
render={({ field }) => {
return (
<Form.Item data-testid="product-organization-form-type-item">
- <Form.Label optional data-testid="product-organization-form-type-label">
+ <Form.Label
+ optional
+ data-testid="product-organization-form-type-label"
+ >
{t("products.fields.type.label")}
</Form.Label>
<Form.Control data-testid="product-organization-form-type-control">
@@ -132,7 +133,7 @@ export const ProductOrganizationForm = ({
</Form.Control>
<Form.ErrorMessage data-testid="product-organization-form-type-error" />
</Form.Item>
- )
+ );
}}
/>
<Form.Field
@@ -141,7 +142,10 @@ export const ProductOrganizationForm = ({
render={({ field }) => {
return (
<Form.Item data-testid="product-organization-form-collection-item">
- <Form.Label optional data-testid="product-organization-form-collection-label">
+ <Form.Label
+ optional
+ data-testid="product-organization-form-collection-label"
+ >
{t("products.fields.collection.label")}
</Form.Label>
<Form.Control data-testid="product-organization-form-collection-control">
@@ -156,7 +160,7 @@ export const ProductOrganizationForm = ({
</Form.Control>
<Form.ErrorMessage data-testid="product-organization-form-collection-error" />
</Form.Item>
- )
+ );
}}
/>
<Form.Field
@@ -165,15 +169,21 @@ export const ProductOrganizationForm = ({
render={({ field }) => {
return (
<Form.Item data-testid="product-organization-form-categories-item">
- <Form.Label optional data-testid="product-organization-form-categories-label">
+ <Form.Label
+ optional
+ data-testid="product-organization-form-categories-label"
+ >
{t("products.fields.categories.label")}
</Form.Label>
<Form.Control data-testid="product-organization-form-categories-control">
- <CategoryCombobox {...field} data-testid="product-organization-form-categories-combobox" />
+ <CategoryCombobox
+ {...field}
+ data-testid="product-organization-form-categories-combobox"
+ />
</Form.Control>
<Form.ErrorMessage data-testid="product-organization-form-categories-error" />
</Form.Item>
- )
+ );
}}
/>
<Form.Field
@@ -182,7 +192,10 @@ export const ProductOrganizationForm = ({
render={({ field }) => {
return (
<Form.Item data-testid="product-organization-form-tags-item">
- <Form.Label optional data-testid="product-organization-form-tags-label">
+ <Form.Label
+ optional
+ data-testid="product-organization-form-tags-label"
+ >
{t("products.fields.tags.label")}
</Form.Label>
<Form.Control data-testid="product-organization-form-tags-control">
@@ -197,25 +210,39 @@ export const ProductOrganizationForm = ({
</Form.Control>
<Form.ErrorMessage data-testid="product-organization-form-tags-error" />
</Form.Item>
- )
+ );
}}
/>
- <FormExtensionZone fields={fields} form={form} data-testid="product-organization-form-extension-zone" />
</div>
</RouteDrawer.Body>
<RouteDrawer.Footer data-testid="product-organization-form-footer">
- <div className="flex items-center justify-end gap-x-2" data-testid="product-organization-form-footer-actions">
- <RouteDrawer.Close asChild data-testid="product-organization-form-cancel-button-wrapper">
- <Button size="small" variant="secondary" data-testid="product-organization-form-cancel-button">
+ <div
+ className="flex items-center justify-end gap-x-2"
+ data-testid="product-organization-form-footer-actions"
+ >
+ <RouteDrawer.Close
+ asChild
+ data-testid="product-organization-form-cancel-button-wrapper"
+ >
+ <Button
+ size="small"
+ variant="secondary"
+ data-testid="product-organization-form-cancel-button"
+ >
{t("actions.cancel")}
</Button>
</RouteDrawer.Close>
- <Button size="small" type="submit" isLoading={isPending} data-testid="product-organization-form-save-button">
+ <Button
+ size="small"
+ type="submit"
+ isLoading={isPending}
+ data-testid="product-organization-form-save-button"
+ >
{t("actions.save")}
</Button>
</div>
</RouteDrawer.Footer>
</KeyboundForm>
</RouteDrawer.Form>
- )
-}
+ );
+};
diff --git a/packages/admin/src/pages/profile/profile-detail/profile-detail.tsx b/packages/admin/src/pages/profile/profile-detail/profile-detail.tsx
index e130e6341..b06deb27e 100644
--- a/packages/admin/src/pages/profile/profile-detail/profile-detail.tsx
+++ b/packages/admin/src/pages/profile/profile-detail/profile-detail.tsx
@@ -3,11 +3,9 @@ import { ProfileGeneralSection } from "./components/profile-general-section"
import { SingleColumnPageSkeleton } from "../../../components/common/skeleton"
import { SingleColumnPage } from "../../../components/layout/pages"
-import { useExtension } from "../../../providers/extension-provider"
export const ProfileDetail = () => {
const { user, isPending: isLoading, isError, error } = useMe()
- const { getWidgets } = useExtension()
if (isLoading || !user) {
return <SingleColumnPageSkeleton sections={1} />
@@ -19,10 +17,6 @@ export const ProfileDetail = () => {
return (
<SingleColumnPage
- widgets={{
- after: getWidgets("profile.details.after"),
- before: getWidgets("profile.details.before"),
- }}
data-testid="profile-detail-page"
>
<ProfileGeneralSection user={user} />
diff --git a/packages/admin/src/pages/promotions/common/edit-rules/components/edit-rules-wrapper/edit-rules-wrapper.tsx b/packages/admin/src/pages/promotions/common/edit-rules/components/edit-rules-wrapper/edit-rules-wrapper.tsx
index d35f6cca6..c0a58cbbe 100644
--- a/packages/admin/src/pages/promotions/common/edit-rules/components/edit-rules-wrapper/edit-rules-wrapper.tsx
+++ b/packages/admin/src/pages/promotions/common/edit-rules/components/edit-rules-wrapper/edit-rules-wrapper.tsx
@@ -1,23 +1,23 @@
-import { FetchError } from '@medusajs/js-sdk';
import {
CreatePromotionRuleDTO,
PromotionDTO,
PromotionRuleDTO,
PromotionRuleOperatorValues,
- PromotionRuleResponse
-} from '@medusajs/types';
-import { toast } from '@medusajs/ui';
+ PromotionRuleResponse,
+} from "@medusajs/types";
+import { toast } from "@medusajs/ui";
-import { useRouteModal } from '../../../../../../components/modals';
+import { useRouteModal } from "../../../../../../components/modals";
import {
usePromotionAddRules,
usePromotionRemoveRules,
usePromotionUpdateRules,
- useUpdatePromotion
-} from '../../../../../../hooks/api/promotions';
-import { RuleTypeValues } from '../../edit-rules';
-import { EditRulesForm } from '../edit-rules-form';
-import { getRuleValue } from './utils';
+ useUpdatePromotion,
+} from "../../../../../../hooks/api/promotions";
+import { RuleTypeValues } from "../../edit-rules";
+import { EditRulesForm } from "../edit-rules-form";
+import { getRuleValue } from "./utils";
+import { ClientError } from "@mercurjs/client";
type EditPromotionFormProps = {
promotion: PromotionDTO;
@@ -25,26 +25,35 @@ type EditPromotionFormProps = {
ruleType: RuleTypeValues;
};
-export const EditRulesWrapper = ({ promotion, rules, ruleType }: EditPromotionFormProps) => {
+export const EditRulesWrapper = ({
+ promotion,
+ rules,
+ ruleType,
+}: EditPromotionFormProps) => {
const { handleSuccess } = useRouteModal();
const { mutateAsync: updatePromotion } = useUpdatePromotion(promotion.id);
- const { mutateAsync: addPromotionRules } = usePromotionAddRules(promotion.id, ruleType);
-
- const { mutateAsync: removePromotionRules } = usePromotionRemoveRules(promotion.id, ruleType);
+ const { mutateAsync: addPromotionRules } = usePromotionAddRules(
+ promotion.id,
+ ruleType,
+ );
- const { mutateAsync: updatePromotionRules, isPending } = usePromotionUpdateRules(
+ const { mutateAsync: removePromotionRules } = usePromotionRemoveRules(
promotion.id,
- ruleType
+ ruleType,
);
+ const { mutateAsync: updatePromotionRules, isPending } =
+ usePromotionUpdateRules(promotion.id, ruleType);
+
const handleSubmit = (
- rulesToRemove?: { id: string; disguised: boolean; attribute: string }[]
+ rulesToRemove?: { id: string; disguised: boolean; attribute: string }[],
) => {
return async function (data: { rules: PromotionRuleResponse[] }) {
const applicationMethodData: Record<any, any> = {};
const { rules: allRules = [] } = data;
- const disguisedRules = allRules.filter(rule => rule.disguised);
- const disguisedRulesToRemove = rulesToRemove?.filter(r => r.disguised) || [];
+ const disguisedRules = allRules.filter((rule) => rule.disguised);
+ const disguisedRulesToRemove =
+ rulesToRemove?.filter((r) => r.disguised) || [];
// For all the rules that were disguised, convert them to actual values in the
// database, they are currently all under application_method. If more of these are coming
@@ -59,31 +68,35 @@ export const EditRulesWrapper = ({ promotion, rules, ruleType }: EditPromotionFo
// This variable will contain the rules that are actual rule objects, without the disguised
// objects
- const rulesData = allRules.filter(rule => !rule.disguised);
- const rulesToCreate: CreatePromotionRuleDTO[] = rulesData.filter(rule => !('id' in rule));
- const rulesToUpdate = rulesData.filter((rule: { id: string }) => typeof rule.id === 'string');
+ const rulesData = allRules.filter((rule) => !rule.disguised);
+ const rulesToCreate: CreatePromotionRuleDTO[] = rulesData.filter(
+ (rule) => !("id" in rule),
+ );
+ const rulesToUpdate = rulesData.filter(
+ (rule: { id: string }) => typeof rule.id === "string",
+ );
try {
if (Object.keys(applicationMethodData).length) {
await updatePromotion({
- application_method: applicationMethodData
+ application_method: applicationMethodData,
} as any);
}
rulesToCreate.length &&
(await addPromotionRules({
- rules: rulesToCreate.map(rule => {
+ rules: rulesToCreate.map((rule) => {
return {
attribute: rule.attribute,
operator: rule.operator,
- values: rule.values
+ values: rule.values,
} as any;
- })
+ }),
}));
rulesToRemove?.length &&
(await removePromotionRules({
- rule_ids: rulesToRemove.map(r => r.id).filter(Boolean)
+ rule_ids: rulesToRemove.map((r) => r.id).filter(Boolean),
}));
rulesToUpdate.length &&
@@ -93,17 +106,20 @@ export const EditRulesWrapper = ({ promotion, rules, ruleType }: EditPromotionFo
id: rule.id!,
attribute: rule.attribute,
operator: rule.operator as PromotionRuleOperatorValues,
- values: rule.values as unknown as string | string[]
+ values: rule.values as unknown as string | string[],
};
- })
+ }),
}));
handleSuccess();
} catch (error) {
const message =
- error instanceof FetchError
- ? error.message.replace(/(\w+_\w+)/g, match => `"${match.replace(/_/g, ' ')}"`)
- : 'An error occurred';
+ error instanceof ClientError
+ ? error.message.replace(
+ /(\w+_\w+)/g,
+ (match) => `"${match.replace(/_/g, " ")}"`,
+ )
+ : "An error occurred";
toast.error(message);
}
};
diff --git a/packages/admin/src/pages/promotions/promotion-detail/promotion-detail.tsx b/packages/admin/src/pages/promotions/promotion-detail/promotion-detail.tsx
index 464183037..5cac7b9c6 100644
--- a/packages/admin/src/pages/promotions/promotion-detail/promotion-detail.tsx
+++ b/packages/admin/src/pages/promotions/promotion-detail/promotion-detail.tsx
@@ -1,51 +1,38 @@
-import { useLoaderData, useParams } from "react-router-dom"
+import { useLoaderData, useParams } from "react-router-dom";
-import { TwoColumnPageSkeleton } from "../../../components/common/skeleton"
-import { TwoColumnPage } from "../../../components/layout/pages"
-import { usePromotion, usePromotionRules } from "../../../hooks/api/promotions"
-import { useExtension } from "../../../providers/extension-provider"
-import { CampaignSection } from "./components/campaign-section"
-import { PromotionConditionsSection } from "./components/promotion-conditions-section"
-import { PromotionGeneralSection } from "./components/promotion-general-section"
-import { promotionLoader } from "./loader"
+import { TwoColumnPageSkeleton } from "../../../components/common/skeleton";
+import { TwoColumnPage } from "../../../components/layout/pages";
+import { usePromotion, usePromotionRules } from "../../../hooks/api/promotions";
+import { CampaignSection } from "./components/campaign-section";
+import { PromotionConditionsSection } from "./components/promotion-conditions-section";
+import { PromotionGeneralSection } from "./components/promotion-general-section";
+import { promotionLoader } from "./loader";
export const PromotionDetail = () => {
const initialData = useLoaderData() as Awaited<
ReturnType<typeof promotionLoader>
- >
+ >;
- const { id } = useParams()
- const { promotion, isLoading } = usePromotion(id!, { initialData })
- const query: Record<string, string> = {}
+ const { id } = useParams();
+ const { promotion, isLoading } = usePromotion(id!, { initialData });
+ const query: Record<string, string> = {};
if (promotion?.type === "buyget") {
- query.promotion_type = promotion.type
+ query.promotion_type = promotion.type;
}
- const { rules } = usePromotionRules(id!, "rules", query)
- const { rules: targetRules } = usePromotionRules(id!, "target-rules", query)
- const { rules: buyRules } = usePromotionRules(id!, "buy-rules", query)
-
- const { getWidgets } = useExtension()
+ const { rules } = usePromotionRules(id!, "rules", query);
+ const { rules: targetRules } = usePromotionRules(id!, "target-rules", query);
+ const { rules: buyRules } = usePromotionRules(id!, "buy-rules", query);
if (isLoading || !promotion) {
return (
<TwoColumnPageSkeleton mainSections={3} sidebarSections={1} showJSON />
- )
+ );
}
return (
- <TwoColumnPage
- data={promotion}
- widgets={{
- after: getWidgets("promotion.details.after"),
- before: getWidgets("promotion.details.before"),
- sideAfter: getWidgets("promotion.details.side.after"),
- sideBefore: getWidgets("promotion.details.side.before"),
- }}
- hasOutlet
- showJSON
- >
+ <TwoColumnPage data={promotion} hasOutlet showJSON>
<TwoColumnPage.Main>
<PromotionGeneralSection promotion={promotion} />
<PromotionConditionsSection rules={rules || []} ruleType={"rules"} />
@@ -68,5 +55,5 @@ export const PromotionDetail = () => {
<CampaignSection campaign={promotion.campaign!} />
</TwoColumnPage.Sidebar>
</TwoColumnPage>
- )
-}
+ );
+};
diff --git a/packages/admin/src/pages/promotions/promotion-list/promotions-list.tsx b/packages/admin/src/pages/promotions/promotion-list/promotions-list.tsx
index 793b8b4cb..fc7c16b8a 100644
--- a/packages/admin/src/pages/promotions/promotion-list/promotions-list.tsx
+++ b/packages/admin/src/pages/promotions/promotion-list/promotions-list.tsx
@@ -1,17 +1,9 @@
import { SingleColumnPage } from "../../../components/layout/pages"
-import { useExtension } from "../../../providers/extension-provider"
import { PromotionListTable } from "./components/promotion-list-table"
export const PromotionsList = () => {
- const { getWidgets } = useExtension()
-
return (
- <SingleColumnPage
- widgets={{
- before: getWidgets("promotion.list.before"),
- after: getWidgets("promotion.list.after"),
- }}
- >
+ <SingleColumnPage>
<PromotionListTable />
</SingleColumnPage>
)
diff --git a/packages/admin/src/pages/refund-reasons/refund-reason-list/refund-reason-list.tsx b/packages/admin/src/pages/refund-reasons/refund-reason-list/refund-reason-list.tsx
index bec203bbe..e510bd4b2 100644
--- a/packages/admin/src/pages/refund-reasons/refund-reason-list/refund-reason-list.tsx
+++ b/packages/admin/src/pages/refund-reasons/refund-reason-list/refund-reason-list.tsx
@@ -1,19 +1,12 @@
import { SingleColumnPage } from "../../../components/layout/pages"
-import { useExtension } from "../../../providers/extension-provider"
import { RefundReasonListTable } from "./components/refund-reason-list-table"
export const RefundReasonList = () => {
- const { getWidgets } = useExtension()
-
return (
<SingleColumnPage
showMetadata={false}
showJSON={false}
hasOutlet
- widgets={{
- after: getWidgets("refund_reason.list.after"),
- before: getWidgets("refund_reason.list.before"),
- }}
>
<RefundReasonListTable />
</SingleColumnPage>
diff --git a/packages/admin/src/pages/regions/region-detail/region-detail.tsx b/packages/admin/src/pages/regions/region-detail/region-detail.tsx
index ac22cf780..100995ccb 100644
--- a/packages/admin/src/pages/regions/region-detail/region-detail.tsx
+++ b/packages/admin/src/pages/regions/region-detail/region-detail.tsx
@@ -1,22 +1,21 @@
-import { useLoaderData, useParams } from "react-router-dom"
+import { useLoaderData, useParams } from "react-router-dom";
-import { useRegion } from "../../../hooks/api/regions"
-import { RegionCountrySection } from "./components/region-country-section"
-import { RegionGeneralSection } from "./components/region-general-section"
-import { regionLoader } from "./loader"
+import { useRegion } from "../../../hooks/api/regions";
+import { RegionCountrySection } from "./components/region-country-section";
+import { RegionGeneralSection } from "./components/region-general-section";
+import { regionLoader } from "./loader";
-import { SingleColumnPageSkeleton } from "../../../components/common/skeleton"
-import { SingleColumnPage } from "../../../components/layout/pages"
-import { usePricePreferences } from "../../../hooks/api/price-preferences"
-import { useExtension } from "../../../providers/extension-provider"
-import { REGION_DETAIL_FIELDS } from "./constants"
+import { SingleColumnPageSkeleton } from "../../../components/common/skeleton";
+import { SingleColumnPage } from "../../../components/layout/pages";
+import { usePricePreferences } from "../../../hooks/api/price-preferences";
+import { REGION_DETAIL_FIELDS } from "./constants";
export const RegionDetail = () => {
const initialData = useLoaderData() as Awaited<
ReturnType<typeof regionLoader>
- >
+ >;
- const { id } = useParams()
+ const { id } = useParams();
const {
region,
isPending: isLoading,
@@ -27,8 +26,8 @@ export const RegionDetail = () => {
{ fields: REGION_DETAIL_FIELDS },
{
initialData,
- }
- )
+ },
+ );
const {
price_preferences: pricePreferences,
@@ -40,38 +39,28 @@ export const RegionDetail = () => {
attribute: "region_id",
value: id,
},
- { enabled: !!region }
- )
-
- const { getWidgets } = useExtension()
+ { enabled: !!region },
+ );
if (isLoading || isLoadingPreferences || !region) {
- return <SingleColumnPageSkeleton sections={2} showJSON showMetadata />
+ return <SingleColumnPageSkeleton sections={2} showJSON showMetadata />;
}
if (isRegionError) {
- throw regionError
+ throw regionError;
}
if (isPreferencesError) {
- throw preferencesError
+ throw preferencesError;
}
return (
- <SingleColumnPage
- widgets={{
- before: getWidgets("region.details.before"),
- after: getWidgets("region.details.after"),
- }}
- data={region}
- showMetadata
- showJSON
- >
+ <SingleColumnPage data={region} showMetadata showJSON>
<RegionGeneralSection
region={region}
pricePreferences={pricePreferences ?? []}
/>
<RegionCountrySection region={region} />
</SingleColumnPage>
- )
-}
+ );
+};
diff --git a/packages/admin/src/pages/regions/region-list/region-list.tsx b/packages/admin/src/pages/regions/region-list/region-list.tsx
index 6d6f81217..b35b0c7c0 100644
--- a/packages/admin/src/pages/regions/region-list/region-list.tsx
+++ b/packages/admin/src/pages/regions/region-list/region-list.tsx
@@ -1,17 +1,9 @@
import { SingleColumnPage } from "../../../components/layout/pages"
-import { useExtension } from "../../../providers/extension-provider"
import { RegionListTable } from "./components/region-list-table"
export const RegionList = () => {
- const { getWidgets } = useExtension()
-
return (
- <SingleColumnPage
- widgets={{
- before: getWidgets("region.list.before"),
- after: getWidgets("region.list.after"),
- }}
- >
+ <SingleColumnPage>
<RegionListTable />
</SingleColumnPage>
)
diff --git a/packages/admin/src/pages/regions/region-metadata/region-metadata.tsx b/packages/admin/src/pages/regions/region-metadata/region-metadata.tsx
index a7b5eae6a..2e07cc914 100644
--- a/packages/admin/src/pages/regions/region-metadata/region-metadata.tsx
+++ b/packages/admin/src/pages/regions/region-metadata/region-metadata.tsx
@@ -3,7 +3,7 @@ import { useParams } from "react-router-dom"
import { MetadataForm } from "@components/forms/metadata-form"
import { RouteDrawer } from "@components/modals"
import { useRegion, useUpdateRegion } from "@hooks/api"
-import { FetchError } from "@medusajs/js-sdk"
+import { ClientError } from "@mercurjs/client"
export const RegionMetadata = () => {
const { id } = useParams()
@@ -17,7 +17,7 @@ export const RegionMetadata = () => {
const handleSubmit = async (
params: { metadata?: Record<string, unknown> | null },
- callbacks: { onSuccess?: () => void; onError?: (error: FetchError | string) => void }
+ callbacks: { onSuccess?: () => void; onError?: (error: ClientError | string) => void }
) => {
try {
const result = await mutateAsync({
@@ -27,7 +27,7 @@ export const RegionMetadata = () => {
return result
} catch (error) {
- const message = error instanceof FetchError ? error.message : 'An error occurred'
+ const message = error instanceof ClientError ? error.message : 'An error occurred'
callbacks.onError?.(message)
throw error
}
diff --git a/packages/admin/src/pages/reservations/reservation-detail/reservation-detail.tsx b/packages/admin/src/pages/reservations/reservation-detail/reservation-detail.tsx
index 6f4628dbb..78e6e5a0b 100644
--- a/packages/admin/src/pages/reservations/reservation-detail/reservation-detail.tsx
+++ b/packages/admin/src/pages/reservations/reservation-detail/reservation-detail.tsx
@@ -4,7 +4,7 @@ import { TwoColumnPageSkeleton } from "../../../components/common/skeleton"
import { TwoColumnPage } from "../../../components/layout/pages"
import { useInventoryItem } from "../../../hooks/api"
import { useReservationItem } from "../../../hooks/api/reservations"
-import { useExtension } from "../../../providers/extension-provider"
+
import { InventoryItemGeneralSection } from "../../inventory/inventory-detail/components/inventory-item-general-section"
import { ReservationGeneralSection } from "./components/reservation-general-section"
import { reservationItemLoader } from "./loader"
@@ -31,8 +31,6 @@ export const ReservationDetail = () => {
{ enabled: !!reservation?.inventory_item?.id! }
)
- const { getWidgets } = useExtension()
-
if (isLoading || !reservation) {
return (
<TwoColumnPageSkeleton
@@ -50,12 +48,6 @@ export const ReservationDetail = () => {
return (
<TwoColumnPage
- widgets={{
- before: getWidgets("reservation.details.before"),
- after: getWidgets("reservation.details.after"),
- sideBefore: getWidgets("reservation.details.side.before"),
- sideAfter: getWidgets("reservation.details.side.after"),
- }}
data={reservation}
showJSON
showMetadata
diff --git a/packages/admin/src/pages/reservations/reservation-list/reservation-list.tsx b/packages/admin/src/pages/reservations/reservation-list/reservation-list.tsx
index b619cbfb8..15695c5bb 100644
--- a/packages/admin/src/pages/reservations/reservation-list/reservation-list.tsx
+++ b/packages/admin/src/pages/reservations/reservation-list/reservation-list.tsx
@@ -1,17 +1,9 @@
import { SingleColumnPage } from "../../../components/layout/pages"
-import { useExtension } from "../../../providers/extension-provider"
import { ReservationListTable } from "./components/reservation-list-table"
export const ReservationList = () => {
- const { getWidgets } = useExtension()
-
return (
- <SingleColumnPage
- widgets={{
- before: getWidgets("reservation.list.before"),
- after: getWidgets("reservation.list.after"),
- }}
- >
+ <SingleColumnPage>
<ReservationListTable />
</SingleColumnPage>
)
diff --git a/packages/admin/src/pages/reservations/reservation-metadata/reservation-metadata.tsx b/packages/admin/src/pages/reservations/reservation-metadata/reservation-metadata.tsx
index 15d693b07..857b9b331 100644
--- a/packages/admin/src/pages/reservations/reservation-metadata/reservation-metadata.tsx
+++ b/packages/admin/src/pages/reservations/reservation-metadata/reservation-metadata.tsx
@@ -1,40 +1,41 @@
-import { useParams } from "react-router-dom"
+import { useParams } from "react-router-dom";
-import {
- useReservationItem,
- useUpdateReservationItem,
-} from "@hooks/api"
-import { MetadataForm } from "@components/forms/metadata-form"
-import { RouteDrawer } from "@components/modals"
-import { FetchError } from "@medusajs/js-sdk"
+import { useReservationItem, useUpdateReservationItem } from "@hooks/api";
+import { MetadataForm } from "@components/forms/metadata-form";
+import { RouteDrawer } from "@components/modals";
+import { ClientError } from "@mercurjs/client";
export const ReservationMetadata = () => {
- const { id } = useParams()
+ const { id } = useParams();
- const { reservation, isPending, isError, error } = useReservationItem(id!)
- const { mutateAsync, isPending: isMutating } = useUpdateReservationItem(id!)
+ const { reservation, isPending, isError, error } = useReservationItem(id!);
+ const { mutateAsync, isPending: isMutating } = useUpdateReservationItem(id!);
if (isError) {
- throw error
+ throw error;
}
const handleSubmit = async (
params: { metadata?: Record<string, unknown> | null },
- callbacks: { onSuccess?: () => void; onError?: (error: FetchError | string) => void }
+ callbacks: {
+ onSuccess?: () => void;
+ onError?: (error: ClientError | string) => void;
+ },
) => {
try {
const result = await mutateAsync({
metadata: params.metadata === undefined ? undefined : params.metadata,
- })
- callbacks.onSuccess?.()
+ });
+ callbacks.onSuccess?.();
- return result
+ return result;
} catch (error) {
- const message = error instanceof FetchError ? error.message : 'An error occurred'
- callbacks.onError?.(message)
- throw error
+ const message =
+ error instanceof ClientError ? error.message : "An error occurred";
+ callbacks.onError?.(message);
+ throw error;
}
- }
+ };
return (
<RouteDrawer>
@@ -45,5 +46,5 @@ export const ReservationMetadata = () => {
metadata={reservation?.metadata}
/>
</RouteDrawer>
- )
-}
+ );
+};
diff --git a/packages/admin/src/pages/return-reasons/return-reason-list/return-reason-list.tsx b/packages/admin/src/pages/return-reasons/return-reason-list/return-reason-list.tsx
index e1dbd289a..648a4f563 100644
--- a/packages/admin/src/pages/return-reasons/return-reason-list/return-reason-list.tsx
+++ b/packages/admin/src/pages/return-reasons/return-reason-list/return-reason-list.tsx
@@ -1,19 +1,12 @@
import { SingleColumnPage } from "../../../components/layout/pages"
-import { useExtension } from "../../../providers/extension-provider"
import { ReturnReasonListTable } from "./components/return-reason-list-table"
export const ReturnReasonList = () => {
- const { getWidgets } = useExtension()
-
return (
<SingleColumnPage
showMetadata={false}
showJSON={false}
hasOutlet
- widgets={{
- after: getWidgets("return_reason.list.after"),
- before: getWidgets("return_reason.list.before"),
- }}
>
<ReturnReasonListTable />
</SingleColumnPage>
diff --git a/packages/admin/src/pages/sales-channels/sales-channel-detail/sales-channel-detail.tsx b/packages/admin/src/pages/sales-channels/sales-channel-detail/sales-channel-detail.tsx
index 9480fb64b..463f58ef8 100644
--- a/packages/admin/src/pages/sales-channels/sales-channel-detail/sales-channel-detail.tsx
+++ b/packages/admin/src/pages/sales-channels/sales-channel-detail/sales-channel-detail.tsx
@@ -3,7 +3,6 @@ import { useLoaderData, useParams } from "react-router-dom"
import { SingleColumnPageSkeleton } from "../../../components/common/skeleton"
import { SingleColumnPage } from "../../../components/layout/pages"
import { useSalesChannel } from "../../../hooks/api/sales-channels"
-import { useExtension } from "../../../providers/extension-provider"
import { SalesChannelGeneralSection } from "./components/sales-channel-general-section"
import { SalesChannelProductSection } from "./components/sales-channel-product-section"
import { salesChannelLoader } from "./loader"
@@ -18,18 +17,12 @@ export const SalesChannelDetail = () => {
initialData,
})
- const { getWidgets } = useExtension()
-
if (isLoading || !sales_channel) {
return <SingleColumnPageSkeleton sections={2} showJSON showMetadata />
}
return (
<SingleColumnPage
- widgets={{
- before: getWidgets("sales_channel.details.before"),
- after: getWidgets("sales_channel.details.after"),
- }}
showJSON
showMetadata
data={sales_channel}
diff --git a/packages/admin/src/pages/sales-channels/sales-channel-list/sales-channel-list.tsx b/packages/admin/src/pages/sales-channels/sales-channel-list/sales-channel-list.tsx
index 8c7dc58a6..44eb5aceb 100644
--- a/packages/admin/src/pages/sales-channels/sales-channel-list/sales-channel-list.tsx
+++ b/packages/admin/src/pages/sales-channels/sales-channel-list/sales-channel-list.tsx
@@ -1,17 +1,10 @@
import { SalesChannelListTable } from "./components/sales-channel-list-table"
import { SingleColumnPage } from "../../../components/layout/pages"
-import { useExtension } from "../../../providers/extension-provider"
export const SalesChannelList = () => {
- const { getWidgets } = useExtension()
-
return (
<SingleColumnPage
- widgets={{
- before: getWidgets("sales_channel.list.before"),
- after: getWidgets("sales_channel.list.after"),
- }}
hasOutlet
>
<SalesChannelListTable />
diff --git a/packages/admin/src/pages/sales-channels/sales-channel-metadata/sales-channel-metadata.tsx b/packages/admin/src/pages/sales-channels/sales-channel-metadata/sales-channel-metadata.tsx
index 366624e34..96182544b 100644
--- a/packages/admin/src/pages/sales-channels/sales-channel-metadata/sales-channel-metadata.tsx
+++ b/packages/admin/src/pages/sales-channels/sales-channel-metadata/sales-channel-metadata.tsx
@@ -1,42 +1,46 @@
-import { useParams } from "react-router-dom"
+import { useParams } from "react-router-dom";
-import { RouteDrawer } from "@components/modals"
-import { MetadataForm } from "@components/forms/metadata-form"
-import { useSalesChannel, useUpdateSalesChannel } from "@hooks/api"
-import { FetchError } from "@medusajs/js-sdk"
+import { RouteDrawer } from "@components/modals";
+import { MetadataForm } from "@components/forms/metadata-form";
+import { useSalesChannel, useUpdateSalesChannel } from "@hooks/api";
+import { ClientError } from "@mercurjs/client";
export const SalesChannelMetadata = () => {
- const { id } = useParams()
+ const { id } = useParams();
const {
sales_channel: salesChannel,
isPending,
isError,
error,
- } = useSalesChannel(id!)
- const { mutateAsync, isPending: isMutating } = useUpdateSalesChannel(id!)
+ } = useSalesChannel(id!);
+ const { mutateAsync, isPending: isMutating } = useUpdateSalesChannel(id!);
if (isError) {
- throw error
+ throw error;
}
const handleSubmit = async (
params: { metadata?: Record<string, unknown> | null },
- callbacks: { onSuccess?: () => void; onError?: (error: FetchError | string) => void }
+ callbacks: {
+ onSuccess?: () => void;
+ onError?: (error: ClientError | string) => void;
+ },
) => {
try {
const result = await mutateAsync({
metadata: params.metadata === undefined ? undefined : params.metadata,
- })
- callbacks.onSuccess?.()
+ });
+ callbacks.onSuccess?.();
- return result
+ return result;
} catch (error) {
- const message = error instanceof FetchError ? error.message : 'An error occurred'
- callbacks.onError?.(message)
- throw error
+ const message =
+ error instanceof ClientError ? error.message : "An error occurred";
+ callbacks.onError?.(message);
+ throw error;
}
- }
+ };
return (
<RouteDrawer data-testid="sales-channel-metadata-drawer">
@@ -47,5 +51,5 @@ export const SalesChannelMetadata = () => {
metadata={salesChannel?.metadata}
/>
</RouteDrawer>
- )
-}
+ );
+};
diff --git a/packages/admin/src/pages/sellers/seller-list/seller-list.tsx b/packages/admin/src/pages/sellers/seller-list/seller-list.tsx
index 5065d6dc4..32f608210 100644
--- a/packages/admin/src/pages/sellers/seller-list/seller-list.tsx
+++ b/packages/admin/src/pages/sellers/seller-list/seller-list.tsx
@@ -1,52 +1,29 @@
-import { useMemo, useState } from "react";
+import { useMemo } from "react";
-import { PencilSquare, User } from "@medusajs/icons";
-import {
- Button,
- Container,
- Drawer,
- Heading,
- Input,
- Label,
- Text,
- toast,
- usePrompt,
-} from "@medusajs/ui";
+import { PencilSquare } from "@medusajs/icons";
+import { Container, Heading } from "@medusajs/ui";
import { keepPreviousData } from "@tanstack/react-query";
import { createColumnHelper } from "@tanstack/react-table";
-import { useNavigate } from "react-router-dom";
-import type { VendorSeller } from "@custom-types/seller";
+import { ActionMenu } from "../../../components/common/action-menu";
+import { _DataTable } from "../../../components/table/data-table";
-import { ActionsButton } from "@components/common/actions-button";
-import { _DataTable } from "@components/table/data-table";
-
-import {
- useInviteSeller,
- useSellers,
- useUpdateSeller,
-} from "@hooks/api/sellers";
-import { useSellersTableColumns } from "@hooks/table/columns/use-seller-table-columns";
-import { useSellersTableQuery } from "@hooks/table/query";
-import { useDataTable } from "@hooks/use-data-table";
-
-import { validateEmail } from "@lib/validate-email";
+import { useSellers } from "../../../hooks/api/sellers";
+import { useSellersTableColumns } from "../../../hooks/table/columns/use-seller-table-columns";
+import { useSellersTableQuery } from "../../../hooks/table/query";
+import { useDataTable } from "../../../hooks/use-data-table";
+import { SellerDTO } from "@mercurjs/types";
const PAGE_SIZE = 10;
-type SellersProps = VendorSeller & { store_status: string };
-
export const SellersList = () => {
- const [open, setOpen] = useState(false);
- const [email, setEmail] = useState("");
const { searchParams, raw } = useSellersTableQuery({
pageSize: PAGE_SIZE,
});
const { sellers, count, isLoading } = useSellers(
{
- fields: "id,email,name,created_at,store_status",
...searchParams,
},
{
@@ -54,8 +31,6 @@ export const SellersList = () => {
},
);
- const { mutateAsync: inviteSeller } = useInviteSeller();
-
const columns = useColumns();
const { table } = useDataTable({
@@ -67,124 +42,52 @@ export const SellersList = () => {
getRowId: (row) => row?.id || "",
});
- const handleInvite = async () => {
- try {
- const isValid = validateEmail(email);
- if (!isValid) {
- return;
- }
-
- await inviteSeller({ email });
- toast.success("Invited!");
- setOpen(false);
- setEmail("");
- } catch {
- toast.error("Error!");
- }
- };
-
return (
- <Container data-testid="seller-list-container">
- <div className="flex items-center justify-between" data-testid="seller-list-header">
- <div>
- <Heading data-testid="seller-list-heading">Sellers</Heading>
- </div>
- <Drawer
- open={open}
- onOpenChange={(openChanged) => setOpen(openChanged)}
- data-testid="seller-list-invite-drawer"
- >
- <Drawer.Trigger
- onClick={() => {
- setOpen(true);
- }}
- asChild
- >
- <Button data-testid="seller-list-invite-button">Invite</Button>
- </Drawer.Trigger>
- <Drawer.Content data-testid="seller-list-invite-drawer-content">
- <Drawer.Header data-testid="seller-list-invite-drawer-header" />
- <Drawer.Body data-testid="seller-list-invite-drawer-body">
- <Heading data-testid="seller-list-invite-drawer-title">Invite Seller</Heading>
- <Text className="text-ui-fg-subtle" size="small" data-testid="seller-list-invite-drawer-description">
- Invite a new seller to your store
- </Text>
- <div className="mt-6 flex flex-col gap-2" data-testid="seller-list-invite-drawer-email-field">
- <Label data-testid="seller-list-invite-drawer-email-label">Email</Label>
- <Input
- placeholder="Email"
- value={email}
- onChange={(e) => setEmail(e.target.value)}
- data-testid="seller-list-invite-drawer-email-input"
- />
- </div>
- <div className="flex justify-end" data-testid="seller-list-invite-drawer-footer">
- <Button className="mt-6" onClick={handleInvite} data-testid="seller-list-invite-drawer-submit-button">
- Invite
- </Button>
- </div>
- </Drawer.Body>
- </Drawer.Content>
- </Drawer>
- </div>
- <div className="flex size-full flex-col overflow-hidden">
- <_DataTable
- table={table}
- columns={columns}
- count={count ?? 0}
- pageSize={PAGE_SIZE}
- isLoading={isLoading}
- queryObject={raw}
- search
- pagination
- navigateTo={(row) => `/sellers/${row.id}`}
- orderBy={[
- { key: "email", label: "Email" },
- { key: "name", label: "Name" },
- { key: "created_at", label: "Created" },
- ]}
- />
+ <Container className="divide-y p-0">
+ <div className="flex items-center justify-between px-6 py-4">
+ <Heading level="h2">Sellers</Heading>
</div>
+ <_DataTable
+ table={table}
+ columns={columns}
+ count={count ?? 0}
+ pageSize={PAGE_SIZE}
+ isLoading={isLoading}
+ queryObject={raw}
+ search
+ pagination
+ navigateTo={(row) => `/sellers/${row.original.id}`}
+ orderBy={[
+ { key: "email", label: "Email" },
+ { key: "name", label: "Name" },
+ { key: "created_at", label: "Created" },
+ ]}
+ />
</Container>
);
};
-const columnHelper = createColumnHelper<VendorSeller>();
-
-const useColumns = () => {
- const dialog = usePrompt();
-
- const navigate = useNavigate();
+const columnHelper = createColumnHelper<SellerDTO>();
- const { mutateAsync: suspendSeller } = useUpdateSeller();
-
- const handleSuspend = async (seller: SellersProps) => {
- const res = await dialog({
- title:
- seller.store_status === "SUSPENDED"
- ? "Activate account"
- : "Suspend account",
- description:
- seller.store_status === "SUSPENDED"
- ? "Are you sure you want to activate this account?"
- : "Are you sure you want to suspend this account?",
- verificationText: seller.email || seller.name || "",
- });
-
- if (!res) {
- return;
- }
-
- if (seller.store_status === "SUSPENDED") {
- await suspendSeller({ id: seller.id, data: { store_status: "ACTIVE" } });
- } else {
- await suspendSeller({
- id: seller.id,
- data: { store_status: "SUSPENDED" },
- });
- }
- };
+const SellerActions = ({ seller }: { seller: SellerDTO }) => {
+ return (
+ <ActionMenu
+ groups={[
+ {
+ actions: [
+ {
+ icon: <PencilSquare />,
+ label: "Edit",
+ to: `/sellers/${seller.id}/edit`,
+ },
+ ],
+ },
+ ]}
+ />
+ );
+};
+const useColumns = () => {
const base = useSellersTableColumns();
const columns = useMemo(
@@ -192,28 +95,7 @@ const useColumns = () => {
...base,
columnHelper.display({
id: "actions",
- cell: ({ row }) => {
- return (
- <ActionsButton
- data-testid={`seller-list-row-actions-${row.original.id}`}
- actions={[
- {
- label: "Edit",
- onClick: () => navigate(`/sellers/${row.original.id}/edit`),
- icon: <PencilSquare />,
- },
- {
- label:
- row.original.store_status === "SUSPENDED"
- ? "Activate account"
- : "Suspend account",
- onClick: () => handleSuspend(row.original as SellersProps),
- icon: <User />,
- },
- ]}
- />
- );
- },
+ cell: ({ row }) => <SellerActions seller={row.original} />,
}),
],
[base],
diff --git a/packages/admin/src/pages/shipping-option-types/shipping-option-type-detail/shipping-option-type-detail.tsx b/packages/admin/src/pages/shipping-option-types/shipping-option-type-detail/shipping-option-type-detail.tsx
index b6c7afbdd..fb721f7d7 100644
--- a/packages/admin/src/pages/shipping-option-types/shipping-option-type-detail/shipping-option-type-detail.tsx
+++ b/packages/admin/src/pages/shipping-option-types/shipping-option-type-detail/shipping-option-type-detail.tsx
@@ -3,7 +3,6 @@ import { useLoaderData, useParams } from "react-router-dom"
import { SingleColumnPageSkeleton } from "../../../components/common/skeleton"
import { SingleColumnPage } from "../../../components/layout/pages"
import { useShippingOptionType } from "../../../hooks/api"
-import { useExtension } from "../../../providers/extension-provider"
import { ShippingOptionTypeGeneralSection } from "./components/shipping-option-type-general-section"
import { shippingOptionTypeLoader } from "./loader"
@@ -18,8 +17,6 @@ export const ShippingOptionTypeDetail = () => {
initialData,
})
- const { getWidgets } = useExtension()
-
if (isPending || !shipping_option_type) {
return <SingleColumnPageSkeleton sections={2} showJSON showMetadata />
}
@@ -30,10 +27,6 @@ export const ShippingOptionTypeDetail = () => {
return (
<SingleColumnPage
- widgets={{
- after: getWidgets("shipping_option_type.details.after"),
- before: getWidgets("shipping_option_type.details.before"),
- }}
showJSON
showMetadata
data={shipping_option_type}
diff --git a/packages/admin/src/pages/shipping-option-types/shipping-option-type-list/shipping-option-type-list.tsx b/packages/admin/src/pages/shipping-option-types/shipping-option-type-list/shipping-option-type-list.tsx
index bb2eed60d..bec697fcb 100644
--- a/packages/admin/src/pages/shipping-option-types/shipping-option-type-list/shipping-option-type-list.tsx
+++ b/packages/admin/src/pages/shipping-option-types/shipping-option-type-list/shipping-option-type-list.tsx
@@ -1,17 +1,9 @@
import { SingleColumnPage } from "../../../components/layout/pages"
-import { useExtension } from "../../../providers/extension-provider"
import { ShippingOptionTypeListTable } from "./components/shipping-option-type-list-table"
export const ShippingOptionTypeList = () => {
- const { getWidgets } = useExtension()
-
return (
- <SingleColumnPage
- widgets={{
- after: getWidgets("shipping_option_type.list.after"),
- before: getWidgets("shipping_option_type.list.before"),
- }}
- >
+ <SingleColumnPage>
<ShippingOptionTypeListTable />
</SingleColumnPage>
)
diff --git a/packages/admin/src/pages/shipping-profiles/shipping-profile-detail/shipping-profile-detail.tsx b/packages/admin/src/pages/shipping-profiles/shipping-profile-detail/shipping-profile-detail.tsx
index c557dd8d1..e065c2934 100644
--- a/packages/admin/src/pages/shipping-profiles/shipping-profile-detail/shipping-profile-detail.tsx
+++ b/packages/admin/src/pages/shipping-profiles/shipping-profile-detail/shipping-profile-detail.tsx
@@ -5,7 +5,6 @@ import { useShippingProfile } from "../../../hooks/api/shipping-profiles"
import { ShippingProfileGeneralSection } from "./components/shipping-profile-general-section"
import { SingleColumnPage } from "../../../components/layout/pages"
-import { useExtension } from "../../../providers/extension-provider"
import { shippingProfileLoader } from "./loader"
export const ShippingProfileDetail = () => {
@@ -21,8 +20,6 @@ export const ShippingProfileDetail = () => {
{ initialData }
)
- const { getWidgets } = useExtension()
-
if (isLoading || !shipping_profile) {
return <SingleColumnPageSkeleton sections={1} showJSON showMetadata />
}
@@ -33,10 +30,6 @@ export const ShippingProfileDetail = () => {
return (
<SingleColumnPage
- widgets={{
- before: getWidgets("shipping_profile.details.before"),
- after: getWidgets("shipping_profile.details.after"),
- }}
showMetadata
showJSON
data={shipping_profile}
diff --git a/packages/admin/src/pages/shipping-profiles/shipping-profile-metadata/shipping-profile-metadata.tsx b/packages/admin/src/pages/shipping-profiles/shipping-profile-metadata/shipping-profile-metadata.tsx
index 375548cf1..ec5ed35d0 100644
--- a/packages/admin/src/pages/shipping-profiles/shipping-profile-metadata/shipping-profile-metadata.tsx
+++ b/packages/admin/src/pages/shipping-profiles/shipping-profile-metadata/shipping-profile-metadata.tsx
@@ -4,7 +4,7 @@ import {
useShippingProfile,
useUpdateShippingProfile,
} from "@hooks/api"
-import { FetchError } from "@medusajs/js-sdk"
+import { ClientError } from "@mercurjs/client"
export const ShippingProfileMetadata = () => {
const { shipping_profile_id } = useParams()
@@ -22,7 +22,7 @@ export const ShippingProfileMetadata = () => {
const handleSubmit = async (
params: { metadata?: Record<string, unknown> | null },
- callbacks: { onSuccess?: () => void; onError?: (error: FetchError | string) => void }
+ callbacks: { onSuccess?: () => void; onError?: (error: ClientError | string) => void }
) => {
try {
const result = await mutateAsync({
@@ -32,7 +32,7 @@ export const ShippingProfileMetadata = () => {
return result
} catch (error) {
- const message = error instanceof FetchError ? error.message : 'An error occurred'
+ const message = error instanceof ClientError ? error.message : 'An error occurred'
callbacks.onError?.(message)
throw error
}
diff --git a/packages/admin/src/pages/shipping-profiles/shipping-profiles-list/shipping-profile-list.tsx b/packages/admin/src/pages/shipping-profiles/shipping-profiles-list/shipping-profile-list.tsx
index 7beabfc42..e04f768d2 100644
--- a/packages/admin/src/pages/shipping-profiles/shipping-profiles-list/shipping-profile-list.tsx
+++ b/packages/admin/src/pages/shipping-profiles/shipping-profiles-list/shipping-profile-list.tsx
@@ -1,17 +1,9 @@
import { SingleColumnPage } from "../../../components/layout/pages"
-import { useExtension } from "../../../providers/extension-provider"
import { ShippingProfileListTable } from "./components/shipping-profile-list-table"
export const ShippingProfileList = () => {
- const { getWidgets } = useExtension()
-
return (
- <SingleColumnPage
- widgets={{
- before: getWidgets("shipping_profile.list.before"),
- after: getWidgets("shipping_profile.list.after"),
- }}
- >
+ <SingleColumnPage>
<ShippingProfileListTable />
</SingleColumnPage>
)
diff --git a/packages/admin/src/pages/store/store-detail/store-detail.tsx b/packages/admin/src/pages/store/store-detail/store-detail.tsx
index fd75a4b52..cfa791d7c 100644
--- a/packages/admin/src/pages/store/store-detail/store-detail.tsx
+++ b/packages/admin/src/pages/store/store-detail/store-detail.tsx
@@ -6,7 +6,6 @@ import { storeLoader } from "./loader"
import { SingleColumnPageSkeleton } from "../../../components/common/skeleton"
import { SingleColumnPage } from "../../../components/layout/pages"
-import { useExtension } from "../../../providers/extension-provider"
import { StoreCurrencySection } from "./components/store-currency-section"
export const StoreDetail = () => {
@@ -16,8 +15,6 @@ export const StoreDetail = () => {
initialData,
})
- const { getWidgets } = useExtension()
-
if (isPending || !store) {
return <SingleColumnPageSkeleton sections={2} showJSON showMetadata />
}
@@ -28,10 +25,6 @@ export const StoreDetail = () => {
return (
<SingleColumnPage
- widgets={{
- before: getWidgets("store.details.before"),
- after: getWidgets("store.details.after"),
- }}
data={store}
hasOutlet
showMetadata
diff --git a/packages/admin/src/pages/store/store-metadata/store-metadata.tsx b/packages/admin/src/pages/store/store-metadata/store-metadata.tsx
index 539e0a7fb..9a4fbad72 100644
--- a/packages/admin/src/pages/store/store-metadata/store-metadata.tsx
+++ b/packages/admin/src/pages/store/store-metadata/store-metadata.tsx
@@ -1,7 +1,7 @@
import { MetadataForm } from "@components/forms/metadata-form"
import { RouteDrawer } from "@components/modals"
import { useStore, useUpdateStore } from "@hooks/api"
-import { FetchError } from "@medusajs/js-sdk"
+import { ClientError } from "@mercurjs/client"
export const StoreMetadata = () => {
const { store, isPending, isError, error } = useStore()
@@ -14,7 +14,7 @@ export const StoreMetadata = () => {
const handleSubmit = async (
params: { metadata?: Record<string, unknown> | null },
- callbacks: { onSuccess?: () => void; onError?: (error: FetchError | string) => void }
+ callbacks: { onSuccess?: () => void; onError?: (error: ClientError | string) => void }
) => {
if (!store?.id) {
callbacks.onError?.('Store ID not available')
@@ -30,7 +30,7 @@ export const StoreMetadata = () => {
return result
} catch (error) {
- const message = error instanceof FetchError ? error.message : 'An error occurred'
+ const message = error instanceof ClientError ? error.message : 'An error occurred'
callbacks.onError?.(message)
throw error
}
diff --git a/packages/admin/src/pages/tax-regions/common/components/tax-override-card/tax-override-card.tsx b/packages/admin/src/pages/tax-regions/common/components/tax-override-card/tax-override-card.tsx
index b309b86ab..a5570b19a 100644
--- a/packages/admin/src/pages/tax-regions/common/components/tax-override-card/tax-override-card.tsx
+++ b/packages/admin/src/pages/tax-regions/common/components/tax-override-card/tax-override-card.tsx
@@ -17,7 +17,7 @@ import { Collapsible as RadixCollapsible } from "radix-ui"
import { ComponentPropsWithoutRef } from "react"
import { useTranslation } from "react-i18next"
-import { FetchError } from "@medusajs/js-sdk"
+import { ClientError } from "@mercurjs/client"
import { ActionMenu } from "../../../../../components/common/action-menu"
import { useProductTypes } from "../../../../../hooks/api/product-types"
import { useProducts } from "../../../../../hooks/api/products"
@@ -275,7 +275,7 @@ const useReferenceValues = (
isPending: boolean
additional: number
isError: boolean
- error: FetchError | null
+ error: ClientError | null
} => {
const products = useProducts(
{
diff --git a/packages/admin/src/pages/tax-regions/tax-region-detail/tax-region-detail.tsx b/packages/admin/src/pages/tax-regions/tax-region-detail/tax-region-detail.tsx
index b7827575d..c91aa2671 100644
--- a/packages/admin/src/pages/tax-regions/tax-region-detail/tax-region-detail.tsx
+++ b/packages/admin/src/pages/tax-regions/tax-region-detail/tax-region-detail.tsx
@@ -1,53 +1,42 @@
-import { useLoaderData, useParams } from "react-router-dom"
-import { useState } from "react"
+import { useLoaderData, useParams } from "react-router-dom";
+import { useState } from "react";
-import { SingleColumnPage } from "../../../components/layout/pages"
-import { useTaxRegion } from "../../../hooks/api/tax-regions"
-import { TaxRegionDetailSection } from "./components/tax-region-detail-section"
-import { TaxRegionProvinceSection } from "./components/tax-region-province-section"
+import { SingleColumnPage } from "../../../components/layout/pages";
+import { useTaxRegion } from "../../../hooks/api/tax-regions";
+import { TaxRegionDetailSection } from "./components/tax-region-detail-section";
+import { TaxRegionProvinceSection } from "./components/tax-region-province-section";
-import { SingleColumnPageSkeleton } from "../../../components/common/skeleton"
-import { useExtension } from "../../../providers/extension-provider"
-import { TaxRegionOverrideSection } from "./components/tax-region-override-section"
-import { TaxRegionSublevelAlert } from "./components/tax-region-sublevel-alert"
-import { TaxRegionProviderSection } from "./tax-region-provider-section"
-import { taxRegionLoader } from "./loader"
+import { SingleColumnPageSkeleton } from "../../../components/common/skeleton";
+import { TaxRegionOverrideSection } from "./components/tax-region-override-section";
+import { TaxRegionSublevelAlert } from "./components/tax-region-sublevel-alert";
+import { TaxRegionProviderSection } from "./tax-region-provider-section";
+import { taxRegionLoader } from "./loader";
export const TaxRegionDetail = () => {
- const { id } = useParams()
- const [showSublevelRegions, setShowSublevelRegions] = useState(false)
+ const { id } = useParams();
+ const [showSublevelRegions, setShowSublevelRegions] = useState(false);
const initialData = useLoaderData() as Awaited<
ReturnType<typeof taxRegionLoader>
- >
+ >;
const {
tax_region: taxRegion,
isLoading,
isError,
error,
- } = useTaxRegion(id!, undefined, { initialData })
-
- const { getWidgets } = useExtension()
+ } = useTaxRegion(id!, undefined, { initialData });
if (isLoading || !taxRegion) {
- return <SingleColumnPageSkeleton sections={4} showJSON />
+ return <SingleColumnPageSkeleton sections={4} showJSON />;
}
if (isError) {
- throw error
+ throw error;
}
return (
- <SingleColumnPage
- data={taxRegion}
- showJSON
- showMetadata
- widgets={{
- after: getWidgets("tax.details.after"),
- before: getWidgets("tax.details.before"),
- }}
- >
+ <SingleColumnPage data={taxRegion} showJSON showMetadata>
<TaxRegionSublevelAlert
taxRegion={taxRegion}
showSublevelRegions={showSublevelRegions}
@@ -61,5 +50,5 @@ export const TaxRegionDetail = () => {
<TaxRegionOverrideSection taxRegion={taxRegion} />
<TaxRegionProviderSection taxRegion={taxRegion} />
</SingleColumnPage>
- )
-}
+ );
+};
diff --git a/packages/admin/src/pages/tax-regions/tax-region-list/tax-region-list.tsx b/packages/admin/src/pages/tax-regions/tax-region-list/tax-region-list.tsx
index 054ae44e5..8dbd65cd1 100644
--- a/packages/admin/src/pages/tax-regions/tax-region-list/tax-region-list.tsx
+++ b/packages/admin/src/pages/tax-regions/tax-region-list/tax-region-list.tsx
@@ -1,16 +1,9 @@
import { SingleColumnPage } from "../../../components/layout/pages"
-import { useExtension } from "../../../providers/extension-provider"
import { TaxRegionListView } from "./components/tax-region-list-view"
export const TaxRegionsList = () => {
- const { getWidgets } = useExtension()
-
return (
<SingleColumnPage
- widgets={{
- before: getWidgets("tax.list.before"),
- after: getWidgets("tax.list.after"),
- }}
hasOutlet
>
<TaxRegionListView />
diff --git a/packages/admin/src/pages/tax-regions/tax-region-metadata/tax-region-metadata.tsx b/packages/admin/src/pages/tax-regions/tax-region-metadata/tax-region-metadata.tsx
index 0a56ac521..fa8bf7103 100644
--- a/packages/admin/src/pages/tax-regions/tax-region-metadata/tax-region-metadata.tsx
+++ b/packages/admin/src/pages/tax-regions/tax-region-metadata/tax-region-metadata.tsx
@@ -3,7 +3,7 @@ import { useParams } from "react-router-dom"
import { useTaxRegion, useUpdateTaxRegion } from "@hooks/api"
import { MetadataForm } from "@components/forms/metadata-form"
import { RouteDrawer } from "@components/modals"
-import { FetchError } from "@medusajs/js-sdk"
+import { ClientError } from "@mercurjs/client"
export const TaxRegionMetadata = () => {
const { id } = useParams()
@@ -17,7 +17,7 @@ export const TaxRegionMetadata = () => {
const handleSubmit = async (
params: { metadata?: Record<string, unknown> | null },
- callbacks: { onSuccess?: () => void; onError?: (error: FetchError | string) => void }
+ callbacks: { onSuccess?: () => void; onError?: (error: ClientError | string) => void }
) => {
try {
const result = await mutateAsync({
@@ -27,7 +27,7 @@ export const TaxRegionMetadata = () => {
return result
} catch (error) {
- const message = error instanceof FetchError ? error.message : 'An error occurred'
+ const message = error instanceof ClientError ? error.message : 'An error occurred'
callbacks.onError?.(message)
throw error
}
diff --git a/packages/admin/src/pages/tax-regions/tax-region-province-detail/tax-region-detail.tsx b/packages/admin/src/pages/tax-regions/tax-region-province-detail/tax-region-detail.tsx
index 2c4d79092..d7c835774 100644
--- a/packages/admin/src/pages/tax-regions/tax-region-province-detail/tax-region-detail.tsx
+++ b/packages/admin/src/pages/tax-regions/tax-region-province-detail/tax-region-detail.tsx
@@ -5,7 +5,6 @@ import { useTaxRegion } from "../../../hooks/api/tax-regions"
import { TaxRegionProvinceDetailSection } from "./components/tax-region-province-detail-section"
import { SingleColumnPageSkeleton } from "../../../components/common/skeleton"
-import { useExtension } from "../../../providers/extension-provider"
import { TaxRegionProvinceOverrideSection } from "./components/tax-region-province-override-section"
import { taxRegionLoader } from "./loader"
@@ -23,8 +22,6 @@ export const TaxRegionDetail = () => {
error,
} = useTaxRegion(province_id!, undefined, { initialData })
- const { getWidgets } = useExtension()
-
if (isLoading || !taxRegion) {
return <SingleColumnPageSkeleton sections={2} showJSON />
}
@@ -37,10 +34,6 @@ export const TaxRegionDetail = () => {
<SingleColumnPage
data={taxRegion}
showJSON
- widgets={{
- after: getWidgets("tax.details.after"),
- before: getWidgets("tax.details.before"),
- }}
>
<TaxRegionProvinceDetailSection taxRegion={taxRegion} />
<TaxRegionProvinceOverrideSection taxRegion={taxRegion} />
diff --git a/packages/admin/src/pages/users/user-detail/user-detail.tsx b/packages/admin/src/pages/users/user-detail/user-detail.tsx
index 5bd07259c..ac6f47d64 100644
--- a/packages/admin/src/pages/users/user-detail/user-detail.tsx
+++ b/packages/admin/src/pages/users/user-detail/user-detail.tsx
@@ -6,7 +6,6 @@ import { userLoader } from "./loader"
import { SingleColumnPageSkeleton } from "../../../components/common/skeleton"
import { SingleColumnPage } from "../../../components/layout/pages"
-import { useExtension } from "../../../providers/extension-provider"
export const UserDetail = () => {
const initialData = useLoaderData() as Awaited<ReturnType<typeof userLoader>>
@@ -21,8 +20,6 @@ export const UserDetail = () => {
initialData,
})
- const { getWidgets } = useExtension()
-
if (isLoading || !user) {
return <SingleColumnPageSkeleton sections={1} showJSON showMetadata />
}
@@ -36,10 +33,6 @@ export const UserDetail = () => {
data={user}
showJSON
showMetadata
- widgets={{
- after: getWidgets("user.details.after"),
- before: getWidgets("user.details.before"),
- }}
>
<UserGeneralSection user={user} />
</SingleColumnPage>
diff --git a/packages/admin/src/pages/users/user-list/user-list.tsx b/packages/admin/src/pages/users/user-list/user-list.tsx
index f2f1e7726..c0b673304 100644
--- a/packages/admin/src/pages/users/user-list/user-list.tsx
+++ b/packages/admin/src/pages/users/user-list/user-list.tsx
@@ -1,17 +1,9 @@
import { SingleColumnPage } from "../../../components/layout/pages"
-import { useExtension } from "../../../providers/extension-provider"
import { UserListTable } from "./components/user-list-table"
export const UserList = () => {
- const { getWidgets } = useExtension()
-
return (
- <SingleColumnPage
- widgets={{
- after: getWidgets("user.list.after"),
- before: getWidgets("user.list.before"),
- }}
- >
+ <SingleColumnPage>
<UserListTable />
</SingleColumnPage>
)
diff --git a/packages/admin/src/pages/users/user-metadata/user-metadata.tsx b/packages/admin/src/pages/users/user-metadata/user-metadata.tsx
index 5e63467f7..515deae97 100644
--- a/packages/admin/src/pages/users/user-metadata/user-metadata.tsx
+++ b/packages/admin/src/pages/users/user-metadata/user-metadata.tsx
@@ -1,9 +1,9 @@
import { useParams } from "react-router-dom";
-import { MetadataForm } from "@components/forms/metadata-form"
-import { RouteDrawer } from "@components/modals"
-import { useUpdateUser, useUser } from "@hooks/api"
-import { FetchError } from "@medusajs/js-sdk"
+import { MetadataForm } from "@components/forms/metadata-form";
+import { RouteDrawer } from "@components/modals";
+import { useUpdateUser, useUser } from "@hooks/api";
+import { ClientError } from "@mercurjs/client";
export const UserMetadata = () => {
const { id } = useParams();
@@ -17,21 +17,25 @@ export const UserMetadata = () => {
const handleSubmit = async (
params: { metadata?: Record<string, unknown> | null },
- callbacks: { onSuccess?: () => void; onError?: (error: FetchError | string) => void }
+ callbacks: {
+ onSuccess?: () => void;
+ onError?: (error: ClientError | string) => void;
+ },
) => {
try {
const result = await mutateAsync({
metadata: params.metadata === undefined ? undefined : params.metadata,
- })
- callbacks.onSuccess?.()
+ });
+ callbacks.onSuccess?.();
- return result
+ return result;
} catch (error) {
- const message = error instanceof FetchError ? error.message : 'An error occurred'
- callbacks.onError?.(message)
- throw error
+ const message =
+ error instanceof ClientError ? error.message : "An error occurred";
+ callbacks.onError?.(message);
+ throw error;
}
- }
+ };
return (
<RouteDrawer data-testid="user-metadata-drawer">