feat(core-flows,dashboard,medusa): ability to add and remove items to claim inbound (#8480)
* wip: setup UI * wip: rendering modal, adding claim items, create checks * fix: make form work after merge * fix: continuation of claim edit * chore: ability to add and remove items to claim inbound * chore: minor fixes --------- Co-authored-by: fPolic <mainacc.polic@gmail.com>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
import {
|
||||
QueryKey,
|
||||
useMutation,
|
||||
@@ -5,21 +6,25 @@ import {
|
||||
useQuery,
|
||||
UseQueryOptions,
|
||||
} from "@tanstack/react-query"
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
|
||||
import { sdk } from "../../lib/client"
|
||||
import { queryClient } from "../../lib/query-client"
|
||||
import { ordersQueryKeys } from "./orders"
|
||||
import { queryKeysFactory } from "../../lib/query-key-factory"
|
||||
import { ordersQueryKeys } from "./orders"
|
||||
|
||||
const CLAIMS_QUERY_KEY = "claims" as const
|
||||
export const claimsQueryKeys = queryKeysFactory(CLAIMS_QUERY_KEY)
|
||||
|
||||
export const useClaim = (
|
||||
id: string,
|
||||
query?: Record<string, any>,
|
||||
query?: HttpTypes.AdminClaimListParams,
|
||||
options?: Omit<
|
||||
UseQueryOptions<any, Error, any, QueryKey>,
|
||||
UseQueryOptions<
|
||||
HttpTypes.AdminClaimResponse,
|
||||
Error,
|
||||
HttpTypes.AdminClaimResponse,
|
||||
QueryKey
|
||||
>,
|
||||
"queryFn" | "queryKey"
|
||||
>
|
||||
) => {
|
||||
@@ -56,10 +61,7 @@ export const useClaims = (
|
||||
export const useCreateClaim = (
|
||||
orderId: string,
|
||||
options?: UseMutationOptions<
|
||||
{
|
||||
claim: HttpTypes.AdminClaimResponse
|
||||
order: HttpTypes.AdminOrderResponse
|
||||
},
|
||||
HttpTypes.AdminClaimResponse,
|
||||
Error,
|
||||
HttpTypes.AdminCreateClaim
|
||||
>
|
||||
@@ -278,6 +280,10 @@ export const useRemoveClaimInboundItem = (
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ordersQueryKeys.preview(orderId),
|
||||
})
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ordersQueryKeys.all,
|
||||
})
|
||||
|
||||
options?.onSuccess?.(data, variables, context)
|
||||
},
|
||||
...options,
|
||||
|
||||
Reference in New Issue
Block a user