2e384842d5
* add: medusa admin hooks + tests * fix: remove unneeded props * fix: deps * fix: deps * fix: deps * fix: failing tests * fix: failing tests * fix: query key * add: yarn workspaces * fix: linting medusa-react * fix: add prepare script * fix: buildOptions * fix: useAdminShippingOptions query * fix: use qs instead for query params (#1019) * fix: formatting * debug: ci pipeline * debug: log node_modules structure * debug: use lerna bootstrap * debug: update node version * debug: print pkgs in workspace * debug: print pkgs in workspace * debug: print pkgs in workspace * debug: print pkgs in workspace * debug: add explicit build step * fix: jsdoc * debug: run build step * debug: fix build errors * debug: add build step to integration tests * fix: failing test * cleanup Co-authored-by: Sebastian Rindom <seb@medusajs.com> Co-authored-by: Sebastian Rindom <skrindom@gmail.com>
45 lines
1.2 KiB
TypeScript
45 lines
1.2 KiB
TypeScript
import { AdminPaymentProvidersList, AdminStoresRes } from "@medusajs/medusa"
|
|
import { Response } from "@medusajs/medusa-js"
|
|
import { useQuery } from "react-query"
|
|
import { useMedusa } from "../../../contexts"
|
|
import { UseQueryOptionsWrapper } from "../../../types"
|
|
import { queryKeysFactory } from "../../utils/index"
|
|
|
|
const ADMIN_STORE_QUERY_KEY = `admin_store` as const
|
|
|
|
export const adminStoreKeys = queryKeysFactory(ADMIN_STORE_QUERY_KEY)
|
|
|
|
type StoreQueryKeys = typeof adminStoreKeys
|
|
|
|
export const useAdminStorePaymentProviders = (
|
|
options?: UseQueryOptionsWrapper<
|
|
Response<AdminPaymentProvidersList>,
|
|
Error,
|
|
ReturnType<StoreQueryKeys["detail"]>
|
|
>
|
|
) => {
|
|
const { client } = useMedusa()
|
|
const { data, ...rest } = useQuery(
|
|
adminStoreKeys.detail("payment_providers"),
|
|
() => client.admin.store.listPaymentProviders(),
|
|
options
|
|
)
|
|
return { ...data, ...rest } as const
|
|
}
|
|
|
|
export const useAdminStore = (
|
|
options?: UseQueryOptionsWrapper<
|
|
Response<AdminStoresRes>,
|
|
Error,
|
|
ReturnType<StoreQueryKeys["details"]>
|
|
>
|
|
) => {
|
|
const { client } = useMedusa()
|
|
const { data, ...rest } = useQuery(
|
|
adminStoreKeys.details(),
|
|
() => client.admin.store.retrieve(),
|
|
options
|
|
)
|
|
return { ...data, ...rest } as const
|
|
}
|