chore(dashboard): Remove v1 code and medusa-react (#7420)
This commit is contained in:
committed by
GitHub
parent
9cbe0085d0
commit
e01472aae6
@@ -48,7 +48,6 @@
|
||||
"i18next-browser-languagedetector": "7.2.0",
|
||||
"i18next-http-backend": "2.4.2",
|
||||
"match-sorter": "^6.3.4",
|
||||
"medusa-react": "latest",
|
||||
"qs": "^6.12.0",
|
||||
"react": "^18.2.0",
|
||||
"react-country-flag": "^3.1.0",
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Toaster } from "@medusajs/ui"
|
||||
import { QueryClientProvider } from "@tanstack/react-query"
|
||||
|
||||
import { I18n } from "./components/utilities/i18n"
|
||||
import { queryClient } from "./lib/medusa"
|
||||
import { queryClient } from "./lib/query-client"
|
||||
import { RouterProvider } from "./providers/router-provider"
|
||||
import { ThemeProvider } from "./providers/theme-provider"
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
export * from "./require-auth";
|
||||
@@ -1,34 +0,0 @@
|
||||
import { Spinner } from "@medusajs/icons"
|
||||
import { Navigate, Outlet, useLocation } from "react-router-dom"
|
||||
|
||||
import { useAdminGetSession } from "medusa-react"
|
||||
import { SearchProvider } from "../../../providers/search-provider"
|
||||
import { SidebarProvider } from "../../../providers/sidebar-provider"
|
||||
|
||||
/**
|
||||
* @deprecated - Delete once all V1 domains have been migrated to V2.
|
||||
*/
|
||||
export const ProtectedRoute = () => {
|
||||
const { user, isLoading } = useAdminGetSession()
|
||||
const location = useLocation()
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div className="flex min-h-screen items-center justify-center">
|
||||
<Spinner className="text-ui-fg-interactive animate-spin" />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
if (!user) {
|
||||
return <Navigate to="/login" state={{ from: location }} replace />
|
||||
}
|
||||
|
||||
return (
|
||||
<SidebarProvider>
|
||||
<SearchProvider>
|
||||
<Outlet />
|
||||
</SearchProvider>
|
||||
</SidebarProvider>
|
||||
)
|
||||
}
|
||||
@@ -3,13 +3,13 @@ import { Select, Text, clx } from "@medusajs/ui"
|
||||
import { useInfiniteQuery } from "@tanstack/react-query"
|
||||
import { format } from "date-fns"
|
||||
import { debounce } from "lodash"
|
||||
import { useAdminCustomer } from "medusa-react"
|
||||
import { PropsWithChildren, useCallback, useEffect, useState } from "react"
|
||||
import { Control, useWatch } from "react-hook-form"
|
||||
import { useTranslation } from "react-i18next"
|
||||
|
||||
import { z } from "zod"
|
||||
import { medusa } from "../../../lib/medusa"
|
||||
|
||||
import { useCustomer } from "../../../hooks/api/customers"
|
||||
import { client } from "../../../lib/client"
|
||||
import { getStylizedAmount } from "../../../lib/money-amount-helpers"
|
||||
import {
|
||||
getOrderFulfillmentStatus,
|
||||
@@ -69,12 +69,12 @@ export const TransferOwnerShipForm = ({
|
||||
isLoading: isLoadingOwner,
|
||||
isError: isOwnerError,
|
||||
error: ownerError,
|
||||
} = useAdminCustomer(currentOwnerId)
|
||||
} = useCustomer(currentOwnerId)
|
||||
|
||||
const { data, fetchNextPage, isFetchingNextPage } = useInfiniteQuery(
|
||||
["customers", debouncedQuery],
|
||||
async ({ pageParam = 0 }) => {
|
||||
const res = await medusa.admin.customers.list({
|
||||
const { data, fetchNextPage, isFetchingNextPage } = useInfiniteQuery({
|
||||
queryKey: ["customers", debouncedQuery],
|
||||
queryFn: async ({ pageParam = 0 }) => {
|
||||
const res = await client.customers.list({
|
||||
q: debouncedQuery,
|
||||
limit: 10,
|
||||
offset: pageParam,
|
||||
@@ -82,15 +82,13 @@ export const TransferOwnerShipForm = ({
|
||||
})
|
||||
return res
|
||||
},
|
||||
{
|
||||
getNextPageParam: (lastPage) => {
|
||||
const moreCustomersExist =
|
||||
lastPage.count > lastPage.offset + lastPage.limit
|
||||
return moreCustomersExist ? lastPage.offset + lastPage.limit : undefined
|
||||
},
|
||||
keepPreviousData: true,
|
||||
}
|
||||
)
|
||||
initialPageParam: 0,
|
||||
getNextPageParam: (lastPage) => {
|
||||
const moreCustomersExist =
|
||||
lastPage.count > lastPage.offset + lastPage.limit
|
||||
return moreCustomersExist ? lastPage.offset + lastPage.limit : undefined
|
||||
},
|
||||
})
|
||||
|
||||
const createLabel = (customer?: Customer) => {
|
||||
if (!customer) {
|
||||
|
||||
@@ -24,12 +24,12 @@ import {
|
||||
|
||||
import { Skeleton } from "../../common/skeleton"
|
||||
|
||||
import { useLogout } from "../../../hooks/api/auth"
|
||||
import { useMe } from "../../../hooks/api/users"
|
||||
import { queryClient } from "../../../lib/query-client"
|
||||
import { useSearch } from "../../../providers/search-provider"
|
||||
import { useSidebar } from "../../../providers/sidebar-provider"
|
||||
import { useTheme } from "../../../providers/theme-provider"
|
||||
import { useLogout } from "../../../hooks/api/auth"
|
||||
import { queryClient } from "../../../lib/medusa"
|
||||
|
||||
export const Shell = ({ children }: PropsWithChildren) => {
|
||||
return (
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { AdminApiKeyListResponse, AdminApiKeyResponse } from "@medusajs/types"
|
||||
import {
|
||||
MutationOptions,
|
||||
QueryKey,
|
||||
@@ -7,11 +8,10 @@ import {
|
||||
useQuery,
|
||||
} from "@tanstack/react-query"
|
||||
import { client } from "../../lib/client"
|
||||
import { queryClient } from "../../lib/medusa"
|
||||
import { queryClient } from "../../lib/query-client"
|
||||
import { queryKeysFactory } from "../../lib/query-key-factory"
|
||||
import { CreateApiKeyReq, UpdateApiKeyReq } from "../../types/api-payloads"
|
||||
import { ApiKeyDeleteRes } from "../../types/api-responses"
|
||||
import { AdminApiKeyResponse, AdminApiKeyListResponse } from "@medusajs/types"
|
||||
import { salesChannelsQueryKeys } from "./sales-channels"
|
||||
|
||||
const API_KEYS_QUERY_KEY = "api_keys" as const
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
useQuery,
|
||||
} from "@tanstack/react-query"
|
||||
import { client } from "../../lib/client"
|
||||
import { queryClient } from "../../lib/medusa"
|
||||
import { queryClient } from "../../lib/query-client"
|
||||
import { queryKeysFactory } from "../../lib/query-key-factory"
|
||||
import { CreateCampaignReq, UpdateCampaignReq } from "../../types/api-payloads"
|
||||
import { CampaignDeleteRes } from "../../types/api-responses"
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
useQuery,
|
||||
} from "@tanstack/react-query"
|
||||
import { client } from "../../lib/client"
|
||||
import { queryClient } from "../../lib/medusa"
|
||||
import { queryClient } from "../../lib/query-client"
|
||||
import { queryKeysFactory } from "../../lib/query-key-factory"
|
||||
import {
|
||||
CreateProductCollectionReq,
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
import {
|
||||
AdminCustomerGroupListResponse,
|
||||
AdminCustomerGroupResponse,
|
||||
} from "@medusajs/types"
|
||||
import {
|
||||
QueryKey,
|
||||
UseMutationOptions,
|
||||
@@ -5,16 +9,12 @@ import {
|
||||
useMutation,
|
||||
useQuery,
|
||||
} from "@tanstack/react-query"
|
||||
import { client } from "../../lib/client"
|
||||
import { queryKeysFactory } from "../../lib/query-key-factory"
|
||||
import {
|
||||
AdminCustomerGroupListResponse,
|
||||
AdminCustomerGroupResponse,
|
||||
} from "@medusajs/types"
|
||||
import { z } from "zod"
|
||||
import { CreateCustomerGroupSchema } from "../../v2-routes/customer-groups/customer-group-create/components/create-customer-group-form"
|
||||
import { queryClient } from "../../lib/medusa"
|
||||
import { EditCustomerGroupSchema } from "../../v2-routes/customer-groups/customer-group-edit/components/edit-customer-group-form"
|
||||
import { client } from "../../lib/client"
|
||||
import { queryClient } from "../../lib/query-client"
|
||||
import { queryKeysFactory } from "../../lib/query-key-factory"
|
||||
import { CreateCustomerGroupSchema } from "../../routes/customer-groups/customer-group-create/components/create-customer-group-form"
|
||||
import { EditCustomerGroupSchema } from "../../routes/customer-groups/customer-group-edit/components/edit-customer-group-form"
|
||||
import { customersQueryKeys } from "./customers"
|
||||
|
||||
const CUSTOMER_GROUPS_QUERY_KEY = "customer_groups" as const
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
useQuery,
|
||||
} from "@tanstack/react-query"
|
||||
import { client } from "../../lib/client"
|
||||
import { queryClient } from "../../lib/medusa"
|
||||
import { queryClient } from "../../lib/query-client"
|
||||
import { queryKeysFactory } from "../../lib/query-key-factory"
|
||||
import { CreateCustomerReq, UpdateCustomerReq } from "../../types/api-payloads"
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import { useMutation, UseMutationOptions } from "@tanstack/react-query"
|
||||
import { queryKeysFactory } from "../../lib/query-key-factory"
|
||||
|
||||
import { client } from "../../lib/client"
|
||||
import { queryClient } from "../../lib/medusa"
|
||||
import { queryClient } from "../../lib/query-client"
|
||||
import { ordersQueryKeys } from "./orders"
|
||||
|
||||
const FULFILLMENTS_QUERY_KEY = "fulfillments" as const
|
||||
|
||||
@@ -1,15 +1,4 @@
|
||||
import { AdminInventoryItemResponse, InventoryNext } from "@medusajs/types"
|
||||
import {
|
||||
InventoryItemDeleteRes,
|
||||
InventoryItemListRes,
|
||||
InventoryItemLocationLevelsRes,
|
||||
InventoryItemRes,
|
||||
} from "../../types/api-responses"
|
||||
import {
|
||||
InventoryItemLocationBatch,
|
||||
UpdateInventoryItemReq,
|
||||
UpdateInventoryLevelReq,
|
||||
} from "../../types/api-payloads"
|
||||
import {
|
||||
QueryKey,
|
||||
UseMutationOptions,
|
||||
@@ -17,9 +6,20 @@ import {
|
||||
useMutation,
|
||||
useQuery,
|
||||
} from "@tanstack/react-query"
|
||||
import {
|
||||
InventoryItemLocationBatch,
|
||||
UpdateInventoryItemReq,
|
||||
UpdateInventoryLevelReq,
|
||||
} from "../../types/api-payloads"
|
||||
import {
|
||||
InventoryItemDeleteRes,
|
||||
InventoryItemListRes,
|
||||
InventoryItemLocationLevelsRes,
|
||||
InventoryItemRes,
|
||||
} from "../../types/api-responses"
|
||||
|
||||
import { client } from "../../lib/client"
|
||||
import { queryClient } from "../../lib/medusa"
|
||||
import { queryClient } from "../../lib/query-client"
|
||||
import { queryKeysFactory } from "../../lib/query-key-factory"
|
||||
|
||||
const INVENTORY_ITEMS_QUERY_KEY = "inventory_items" as const
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
import {
|
||||
AdminInviteResponse,
|
||||
DeleteResponse,
|
||||
HttpTypes,
|
||||
PaginatedResponse,
|
||||
} from "@medusajs/types"
|
||||
import {
|
||||
QueryKey,
|
||||
UseMutationOptions,
|
||||
@@ -6,14 +12,8 @@ import {
|
||||
useQuery,
|
||||
} from "@tanstack/react-query"
|
||||
import { sdk } from "../../lib/client"
|
||||
import { queryClient } from "../../lib/medusa"
|
||||
import { queryClient } from "../../lib/query-client"
|
||||
import { queryKeysFactory } from "../../lib/query-key-factory"
|
||||
import {
|
||||
AdminInviteResponse,
|
||||
DeleteResponse,
|
||||
HttpTypes,
|
||||
PaginatedResponse,
|
||||
} from "@medusajs/types"
|
||||
|
||||
const INVITES_QUERY_KEY = "invites" as const
|
||||
const invitesQueryKeys = queryKeysFactory(INVITES_QUERY_KEY)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { QueryKey, useQuery, UseQueryOptions } from "@tanstack/react-query"
|
||||
|
||||
import { queryKeysFactory } from "../../lib/query-key-factory"
|
||||
import { client } from "../../lib/client"
|
||||
import { queryKeysFactory } from "../../lib/query-key-factory"
|
||||
|
||||
const ORDERS_QUERY_KEY = "orders" as const
|
||||
export const ordersQueryKeys = queryKeysFactory(ORDERS_QUERY_KEY)
|
||||
@@ -15,7 +15,7 @@ export const useOrder = (
|
||||
>
|
||||
) => {
|
||||
const { data, ...rest } = useQuery({
|
||||
queryFn: () => client.orders.retrieve(id, query),
|
||||
queryFn: async () => client.orders.retrieve(id, query),
|
||||
queryKey: ordersQueryKeys.detail(id, query),
|
||||
...options,
|
||||
})
|
||||
@@ -31,7 +31,7 @@ export const useOrders = (
|
||||
>
|
||||
) => {
|
||||
const { data, ...rest } = useQuery({
|
||||
queryFn: () => client.orders.list(query),
|
||||
queryFn: async () => client.orders.list(query),
|
||||
queryKey: ordersQueryKeys.list(query),
|
||||
...options,
|
||||
})
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
useQuery,
|
||||
} from "@tanstack/react-query"
|
||||
import { client } from "../../lib/client"
|
||||
import { queryClient } from "../../lib/medusa"
|
||||
import { queryClient } from "../../lib/query-client"
|
||||
import { queryKeysFactory } from "../../lib/query-key-factory"
|
||||
import {
|
||||
AddPriceListPricesReq,
|
||||
|
||||
@@ -6,9 +6,13 @@ import {
|
||||
useQuery,
|
||||
} from "@tanstack/react-query"
|
||||
import { client } from "../../lib/client"
|
||||
import { queryClient } from "../../lib/query-client"
|
||||
import { queryKeysFactory } from "../../lib/query-key-factory"
|
||||
import { ProductDeleteRes, ProductRes } from "../../types/api-responses"
|
||||
import { queryClient } from "../../lib/medusa"
|
||||
import {
|
||||
ProductDeleteRes,
|
||||
ProductListRes,
|
||||
ProductRes,
|
||||
} from "../../types/api-responses"
|
||||
|
||||
const PRODUCTS_QUERY_KEY = "products" as const
|
||||
export const productsQueryKeys = queryKeysFactory(PRODUCTS_QUERY_KEY)
|
||||
@@ -200,7 +204,7 @@ export const useProduct = (
|
||||
export const useProducts = (
|
||||
query?: Record<string, any>,
|
||||
options?: Omit<
|
||||
UseQueryOptions<any, Error, any, QueryKey>,
|
||||
UseQueryOptions<ProductListRes, Error, ProductListRes, QueryKey>,
|
||||
"queryFn" | "queryKey"
|
||||
>
|
||||
) => {
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
UseQueryOptions,
|
||||
} from "@tanstack/react-query"
|
||||
import { client } from "../../lib/client"
|
||||
import { queryClient } from "../../lib/medusa"
|
||||
import { queryClient } from "../../lib/query-client"
|
||||
import { queryKeysFactory } from "../../lib/query-key-factory"
|
||||
import {
|
||||
BatchAddPromotionRulesReq,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { DeleteResponse, HttpTypes, PaginatedResponse } from "@medusajs/types"
|
||||
import {
|
||||
QueryKey,
|
||||
UseMutationOptions,
|
||||
@@ -6,12 +7,11 @@ import {
|
||||
useQuery,
|
||||
} from "@tanstack/react-query"
|
||||
import { sdk } from "../../lib/client"
|
||||
import { queryClient } from "../../lib/medusa"
|
||||
import { queryClient } from "../../lib/query-client"
|
||||
import { queryKeysFactory } from "../../lib/query-key-factory"
|
||||
import { DeleteResponse, HttpTypes, PaginatedResponse } from "@medusajs/types"
|
||||
|
||||
const REGIONS_QUERY_KEY = "regions" as const
|
||||
const regionsQueryKeys = queryKeysFactory(REGIONS_QUERY_KEY)
|
||||
export const regionsQueryKeys = queryKeysFactory(REGIONS_QUERY_KEY)
|
||||
|
||||
export const useRegion = (
|
||||
id: string,
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
import {
|
||||
CreateReservationReq,
|
||||
UpdateReservationReq,
|
||||
} from "../../types/api-payloads"
|
||||
import {
|
||||
QueryKey,
|
||||
UseMutationOptions,
|
||||
@@ -9,6 +5,10 @@ import {
|
||||
useMutation,
|
||||
useQuery,
|
||||
} from "@tanstack/react-query"
|
||||
import {
|
||||
CreateReservationReq,
|
||||
UpdateReservationReq,
|
||||
} from "../../types/api-payloads"
|
||||
import {
|
||||
ReservationItemDeleteRes,
|
||||
ReservationItemListRes,
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
|
||||
import { InventoryNext } from "@medusajs/types"
|
||||
import { client } from "../../lib/client"
|
||||
import { queryClient } from "../../lib/medusa"
|
||||
import { queryClient } from "../../lib/query-client"
|
||||
import { queryKeysFactory } from "../../lib/query-key-factory"
|
||||
|
||||
const RESERVATION_ITEMS_QUERY_KEY = "reservation_items" as const
|
||||
|
||||
@@ -6,8 +6,12 @@ import {
|
||||
useQuery,
|
||||
} from "@tanstack/react-query"
|
||||
|
||||
import {
|
||||
AdminSalesChannelListResponse,
|
||||
AdminSalesChannelResponse,
|
||||
} from "@medusajs/types"
|
||||
import { client } from "../../lib/client"
|
||||
import { queryClient } from "../../lib/medusa"
|
||||
import { queryClient } from "../../lib/query-client"
|
||||
import { queryKeysFactory } from "../../lib/query-key-factory"
|
||||
import {
|
||||
AddProductsSalesChannelReq,
|
||||
@@ -17,10 +21,6 @@ import {
|
||||
} from "../../types/api-payloads"
|
||||
import { SalesChannelDeleteRes } from "../../types/api-responses"
|
||||
import { productsQueryKeys } from "./products"
|
||||
import {
|
||||
AdminSalesChannelListResponse,
|
||||
AdminSalesChannelResponse,
|
||||
} from "@medusajs/types"
|
||||
|
||||
const SALES_CHANNELS_QUERY_KEY = "sales-channels" as const
|
||||
export const salesChannelsQueryKeys = queryKeysFactory(SALES_CHANNELS_QUERY_KEY)
|
||||
|
||||
@@ -6,17 +6,17 @@ import {
|
||||
UseQueryOptions,
|
||||
} from "@tanstack/react-query"
|
||||
|
||||
import {
|
||||
ShippingOptionDeleteRes,
|
||||
ShippingOptionRes,
|
||||
} from "../../types/api-responses"
|
||||
import { client } from "../../lib/client"
|
||||
import { queryClient } from "../../lib/query-client"
|
||||
import {
|
||||
CreateShippingOptionReq,
|
||||
UpdateShippingOptionReq,
|
||||
} from "../../types/api-payloads"
|
||||
import {
|
||||
ShippingOptionDeleteRes,
|
||||
ShippingOptionRes,
|
||||
} from "../../types/api-responses"
|
||||
import { stockLocationsQueryKeys } from "./stock-locations"
|
||||
import { queryClient } from "../../lib/medusa"
|
||||
import { client } from "../../lib/client"
|
||||
|
||||
export const useShippingOptions = (
|
||||
query?: Record<string, any>,
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
|
||||
import { DeleteResponse } from "@medusajs/types"
|
||||
import { client } from "../../lib/client"
|
||||
import { queryClient } from "../../lib/medusa"
|
||||
import { queryClient } from "../../lib/query-client"
|
||||
import { queryKeysFactory } from "../../lib/query-key-factory"
|
||||
|
||||
const SHIPPING_PROFILE_QUERY_KEY = "shipping_profile" as const
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
} from "@tanstack/react-query"
|
||||
|
||||
import { client } from "../../lib/client"
|
||||
import { queryClient } from "../../lib/medusa"
|
||||
import { queryClient } from "../../lib/query-client"
|
||||
import { queryKeysFactory } from "../../lib/query-key-factory"
|
||||
import {
|
||||
CreateFulfillmentSetReq,
|
||||
@@ -24,7 +24,6 @@ import {
|
||||
StockLocationListRes,
|
||||
StockLocationRes,
|
||||
} from "../../types/api-responses"
|
||||
import { salesChannelsQueryKeys } from "./sales-channels"
|
||||
|
||||
const STOCK_LOCATIONS_QUERY_KEY = "stock_locations" as const
|
||||
export const stockLocationsQueryKeys = queryKeysFactory(
|
||||
|
||||
@@ -7,13 +7,13 @@ import {
|
||||
} from "@tanstack/react-query"
|
||||
|
||||
import { client } from "../../lib/client"
|
||||
import { queryClient } from "../../lib/medusa"
|
||||
import { queryClient } from "../../lib/query-client"
|
||||
import { queryKeysFactory } from "../../lib/query-key-factory"
|
||||
import { UpdateStoreReq } from "../../types/api-payloads"
|
||||
import { StoreRes } from "../../types/api-responses"
|
||||
import { queryKeysFactory } from "../../lib/query-key-factory"
|
||||
|
||||
const STORE_QUERY_KEY = "store" as const
|
||||
const storeQueryKeys = queryKeysFactory(STORE_QUERY_KEY)
|
||||
export const storeQueryKeys = queryKeysFactory(STORE_QUERY_KEY)
|
||||
|
||||
export const useStore = (
|
||||
options?: Omit<
|
||||
|
||||
@@ -5,13 +5,13 @@ import {
|
||||
import { AdminTaxRateListResponse, AdminTaxRateResponse } from "@medusajs/types"
|
||||
import {
|
||||
QueryKey,
|
||||
useMutation,
|
||||
UseMutationOptions,
|
||||
useQuery,
|
||||
UseQueryOptions,
|
||||
useMutation,
|
||||
useQuery,
|
||||
} from "@tanstack/react-query"
|
||||
import { client } from "../../lib/client"
|
||||
import { queryClient } from "../../lib/medusa"
|
||||
import { queryClient } from "../../lib/query-client"
|
||||
import { queryKeysFactory } from "../../lib/query-key-factory"
|
||||
import { TaxRateDeleteRes } from "../../types/api-responses"
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
useQuery,
|
||||
} from "@tanstack/react-query"
|
||||
import { client } from "../../lib/client"
|
||||
import { queryClient } from "../../lib/medusa"
|
||||
import { queryClient } from "../../lib/query-client"
|
||||
import { queryKeysFactory } from "../../lib/query-key-factory"
|
||||
import { TaxRegionDeleteRes } from "../../types/api-responses"
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
useQuery,
|
||||
} from "@tanstack/react-query"
|
||||
import { client } from "../../lib/client"
|
||||
import { queryClient } from "../../lib/medusa"
|
||||
import { queryClient } from "../../lib/query-client"
|
||||
import { queryKeysFactory } from "../../lib/query-key-factory"
|
||||
import { UpdateUserReq } from "../../types/api-payloads"
|
||||
import { UserDeleteRes, UserListRes, UserRes } from "../../types/api-responses"
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
} from "../../types/api-responses"
|
||||
|
||||
const WORKFLOW_EXECUTIONS_QUERY_KEY = "workflow_executions" as const
|
||||
const workflowExecutionsQueryKeys = queryKeysFactory(
|
||||
export const workflowExecutionsQueryKeys = queryKeysFactory(
|
||||
WORKFLOW_EXECUTIONS_QUERY_KEY
|
||||
)
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
getCategoryPath,
|
||||
getIsActiveProps,
|
||||
getIsInternalProps,
|
||||
} from "../../../v2-routes/categories/common/utils"
|
||||
} from "../../../routes/categories/common/utils"
|
||||
|
||||
const columnHelper =
|
||||
createColumnHelper<AdminProductCategoryResponse["product_category"]>()
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
import {
|
||||
AdminCampaignRes,
|
||||
AdminCampaignsListRes,
|
||||
AdminGetCampaignsCampaignParams,
|
||||
AdminGetCampaignsParams,
|
||||
AdminPostCampaignsCampaignReq,
|
||||
} from "@medusajs/medusa"
|
||||
import { useMutation } from "@tanstack/react-query"
|
||||
import { queryKeysFactory, useAdminCustomQuery } from "medusa-react"
|
||||
import { medusa } from "../medusa"
|
||||
|
||||
const QUERY_KEY = "admin_campaigns"
|
||||
export const adminCampaignKeys = queryKeysFactory<
|
||||
typeof QUERY_KEY,
|
||||
AdminGetCampaignsParams
|
||||
>(QUERY_KEY)
|
||||
|
||||
export const adminCampaignQueryFns = {
|
||||
list: (query: AdminGetCampaignsParams) =>
|
||||
medusa.admin.custom.get(`/admin/campaigns`, query),
|
||||
detail: (id: string) => medusa.admin.custom.get(`/admin/campaigns/${id}`),
|
||||
}
|
||||
|
||||
export const useV2Campaigns = (
|
||||
query?: AdminGetCampaignsParams,
|
||||
options?: object
|
||||
) => {
|
||||
const { data, ...rest } = useAdminCustomQuery<
|
||||
AdminGetCampaignsParams,
|
||||
AdminCampaignsListRes
|
||||
>("/admin/campaigns", adminCampaignKeys.list(query), query, options)
|
||||
|
||||
return { ...data, ...rest }
|
||||
}
|
||||
|
||||
export const useV2Campaign = (
|
||||
id: string,
|
||||
query?: AdminGetCampaignsParams,
|
||||
options?: object
|
||||
) => {
|
||||
const { data, ...rest } = useAdminCustomQuery<
|
||||
AdminGetCampaignsCampaignParams,
|
||||
AdminCampaignRes
|
||||
>(`/admin/campaigns/${id}`, adminCampaignKeys.detail(id), query, options)
|
||||
|
||||
return { ...data, ...rest }
|
||||
}
|
||||
|
||||
export const useV2DeleteCampaign = (id: string) => {
|
||||
return useMutation(() => medusa.admin.custom.delete(`/admin/campaigns/${id}`))
|
||||
}
|
||||
|
||||
export const useV2PostCampaign = (id: string) => {
|
||||
return useMutation((args: AdminPostCampaignsCampaignReq) =>
|
||||
medusa.client.request("POST", `/admin/campaigns/${id}`, args)
|
||||
)
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
import { CurrencyDTO } from "@medusajs/types"
|
||||
import { adminCurrenciesKeys, useAdminCustomQuery } from "medusa-react"
|
||||
import { V2ListRes } from "./types/common"
|
||||
|
||||
// TODO: Add types once we export V2 API types
|
||||
export const useV2Currencies = (query?: any, options?: any) => {
|
||||
const { data, ...rest } = useAdminCustomQuery(
|
||||
`/admin/currencies`,
|
||||
adminCurrenciesKeys.list(query),
|
||||
query,
|
||||
options
|
||||
)
|
||||
|
||||
const typedData: {
|
||||
currencies: CurrencyDTO[] | undefined
|
||||
} & V2ListRes = {
|
||||
currencies: data?.currencies,
|
||||
count: data?.count,
|
||||
offset: data?.offset,
|
||||
limit: data?.limit,
|
||||
}
|
||||
|
||||
return { ...typedData, ...rest }
|
||||
}
|
||||
|
||||
export const useV2Currency = (id: string, options?: any) => {
|
||||
const { data, ...rest } = useAdminCustomQuery(
|
||||
`/admin/currencies/${id}`,
|
||||
adminCurrenciesKeys.detail(id),
|
||||
undefined,
|
||||
options
|
||||
)
|
||||
|
||||
const currency: CurrencyDTO | undefined = data?.currency
|
||||
|
||||
return { currency, ...rest }
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
export * from "./auth"
|
||||
export * from "./campaign"
|
||||
export * from "./currencies"
|
||||
@@ -1,13 +0,0 @@
|
||||
export type AcceptInviteInput = {
|
||||
payload: {
|
||||
first_name: string
|
||||
last_name: string
|
||||
}
|
||||
// Token for the created auth user
|
||||
token: string
|
||||
}
|
||||
|
||||
export type CreateAuthUserInput = {
|
||||
email: string
|
||||
password: string
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
export type V2ListRes = {
|
||||
count: number | undefined
|
||||
offset: number | undefined
|
||||
limit: number | undefined
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
import { CurrencyDTO, PaymentProviderDTO, StoreDTO } from "@medusajs/types"
|
||||
|
||||
export type Store = StoreDTO & {
|
||||
default_currency: CurrencyDTO | null
|
||||
currencies?: CurrencyDTO[]
|
||||
payment_providers?: PaymentProviderDTO[]
|
||||
}
|
||||
@@ -3,8 +3,8 @@ import {
|
||||
AdminCustomerGroupResponse,
|
||||
} from "@medusajs/types"
|
||||
import { z } from "zod"
|
||||
import { CreateCustomerGroupSchema } from "../../v2-routes/customer-groups/customer-group-create/components/create-customer-group-form"
|
||||
import { EditCustomerGroupSchema } from "../../v2-routes/customer-groups/customer-group-edit/components/edit-customer-group-form"
|
||||
import { CreateCustomerGroupSchema } from "../../routes/customer-groups/customer-group-create/components/create-customer-group-form"
|
||||
import { EditCustomerGroupSchema } from "../../routes/customer-groups/customer-group-edit/components/edit-customer-group-form"
|
||||
import { deleteRequest, getRequest, postRequest } from "./common"
|
||||
|
||||
async function retrieveCustomerGroup(id: string, query?: Record<string, any>) {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
import { QueryClient } from "@tanstack/react-query"
|
||||
|
||||
export const MEDUSA_BACKEND_URL = __BACKEND_URL__ ?? "http://localhost:9000"
|
||||
@@ -12,8 +11,3 @@ export const queryClient = new QueryClient({
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
export const medusa = new Medusa({
|
||||
baseUrl: MEDUSA_BACKEND_URL,
|
||||
maxRetries: 1,
|
||||
})
|
||||
@@ -1,8 +0,0 @@
|
||||
import { createContext } from "react"
|
||||
import { Feature } from "./types"
|
||||
|
||||
type FeatureContextValue = {
|
||||
isFeatureEnabled: (feature: Feature) => boolean
|
||||
}
|
||||
|
||||
export const FeatureContext = createContext<FeatureContextValue | null>(null)
|
||||
@@ -1,33 +0,0 @@
|
||||
import { useAdminStore } from "medusa-react"
|
||||
import { PropsWithChildren, useEffect, useState } from "react"
|
||||
import { FeatureContext } from "./feature-context"
|
||||
import { Feature } from "./types"
|
||||
|
||||
export const FeatureProvider = ({ children }: PropsWithChildren) => {
|
||||
const { store, isLoading } = useAdminStore()
|
||||
const [features, setFeatures] = useState<Feature[]>([])
|
||||
|
||||
useEffect(() => {
|
||||
if (!store || isLoading) {
|
||||
return
|
||||
}
|
||||
|
||||
const flags = store.feature_flags
|
||||
.filter((f) => f.value === true)
|
||||
.map((f) => f.key)
|
||||
const modules = store.modules.map((m) => m.module)
|
||||
const enabled = flags.concat(modules)
|
||||
|
||||
setFeatures(enabled as Feature[])
|
||||
}, [store, isLoading])
|
||||
|
||||
function isFeatureEnabled(feature: Feature) {
|
||||
return features.includes(feature)
|
||||
}
|
||||
|
||||
return (
|
||||
<FeatureContext.Provider value={{ isFeatureEnabled }}>
|
||||
{children}
|
||||
</FeatureContext.Provider>
|
||||
)
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
export { FeatureProvider } from "./feature-provider";
|
||||
export { useFeature } from "./use-feature";
|
||||
@@ -1,16 +0,0 @@
|
||||
const featureFlags = [
|
||||
"analytics",
|
||||
"order_editing",
|
||||
"product_categories",
|
||||
"publishable_api_keys",
|
||||
"sales_channels",
|
||||
"tax_inclusive_pricing",
|
||||
] as const
|
||||
|
||||
type FeatureFlag = (typeof featureFlags)[number]
|
||||
|
||||
const modules = ["inventory"] as const
|
||||
|
||||
type Module = (typeof modules)[number]
|
||||
|
||||
export type Feature = FeatureFlag | Module
|
||||
@@ -1,10 +0,0 @@
|
||||
import { useContext } from "react";
|
||||
import { FeatureContext } from "./feature-context";
|
||||
|
||||
export const useFeature = () => {
|
||||
const context = useContext(FeatureContext);
|
||||
if (context === null) {
|
||||
throw new Error("useFeature must be used within a FeatureProvider");
|
||||
}
|
||||
return context;
|
||||
};
|
||||
@@ -5,9 +5,9 @@ import {
|
||||
AdminProductCategoryResponse,
|
||||
AdminTaxRateResponse,
|
||||
AdminTaxRegionResponse,
|
||||
HttpTypes,
|
||||
SalesChannelDTO,
|
||||
UserDTO,
|
||||
HttpTypes,
|
||||
} from "@medusajs/types"
|
||||
import { Outlet, RouteObject } from "react-router-dom"
|
||||
|
||||
@@ -23,11 +23,11 @@ import { SettingsExtensions } from "./settings-extensions"
|
||||
export const RouteMap: RouteObject[] = [
|
||||
{
|
||||
path: "/login",
|
||||
lazy: () => import("../../v2-routes/login"),
|
||||
lazy: () => import("../../routes/login"),
|
||||
},
|
||||
{
|
||||
path: "/",
|
||||
lazy: () => import("../../v2-routes/home"),
|
||||
lazy: () => import("../../routes/home"),
|
||||
},
|
||||
{
|
||||
path: "*",
|
||||
@@ -35,7 +35,7 @@ export const RouteMap: RouteObject[] = [
|
||||
},
|
||||
{
|
||||
path: "/invite",
|
||||
lazy: () => import("../../v2-routes/invite"),
|
||||
lazy: () => import("../../routes/invite"),
|
||||
},
|
||||
{
|
||||
element: <ProtectedRoute />,
|
||||
@@ -53,70 +53,67 @@ export const RouteMap: RouteObject[] = [
|
||||
children: [
|
||||
{
|
||||
path: "",
|
||||
lazy: () => import("../../v2-routes/products/product-list"),
|
||||
lazy: () => import("../../routes/products/product-list"),
|
||||
children: [
|
||||
{
|
||||
path: "create",
|
||||
lazy: () =>
|
||||
import("../../v2-routes/products/product-create"),
|
||||
lazy: () => import("../../routes/products/product-create"),
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: ":id",
|
||||
lazy: () => import("../../v2-routes/products/product-detail"),
|
||||
lazy: () => import("../../routes/products/product-detail"),
|
||||
handle: {
|
||||
crumb: (data: AdminProductsRes) => data.product.title,
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: "edit",
|
||||
lazy: () => import("../../v2-routes/products/product-edit"),
|
||||
lazy: () => import("../../routes/products/product-edit"),
|
||||
},
|
||||
{
|
||||
path: "sales-channels",
|
||||
lazy: () =>
|
||||
import("../../v2-routes/products/product-sales-channels"),
|
||||
import("../../routes/products/product-sales-channels"),
|
||||
},
|
||||
{
|
||||
path: "attributes",
|
||||
lazy: () =>
|
||||
import("../../v2-routes/products/product-attributes"),
|
||||
import("../../routes/products/product-attributes"),
|
||||
},
|
||||
{
|
||||
path: "organization",
|
||||
lazy: () =>
|
||||
import("../../v2-routes/products/product-organization"),
|
||||
import("../../routes/products/product-organization"),
|
||||
},
|
||||
{
|
||||
path: "media",
|
||||
lazy: () =>
|
||||
import("../../v2-routes/products/product-media"),
|
||||
lazy: () => import("../../routes/products/product-media"),
|
||||
},
|
||||
{
|
||||
path: "prices",
|
||||
lazy: () =>
|
||||
import("../../v2-routes/products/product-prices"),
|
||||
lazy: () => import("../../routes/products/product-prices"),
|
||||
},
|
||||
{
|
||||
path: "options/create",
|
||||
lazy: () =>
|
||||
import("../../v2-routes/products/product-create-option"),
|
||||
import("../../routes/products/product-create-option"),
|
||||
},
|
||||
{
|
||||
path: "options/:option_id/edit",
|
||||
lazy: () =>
|
||||
import("../../v2-routes/products/product-edit-option"),
|
||||
import("../../routes/products/product-edit-option"),
|
||||
},
|
||||
{
|
||||
path: "variants/create",
|
||||
lazy: () =>
|
||||
import("../../v2-routes/products/product-create-variant"),
|
||||
import("../../routes/products/product-create-variant"),
|
||||
},
|
||||
{
|
||||
path: "variants/:variant_id/edit",
|
||||
lazy: () =>
|
||||
import("../../v2-routes/products/product-edit-variant"),
|
||||
import("../../routes/products/product-edit-variant"),
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -130,12 +127,11 @@ export const RouteMap: RouteObject[] = [
|
||||
children: [
|
||||
{
|
||||
path: "",
|
||||
lazy: () => import("../../v2-routes/categories/category-list"),
|
||||
lazy: () => import("../../routes/categories/category-list"),
|
||||
},
|
||||
{
|
||||
path: ":id",
|
||||
lazy: () =>
|
||||
import("../../v2-routes/categories/category-detail"),
|
||||
lazy: () => import("../../routes/categories/category-detail"),
|
||||
handle: {
|
||||
crumb: (data: AdminProductCategoryResponse) =>
|
||||
data.product_category.name,
|
||||
@@ -151,16 +147,16 @@ export const RouteMap: RouteObject[] = [
|
||||
children: [
|
||||
{
|
||||
path: "",
|
||||
lazy: () => import("../../v2-routes/orders/order-list"),
|
||||
lazy: () => import("../../routes/orders/order-list"),
|
||||
},
|
||||
{
|
||||
path: ":id",
|
||||
lazy: () => import("../../v2-routes/orders/order-detail"),
|
||||
lazy: () => import("../../routes/orders/order-detail"),
|
||||
children: [
|
||||
{
|
||||
path: "fulfillment",
|
||||
lazy: () =>
|
||||
import("../../v2-routes/orders/order-create-fulfillment"),
|
||||
import("../../routes/orders/order-create-fulfillment"),
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -174,17 +170,15 @@ export const RouteMap: RouteObject[] = [
|
||||
children: [
|
||||
{
|
||||
path: "",
|
||||
lazy: () => import("../../v2-routes/promotions/promotion-list"),
|
||||
lazy: () => import("../../routes/promotions/promotion-list"),
|
||||
},
|
||||
{
|
||||
path: "create",
|
||||
lazy: () =>
|
||||
import("../../v2-routes/promotions/promotion-create"),
|
||||
lazy: () => import("../../routes/promotions/promotion-create"),
|
||||
},
|
||||
{
|
||||
path: ":id",
|
||||
lazy: () =>
|
||||
import("../../v2-routes/promotions/promotion-detail"),
|
||||
lazy: () => import("../../routes/promotions/promotion-detail"),
|
||||
handle: {
|
||||
// TODO: Re-add type when it's available again
|
||||
crumb: (data: any) => data.promotion?.code,
|
||||
@@ -193,21 +187,17 @@ export const RouteMap: RouteObject[] = [
|
||||
{
|
||||
path: "edit",
|
||||
lazy: () =>
|
||||
import(
|
||||
"../../v2-routes/promotions/promotion-edit-details"
|
||||
),
|
||||
import("../../routes/promotions/promotion-edit-details"),
|
||||
},
|
||||
{
|
||||
path: "add-to-campaign",
|
||||
lazy: () =>
|
||||
import(
|
||||
"../../v2-routes/promotions/promotion-add-campaign"
|
||||
),
|
||||
import("../../routes/promotions/promotion-add-campaign"),
|
||||
},
|
||||
{
|
||||
path: ":ruleType/edit",
|
||||
lazy: () =>
|
||||
import("../../v2-routes/promotions/common/edit-rules"),
|
||||
import("../../routes/promotions/common/edit-rules"),
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -219,34 +209,31 @@ export const RouteMap: RouteObject[] = [
|
||||
children: [
|
||||
{
|
||||
path: "",
|
||||
lazy: () => import("../../v2-routes/campaigns/campaign-list"),
|
||||
lazy: () => import("../../routes/campaigns/campaign-list"),
|
||||
children: [],
|
||||
},
|
||||
{
|
||||
path: "create",
|
||||
lazy: () => import("../../v2-routes/campaigns/campaign-create"),
|
||||
lazy: () => import("../../routes/campaigns/campaign-create"),
|
||||
},
|
||||
{
|
||||
path: ":id",
|
||||
lazy: () => import("../../v2-routes/campaigns/campaign-detail"),
|
||||
lazy: () => import("../../routes/campaigns/campaign-detail"),
|
||||
handle: { crumb: (data: any) => data.campaign.name },
|
||||
children: [
|
||||
{
|
||||
path: "edit",
|
||||
lazy: () =>
|
||||
import("../../v2-routes/campaigns/campaign-edit"),
|
||||
lazy: () => import("../../routes/campaigns/campaign-edit"),
|
||||
},
|
||||
{
|
||||
path: "edit-budget",
|
||||
lazy: () =>
|
||||
import("../../v2-routes/campaigns/campaign-budget-edit"),
|
||||
import("../../routes/campaigns/campaign-budget-edit"),
|
||||
},
|
||||
{
|
||||
path: "add-promotions",
|
||||
lazy: () =>
|
||||
import(
|
||||
"../../v2-routes/campaigns/add-campaign-promotions"
|
||||
),
|
||||
import("../../routes/campaigns/add-campaign-promotions"),
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -260,20 +247,19 @@ export const RouteMap: RouteObject[] = [
|
||||
children: [
|
||||
{
|
||||
path: "",
|
||||
lazy: () =>
|
||||
import("../../v2-routes/collections/collection-list"),
|
||||
lazy: () => import("../../routes/collections/collection-list"),
|
||||
children: [
|
||||
{
|
||||
path: "create",
|
||||
lazy: () =>
|
||||
import("../../v2-routes/collections/collection-create"),
|
||||
import("../../routes/collections/collection-create"),
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: ":id",
|
||||
lazy: () =>
|
||||
import("../../v2-routes/collections/collection-detail"),
|
||||
import("../../routes/collections/collection-detail"),
|
||||
handle: {
|
||||
crumb: (data: AdminCollectionsRes) => data.collection.title,
|
||||
},
|
||||
@@ -281,13 +267,13 @@ export const RouteMap: RouteObject[] = [
|
||||
{
|
||||
path: "edit",
|
||||
lazy: () =>
|
||||
import("../../v2-routes/collections/collection-edit"),
|
||||
import("../../routes/collections/collection-edit"),
|
||||
},
|
||||
{
|
||||
path: "products",
|
||||
lazy: () =>
|
||||
import(
|
||||
"../../v2-routes/collections/collection-add-products"
|
||||
"../../routes/collections/collection-add-products"
|
||||
),
|
||||
},
|
||||
],
|
||||
@@ -302,40 +288,38 @@ export const RouteMap: RouteObject[] = [
|
||||
children: [
|
||||
{
|
||||
path: "",
|
||||
lazy: () => import("../../v2-routes/pricing/pricing-list"),
|
||||
lazy: () => import("../../routes/pricing/pricing-list"),
|
||||
children: [
|
||||
{
|
||||
path: "create",
|
||||
lazy: () =>
|
||||
import("../../v2-routes/pricing/pricing-create"),
|
||||
lazy: () => import("../../routes/pricing/pricing-create"),
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: ":id",
|
||||
lazy: () => import("../../v2-routes/pricing/pricing-detail"),
|
||||
lazy: () => import("../../routes/pricing/pricing-detail"),
|
||||
handle: {
|
||||
crumb: (data: PriceListRes) => data.price_list.title,
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: "edit",
|
||||
lazy: () => import("../../v2-routes/pricing/pricing-edit"),
|
||||
lazy: () => import("../../routes/pricing/pricing-edit"),
|
||||
},
|
||||
{
|
||||
path: "configuration",
|
||||
lazy: () =>
|
||||
import("../../v2-routes/pricing/pricing-configuration"),
|
||||
import("../../routes/pricing/pricing-configuration"),
|
||||
},
|
||||
{
|
||||
path: "products/add",
|
||||
lazy: () =>
|
||||
import("../../v2-routes/pricing/pricing-products"),
|
||||
lazy: () => import("../../routes/pricing/pricing-products"),
|
||||
},
|
||||
{
|
||||
path: "products/edit",
|
||||
lazy: () =>
|
||||
import("../../v2-routes/pricing/pricing-products-prices"),
|
||||
import("../../routes/pricing/pricing-products-prices"),
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -349,18 +333,18 @@ export const RouteMap: RouteObject[] = [
|
||||
children: [
|
||||
{
|
||||
path: "",
|
||||
lazy: () => import("../../v2-routes/customers/customer-list"),
|
||||
lazy: () => import("../../routes/customers/customer-list"),
|
||||
children: [
|
||||
{
|
||||
path: "create",
|
||||
lazy: () =>
|
||||
import("../../v2-routes/customers/customer-create"),
|
||||
import("../../routes/customers/customer-create"),
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: ":id",
|
||||
lazy: () => import("../../v2-routes/customers/customer-detail"),
|
||||
lazy: () => import("../../routes/customers/customer-detail"),
|
||||
handle: {
|
||||
// Re-add type when it's available again
|
||||
crumb: (data: any) => data.customer.email,
|
||||
@@ -368,14 +352,13 @@ export const RouteMap: RouteObject[] = [
|
||||
children: [
|
||||
{
|
||||
path: "edit",
|
||||
lazy: () =>
|
||||
import("../../v2-routes/customers/customer-edit"),
|
||||
lazy: () => import("../../routes/customers/customer-edit"),
|
||||
},
|
||||
{
|
||||
path: "add-customer-groups",
|
||||
lazy: () =>
|
||||
import(
|
||||
"../../v2-routes/customers/customers-add-customer-group"
|
||||
"../../routes/customers/customers-add-customer-group"
|
||||
),
|
||||
},
|
||||
],
|
||||
@@ -391,13 +374,13 @@ export const RouteMap: RouteObject[] = [
|
||||
{
|
||||
path: "",
|
||||
lazy: () =>
|
||||
import("../../v2-routes/customer-groups/customer-group-list"),
|
||||
import("../../routes/customer-groups/customer-group-list"),
|
||||
children: [
|
||||
{
|
||||
path: "create",
|
||||
lazy: () =>
|
||||
import(
|
||||
"../../v2-routes/customer-groups/customer-group-create"
|
||||
"../../routes/customer-groups/customer-group-create"
|
||||
),
|
||||
},
|
||||
],
|
||||
@@ -405,9 +388,7 @@ export const RouteMap: RouteObject[] = [
|
||||
{
|
||||
path: ":id",
|
||||
lazy: () =>
|
||||
import(
|
||||
"../../v2-routes/customer-groups/customer-group-detail"
|
||||
),
|
||||
import("../../routes/customer-groups/customer-group-detail"),
|
||||
handle: {
|
||||
crumb: (data: AdminCustomerGroupResponse) =>
|
||||
data.customer_group.name,
|
||||
@@ -417,14 +398,14 @@ export const RouteMap: RouteObject[] = [
|
||||
path: "edit",
|
||||
lazy: () =>
|
||||
import(
|
||||
"../../v2-routes/customer-groups/customer-group-edit"
|
||||
"../../routes/customer-groups/customer-group-edit"
|
||||
),
|
||||
},
|
||||
{
|
||||
path: "add-customers",
|
||||
lazy: () =>
|
||||
import(
|
||||
"../../v2-routes/customer-groups/customer-group-add-customers"
|
||||
"../../routes/customer-groups/customer-group-add-customers"
|
||||
),
|
||||
},
|
||||
],
|
||||
@@ -440,13 +421,13 @@ export const RouteMap: RouteObject[] = [
|
||||
{
|
||||
path: "",
|
||||
lazy: () =>
|
||||
import("../../v2-routes/reservations/reservation-list"),
|
||||
import("../../routes/reservations/reservation-list"),
|
||||
children: [
|
||||
{
|
||||
path: "create",
|
||||
lazy: () =>
|
||||
import(
|
||||
"../../v2-routes/reservations/reservation-list/create-reservation"
|
||||
"../../routes/reservations/reservation-list/create-reservation"
|
||||
),
|
||||
},
|
||||
],
|
||||
@@ -454,7 +435,7 @@ export const RouteMap: RouteObject[] = [
|
||||
{
|
||||
path: ":id",
|
||||
lazy: () =>
|
||||
import("../../v2-routes/reservations/reservation-detail"),
|
||||
import("../../routes/reservations/reservation-detail"),
|
||||
handle: {
|
||||
crumb: ({ reservation }: any) => {
|
||||
return (
|
||||
@@ -469,7 +450,7 @@ export const RouteMap: RouteObject[] = [
|
||||
path: "edit",
|
||||
lazy: () =>
|
||||
import(
|
||||
"../../v2-routes/reservations/reservation-detail/components/edit-reservation"
|
||||
"../../routes/reservations/reservation-detail/components/edit-reservation"
|
||||
),
|
||||
},
|
||||
],
|
||||
@@ -484,12 +465,11 @@ export const RouteMap: RouteObject[] = [
|
||||
children: [
|
||||
{
|
||||
path: "",
|
||||
lazy: () => import("../../v2-routes/inventory/inventory-list"),
|
||||
lazy: () => import("../../routes/inventory/inventory-list"),
|
||||
},
|
||||
{
|
||||
path: ":id",
|
||||
lazy: () =>
|
||||
import("../../v2-routes/inventory/inventory-detail"),
|
||||
lazy: () => import("../../routes/inventory/inventory-detail"),
|
||||
handle: {
|
||||
crumb: (data: InventoryItemRes) =>
|
||||
data.inventory_item.title ?? data.inventory_item.sku,
|
||||
@@ -499,41 +479,39 @@ export const RouteMap: RouteObject[] = [
|
||||
path: "edit",
|
||||
lazy: () =>
|
||||
import(
|
||||
"../../v2-routes/inventory/inventory-detail/components/edit-inventory-item"
|
||||
"../../routes/inventory/inventory-detail/components/edit-inventory-item"
|
||||
),
|
||||
},
|
||||
{
|
||||
path: "attributes",
|
||||
lazy: () =>
|
||||
import(
|
||||
"../../v2-routes/inventory/inventory-detail/components/edit-inventory-item-attributes"
|
||||
"../../routes/inventory/inventory-detail/components/edit-inventory-item-attributes"
|
||||
),
|
||||
},
|
||||
{
|
||||
path: "locations",
|
||||
lazy: () =>
|
||||
import(
|
||||
"../../v2-routes/inventory/inventory-detail/components/manage-locations"
|
||||
"../../routes/inventory/inventory-detail/components/manage-locations"
|
||||
),
|
||||
},
|
||||
{
|
||||
path: "locations/:location_id",
|
||||
lazy: () =>
|
||||
import(
|
||||
"../../v2-routes/inventory/inventory-detail/components/adjust-inventory"
|
||||
"../../routes/inventory/inventory-detail/components/adjust-inventory"
|
||||
),
|
||||
},
|
||||
{
|
||||
// TODO: create reservation
|
||||
path: "reservations",
|
||||
lazy: () =>
|
||||
import("../../v2-routes/customers/customer-edit"),
|
||||
lazy: () => import("../../routes/customers/customer-edit"),
|
||||
},
|
||||
{
|
||||
// TODO: edit reservation
|
||||
path: "reservations/:reservation_id",
|
||||
lazy: () =>
|
||||
import("../../v2-routes/customers/customer-edit"),
|
||||
lazy: () => import("../../routes/customers/customer-edit"),
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -554,18 +532,18 @@ export const RouteMap: RouteObject[] = [
|
||||
children: [
|
||||
{
|
||||
index: true,
|
||||
lazy: () => import("../../v2-routes/settings"),
|
||||
lazy: () => import("../../routes/settings"),
|
||||
},
|
||||
{
|
||||
path: "profile",
|
||||
lazy: () => import("../../v2-routes/profile/profile-detail"),
|
||||
lazy: () => import("../../routes/profile/profile-detail"),
|
||||
handle: {
|
||||
crumb: () => "Profile",
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: "edit",
|
||||
lazy: () => import("../../v2-routes/profile/profile-edit"),
|
||||
lazy: () => import("../../routes/profile/profile-edit"),
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -578,17 +556,17 @@ export const RouteMap: RouteObject[] = [
|
||||
children: [
|
||||
{
|
||||
path: "",
|
||||
lazy: () => import("../../v2-routes/regions/region-list"),
|
||||
lazy: () => import("../../routes/regions/region-list"),
|
||||
children: [
|
||||
{
|
||||
path: "create",
|
||||
lazy: () => import("../../v2-routes/regions/region-create"),
|
||||
lazy: () => import("../../routes/regions/region-create"),
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: ":id",
|
||||
lazy: () => import("../../v2-routes/regions/region-detail"),
|
||||
lazy: () => import("../../routes/regions/region-detail"),
|
||||
handle: {
|
||||
crumb: (data: { region: HttpTypes.AdminRegion }) =>
|
||||
data.region.name,
|
||||
@@ -596,12 +574,12 @@ export const RouteMap: RouteObject[] = [
|
||||
children: [
|
||||
{
|
||||
path: "edit",
|
||||
lazy: () => import("../../v2-routes/regions/region-edit"),
|
||||
lazy: () => import("../../routes/regions/region-edit"),
|
||||
},
|
||||
{
|
||||
path: "countries/add",
|
||||
lazy: () =>
|
||||
import("../../v2-routes/regions/region-add-countries"),
|
||||
import("../../routes/regions/region-add-countries"),
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -609,19 +587,18 @@ export const RouteMap: RouteObject[] = [
|
||||
},
|
||||
{
|
||||
path: "store",
|
||||
lazy: () => import("../../v2-routes/store/store-detail"),
|
||||
lazy: () => import("../../routes/store/store-detail"),
|
||||
handle: {
|
||||
crumb: () => "Store",
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: "edit",
|
||||
lazy: () => import("../../v2-routes/store/store-edit"),
|
||||
lazy: () => import("../../routes/store/store-edit"),
|
||||
},
|
||||
{
|
||||
path: "currencies",
|
||||
lazy: () =>
|
||||
import("../../v2-routes/store/store-add-currencies"),
|
||||
lazy: () => import("../../routes/store/store-add-currencies"),
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -634,24 +611,24 @@ export const RouteMap: RouteObject[] = [
|
||||
children: [
|
||||
{
|
||||
path: "",
|
||||
lazy: () => import("../../v2-routes/users/user-list"),
|
||||
lazy: () => import("../../routes/users/user-list"),
|
||||
children: [
|
||||
{
|
||||
path: "invite",
|
||||
lazy: () => import("../../v2-routes/users/user-invite"),
|
||||
lazy: () => import("../../routes/users/user-invite"),
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: ":id",
|
||||
lazy: () => import("../../v2-routes/users/user-detail"),
|
||||
lazy: () => import("../../routes/users/user-detail"),
|
||||
handle: {
|
||||
crumb: (data: { user: UserDTO }) => data.user.email,
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: "edit",
|
||||
lazy: () => import("../../v2-routes/users/user-edit"),
|
||||
lazy: () => import("../../routes/users/user-edit"),
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -667,13 +644,13 @@ export const RouteMap: RouteObject[] = [
|
||||
{
|
||||
path: "",
|
||||
lazy: () =>
|
||||
import("../../v2-routes/sales-channels/sales-channel-list"),
|
||||
import("../../routes/sales-channels/sales-channel-list"),
|
||||
children: [
|
||||
{
|
||||
path: "create",
|
||||
lazy: () =>
|
||||
import(
|
||||
"../../v2-routes/sales-channels/sales-channel-create"
|
||||
"../../routes/sales-channels/sales-channel-create"
|
||||
),
|
||||
},
|
||||
],
|
||||
@@ -681,7 +658,7 @@ export const RouteMap: RouteObject[] = [
|
||||
{
|
||||
path: ":id",
|
||||
lazy: () =>
|
||||
import("../../v2-routes/sales-channels/sales-channel-detail"),
|
||||
import("../../routes/sales-channels/sales-channel-detail"),
|
||||
handle: {
|
||||
crumb: (data: { sales_channel: SalesChannelDTO }) =>
|
||||
data.sales_channel.name,
|
||||
@@ -690,15 +667,13 @@ export const RouteMap: RouteObject[] = [
|
||||
{
|
||||
path: "edit",
|
||||
lazy: () =>
|
||||
import(
|
||||
"../../v2-routes/sales-channels/sales-channel-edit"
|
||||
),
|
||||
import("../../routes/sales-channels/sales-channel-edit"),
|
||||
},
|
||||
{
|
||||
path: "add-products",
|
||||
lazy: () =>
|
||||
import(
|
||||
"../../v2-routes/sales-channels/sales-channel-add-products"
|
||||
"../../routes/sales-channels/sales-channel-add-products"
|
||||
),
|
||||
},
|
||||
],
|
||||
@@ -714,26 +689,25 @@ export const RouteMap: RouteObject[] = [
|
||||
children: [
|
||||
{
|
||||
path: "",
|
||||
lazy: () => import("../../v2-routes/shipping/location-list"),
|
||||
lazy: () => import("../../routes/shipping/location-list"),
|
||||
},
|
||||
{
|
||||
path: "create",
|
||||
lazy: () => import("../../v2-routes/shipping/location-create"),
|
||||
lazy: () => import("../../routes/shipping/location-create"),
|
||||
},
|
||||
{
|
||||
path: ":location_id",
|
||||
lazy: () => import("../../v2-routes/shipping/location-details"),
|
||||
lazy: () => import("../../routes/shipping/location-details"),
|
||||
children: [
|
||||
{
|
||||
path: "edit",
|
||||
lazy: () =>
|
||||
import("../../v2-routes/shipping/location-edit"),
|
||||
lazy: () => import("../../routes/shipping/location-edit"),
|
||||
},
|
||||
{
|
||||
path: "sales-channels/edit",
|
||||
lazy: () =>
|
||||
import(
|
||||
"../../v2-routes/shipping/location-add-sales-channels"
|
||||
"../../routes/shipping/location-add-sales-channels"
|
||||
),
|
||||
},
|
||||
{
|
||||
@@ -742,9 +716,7 @@ export const RouteMap: RouteObject[] = [
|
||||
{
|
||||
path: "service-zones/create",
|
||||
lazy: () =>
|
||||
import(
|
||||
"../../v2-routes/shipping/service-zone-create"
|
||||
),
|
||||
import("../../routes/shipping/service-zone-create"),
|
||||
},
|
||||
{
|
||||
path: "service-zone/:zone_id",
|
||||
@@ -752,15 +724,13 @@ export const RouteMap: RouteObject[] = [
|
||||
{
|
||||
path: "edit",
|
||||
lazy: () =>
|
||||
import(
|
||||
"../../v2-routes/shipping/service-zone-edit"
|
||||
),
|
||||
import("../../routes/shipping/service-zone-edit"),
|
||||
},
|
||||
{
|
||||
path: "edit-areas",
|
||||
lazy: () =>
|
||||
import(
|
||||
"../../v2-routes/shipping/service-zone-areas-edit"
|
||||
"../../routes/shipping/service-zone-areas-edit"
|
||||
),
|
||||
},
|
||||
{
|
||||
@@ -770,7 +740,7 @@ export const RouteMap: RouteObject[] = [
|
||||
path: "create",
|
||||
lazy: () =>
|
||||
import(
|
||||
"../../v2-routes/shipping/shipping-options-create"
|
||||
"../../routes/shipping/shipping-options-create"
|
||||
),
|
||||
},
|
||||
{
|
||||
@@ -780,14 +750,14 @@ export const RouteMap: RouteObject[] = [
|
||||
path: "edit",
|
||||
lazy: () =>
|
||||
import(
|
||||
"../../v2-routes/shipping/shipping-option-edit"
|
||||
"../../routes/shipping/shipping-option-edit"
|
||||
),
|
||||
},
|
||||
{
|
||||
path: "edit-pricing",
|
||||
lazy: () =>
|
||||
import(
|
||||
"../../v2-routes/shipping/shipping-options-edit-pricing"
|
||||
"../../routes/shipping/shipping-options-edit-pricing"
|
||||
),
|
||||
},
|
||||
],
|
||||
@@ -813,14 +783,14 @@ export const RouteMap: RouteObject[] = [
|
||||
path: "",
|
||||
lazy: () =>
|
||||
import(
|
||||
"../../v2-routes/workflow-executions/workflow-execution-list"
|
||||
"../../routes/workflow-executions/workflow-execution-list"
|
||||
),
|
||||
},
|
||||
{
|
||||
path: ":id",
|
||||
lazy: () =>
|
||||
import(
|
||||
"../../v2-routes/workflow-executions/workflow-execution-detail"
|
||||
"../../routes/workflow-executions/workflow-execution-detail"
|
||||
),
|
||||
handle: {
|
||||
crumb: (data: { workflow: any }) => {
|
||||
@@ -845,14 +815,14 @@ export const RouteMap: RouteObject[] = [
|
||||
path: "",
|
||||
lazy: () =>
|
||||
import(
|
||||
"../../v2-routes/shipping-profiles/shipping-profiles-list"
|
||||
"../../routes/shipping-profiles/shipping-profiles-list"
|
||||
),
|
||||
children: [
|
||||
{
|
||||
path: "create",
|
||||
lazy: () =>
|
||||
import(
|
||||
"../../v2-routes/shipping-profiles/shipping-profile-create"
|
||||
"../../routes/shipping-profiles/shipping-profile-create"
|
||||
),
|
||||
},
|
||||
],
|
||||
@@ -861,7 +831,7 @@ export const RouteMap: RouteObject[] = [
|
||||
path: ":id",
|
||||
lazy: () =>
|
||||
import(
|
||||
"../../v2-routes/shipping-profiles/shipping-profile-detail"
|
||||
"../../routes/shipping-profiles/shipping-profile-detail"
|
||||
),
|
||||
},
|
||||
],
|
||||
@@ -881,14 +851,14 @@ export const RouteMap: RouteObject[] = [
|
||||
path: "",
|
||||
lazy: () =>
|
||||
import(
|
||||
"../../v2-routes/api-key-management/api-key-management-list"
|
||||
"../../routes/api-key-management/api-key-management-list"
|
||||
),
|
||||
children: [
|
||||
{
|
||||
path: "create",
|
||||
lazy: () =>
|
||||
import(
|
||||
"../../v2-routes/api-key-management/api-key-management-create"
|
||||
"../../routes/api-key-management/api-key-management-create"
|
||||
),
|
||||
},
|
||||
],
|
||||
@@ -899,7 +869,7 @@ export const RouteMap: RouteObject[] = [
|
||||
path: ":id",
|
||||
lazy: () =>
|
||||
import(
|
||||
"../../v2-routes/api-key-management/api-key-management-detail"
|
||||
"../../routes/api-key-management/api-key-management-detail"
|
||||
),
|
||||
handle: {
|
||||
crumb: (data: AdminApiKeyResponse) => {
|
||||
@@ -911,14 +881,14 @@ export const RouteMap: RouteObject[] = [
|
||||
path: "edit",
|
||||
lazy: () =>
|
||||
import(
|
||||
"../../v2-routes/api-key-management/api-key-management-edit"
|
||||
"../../routes/api-key-management/api-key-management-edit"
|
||||
),
|
||||
},
|
||||
{
|
||||
path: "sales-channels",
|
||||
lazy: () =>
|
||||
import(
|
||||
"../../v2-routes/api-key-management/api-key-management-sales-channels"
|
||||
"../../routes/api-key-management/api-key-management-sales-channels"
|
||||
),
|
||||
},
|
||||
],
|
||||
@@ -940,14 +910,14 @@ export const RouteMap: RouteObject[] = [
|
||||
path: "",
|
||||
lazy: () =>
|
||||
import(
|
||||
"../../v2-routes/api-key-management/api-key-management-list"
|
||||
"../../routes/api-key-management/api-key-management-list"
|
||||
),
|
||||
children: [
|
||||
{
|
||||
path: "create",
|
||||
lazy: () =>
|
||||
import(
|
||||
"../../v2-routes/api-key-management/api-key-management-create"
|
||||
"../../routes/api-key-management/api-key-management-create"
|
||||
),
|
||||
},
|
||||
],
|
||||
@@ -958,7 +928,7 @@ export const RouteMap: RouteObject[] = [
|
||||
path: ":id",
|
||||
lazy: () =>
|
||||
import(
|
||||
"../../v2-routes/api-key-management/api-key-management-detail"
|
||||
"../../routes/api-key-management/api-key-management-detail"
|
||||
),
|
||||
handle: {
|
||||
crumb: (data: AdminApiKeyResponse) => {
|
||||
@@ -970,7 +940,7 @@ export const RouteMap: RouteObject[] = [
|
||||
path: "edit",
|
||||
lazy: () =>
|
||||
import(
|
||||
"../../v2-routes/api-key-management/api-key-management-edit"
|
||||
"../../routes/api-key-management/api-key-management-edit"
|
||||
),
|
||||
},
|
||||
],
|
||||
@@ -986,19 +956,18 @@ export const RouteMap: RouteObject[] = [
|
||||
children: [
|
||||
{
|
||||
path: "",
|
||||
lazy: () => import("../../v2-routes/taxes/tax-region-list"),
|
||||
lazy: () => import("../../routes/taxes/tax-region-list"),
|
||||
children: [
|
||||
{
|
||||
path: "create",
|
||||
lazy: () =>
|
||||
import("../../v2-routes/taxes/tax-region-create"),
|
||||
lazy: () => import("../../routes/taxes/tax-region-create"),
|
||||
children: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: ":id",
|
||||
lazy: () => import("../../v2-routes/taxes/tax-region-detail"),
|
||||
lazy: () => import("../../routes/taxes/tax-region-detail"),
|
||||
handle: {
|
||||
crumb: (data: AdminTaxRegionResponse) => {
|
||||
return data.tax_region.country_code
|
||||
@@ -1008,12 +977,12 @@ export const RouteMap: RouteObject[] = [
|
||||
{
|
||||
path: "create-default",
|
||||
lazy: () =>
|
||||
import("../../v2-routes/taxes/tax-province-create"),
|
||||
import("../../routes/taxes/tax-province-create"),
|
||||
children: [],
|
||||
},
|
||||
{
|
||||
path: "create-override",
|
||||
lazy: () => import("../../v2-routes/taxes/tax-rate-create"),
|
||||
lazy: () => import("../../routes/taxes/tax-rate-create"),
|
||||
children: [],
|
||||
},
|
||||
{
|
||||
@@ -1025,7 +994,7 @@ export const RouteMap: RouteObject[] = [
|
||||
{
|
||||
path: "edit",
|
||||
lazy: () =>
|
||||
import("../../v2-routes/taxes/tax-rate-edit"),
|
||||
import("../../routes/taxes/tax-rate-edit"),
|
||||
handle: {
|
||||
crumb: (data: AdminTaxRateResponse) => {
|
||||
return data.tax_rate.code
|
||||
|
||||
@@ -3,7 +3,7 @@ import { LoaderFunctionArgs } from "react-router-dom"
|
||||
import { AdminApiKeyResponse } from "@medusajs/types"
|
||||
import { apiKeysQueryKeys } from "../../../hooks/api/api-keys"
|
||||
import { client } from "../../../lib/client"
|
||||
import { queryClient } from "../../../lib/medusa"
|
||||
import { queryClient } from "../../../lib/query-client"
|
||||
|
||||
const apiKeyDetailQuery = (id: string) => ({
|
||||
queryKey: apiKeysQueryKeys.detail(id),
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Response } from "@medusajs/medusa-js"
|
||||
import { AdminCampaignResponse } from "@medusajs/types"
|
||||
import { LoaderFunctionArgs } from "react-router-dom"
|
||||
|
||||
import { campaignsQueryKeys } from "../../../hooks/api/campaigns"
|
||||
import { client } from "../../../lib/client"
|
||||
import { queryClient } from "../../../lib/medusa"
|
||||
import { queryClient } from "../../../lib/query-client"
|
||||
|
||||
const campaignDetailQuery = (id: string) => ({
|
||||
queryKey: campaignsQueryKeys.detail(id),
|
||||
@@ -18,7 +18,7 @@ export const campaignLoader = async ({ params }: LoaderFunctionArgs) => {
|
||||
const query = campaignDetailQuery(id!)
|
||||
|
||||
return (
|
||||
queryClient.getQueryData<Response<AdminCampaignResponse>>(query.queryKey) ??
|
||||
queryClient.getQueryData<AdminCampaignResponse>(query.queryKey) ??
|
||||
(await queryClient.fetchQuery(query))
|
||||
)
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user