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>
47 lines
1.4 KiB
TypeScript
47 lines
1.4 KiB
TypeScript
import { adminStoreKeys } from "./queries"
|
|
import { AdminPostStoreReq, AdminStoresRes } from "@medusajs/medusa"
|
|
import { Response } from "@medusajs/medusa-js"
|
|
import { useMutation, UseMutationOptions, useQueryClient } from "react-query"
|
|
import { useMedusa } from "../../../contexts/medusa"
|
|
import { buildOptions } from "../../utils/buildOptions"
|
|
|
|
export const useAdminUpdateStore = (
|
|
options?: UseMutationOptions<
|
|
Response<AdminStoresRes>,
|
|
Error,
|
|
AdminPostStoreReq
|
|
>
|
|
) => {
|
|
const { client } = useMedusa()
|
|
const queryClient = useQueryClient()
|
|
|
|
return useMutation(
|
|
(payload: AdminPostStoreReq) => client.admin.store.update(payload),
|
|
buildOptions(queryClient, adminStoreKeys.details(), options)
|
|
)
|
|
}
|
|
|
|
export const useAdminAddStoreCurrency = (
|
|
options?: UseMutationOptions<Response<AdminStoresRes>, Error, string>
|
|
) => {
|
|
const { client } = useMedusa()
|
|
const queryClient = useQueryClient()
|
|
|
|
return useMutation(
|
|
(currency_code: string) => client.admin.store.deleteCurrency(currency_code),
|
|
buildOptions(queryClient, adminStoreKeys.details(), options)
|
|
)
|
|
}
|
|
|
|
export const useAdminDeleteStoreCurrency = (
|
|
options?: UseMutationOptions<Response<AdminStoresRes>, Error, string>
|
|
) => {
|
|
const { client } = useMedusa()
|
|
const queryClient = useQueryClient()
|
|
|
|
return useMutation(
|
|
(currency_code: string) => client.admin.store.deleteCurrency(currency_code),
|
|
buildOptions(queryClient, adminStoreKeys.details(), options)
|
|
)
|
|
}
|