Skip to content

Commit

Permalink
Merge branch 'develop' into feat/promotion-campaigns
Browse files Browse the repository at this point in the history
  • Loading branch information
riqwan committed May 23, 2024
2 parents d1b1fd8 + 37ae87f commit 314517a
Show file tree
Hide file tree
Showing 935 changed files with 1,060 additions and 17,725 deletions.
1 change: 0 additions & 1 deletion packages/admin-next/dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/admin-next/dashboard/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -69,28 +69,26 @@ 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,
has_account: true, // Only show customers with confirmed accounts
})
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
4 changes: 2 additions & 2 deletions packages/admin-next/dashboard/src/hooks/api/api-keys.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { AdminApiKeyListResponse, AdminApiKeyResponse } from "@medusajs/types"
import {
MutationOptions,
QueryKey,
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/admin-next/dashboard/src/hooks/api/campaigns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
16 changes: 8 additions & 8 deletions packages/admin-next/dashboard/src/hooks/api/customer-groups.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import {
AdminCustomerGroupListResponse,
AdminCustomerGroupResponse,
} from "@medusajs/types"
import {
QueryKey,
UseMutationOptions,
UseQueryOptions,
useMutation,
useQuery,
} from "@tanstack/react-query"
import { z } from "zod"
import { client } from "../../lib/client"
import { queryClient } from "../../lib/query-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 { 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
Expand Down
2 changes: 1 addition & 1 deletion packages/admin-next/dashboard/src/hooks/api/customers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 12 additions & 12 deletions packages/admin-next/dashboard/src/hooks/api/inventory.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
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,
UseQueryOptions,
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
Expand Down
14 changes: 7 additions & 7 deletions packages/admin-next/dashboard/src/hooks/api/invites.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import {
AdminInviteResponse,
DeleteResponse,
HttpTypes,
PaginatedResponse,
} from "@medusajs/types"
import {
QueryKey,
UseMutationOptions,
Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions packages/admin-next/dashboard/src/hooks/api/orders.ts
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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,
})
Expand All @@ -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,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 7 additions & 3 deletions packages/admin-next/dashboard/src/hooks/api/products.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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"
>
) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/admin-next/dashboard/src/hooks/api/promotions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,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,
Expand Down
6 changes: 3 additions & 3 deletions packages/admin-next/dashboard/src/hooks/api/regions.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { DeleteResponse, HttpTypes, PaginatedResponse } from "@medusajs/types"
import {
QueryKey,
UseMutationOptions,
Expand All @@ -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,
Expand Down
10 changes: 5 additions & 5 deletions packages/admin-next/dashboard/src/hooks/api/reservations.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import {
CreateReservationReq,
UpdateReservationReq,
} from "../../types/api-payloads"
import {
QueryKey,
UseMutationOptions,
UseQueryOptions,
useMutation,
useQuery,
} from "@tanstack/react-query"
import {
CreateReservationReq,
UpdateReservationReq,
} from "../../types/api-payloads"
import {
ReservationItemDeleteRes,
ReservationItemListRes,
Expand All @@ -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
Expand Down
Loading

0 comments on commit 314517a

Please sign in to comment.