Skip to content

Commit

Permalink
fix(dashboard,js-sdk): remove methods / hooks to non existing exchang…
Browse files Browse the repository at this point in the history
…e routes (#9697)

Remove the following exchange methods (and hooks from dashboard) which point to routes that don't exist:

- `delete`
- `addItems`
- `updateItem`
- `removeItem`
  • Loading branch information
shahednasser authored Oct 21, 2024
1 parent 16e4468 commit a0668ad
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 170 deletions.
101 changes: 0 additions & 101 deletions packages/admin/dashboard/src/hooks/api/exchanges.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,107 +118,6 @@ export const useCancelExchange = (
})
}

export const useDeleteExchange = (
id: string,
orderId: string,
options?: UseMutationOptions<
HttpTypes.AdminExchangeDeleteResponse,
FetchError
>
) => {
return useMutation({
mutationFn: () => sdk.admin.exchange.delete(id),
onSuccess: (data: any, variables: any, context: any) => {
queryClient.invalidateQueries({
queryKey: ordersQueryKeys.details(),
})

queryClient.invalidateQueries({
queryKey: ordersQueryKeys.preview(orderId),
})

queryClient.invalidateQueries({
queryKey: exchangesQueryKeys.details(),
})
queryClient.invalidateQueries({
queryKey: exchangesQueryKeys.lists(),
})
options?.onSuccess?.(data, variables, context)
},
...options,
})
}

export const useAddExchangeItems = (
id: string,
orderId: string,
options?: UseMutationOptions<
HttpTypes.AdminExchangeResponse,
FetchError,
HttpTypes.AdminAddExchangeItems
>
) => {
return useMutation({
mutationFn: (payload: HttpTypes.AdminAddExchangeItems) =>
sdk.admin.exchange.addItems(id, payload),
onSuccess: (data: any, variables: any, context: any) => {
queryClient.invalidateQueries({
queryKey: ordersQueryKeys.preview(orderId),
})
options?.onSuccess?.(data, variables, context)
},
...options,
})
}

export const useUpdateExchangeItems = (
id: string,
orderId: string,
options?: UseMutationOptions<
HttpTypes.AdminExchangeResponse,
FetchError,
HttpTypes.AdminUpdateExchangeItem & { actionId: string }
>
) => {
return useMutation({
mutationFn: ({
actionId,
...payload
}: HttpTypes.AdminUpdateExchangeItem & { actionId: string }) => {
return sdk.admin.exchange.updateItem(id, actionId, payload)
},
onSuccess: (data: any, variables: any, context: any) => {
queryClient.invalidateQueries({
queryKey: ordersQueryKeys.preview(orderId),
})
options?.onSuccess?.(data, variables, context)
},
...options,
})
}

export const useRemoveExchangeItem = (
id: string,
orderId: string,
options?: UseMutationOptions<
HttpTypes.AdminReturnResponse,
FetchError,
string
>
) => {
return useMutation({
mutationFn: (actionId: string) =>
sdk.admin.return.removeReturnItem(id, actionId),
onSuccess: (data: any, variables: any, context: any) => {
queryClient.invalidateQueries({
queryKey: ordersQueryKeys.preview(orderId),
})
options?.onSuccess?.(data, variables, context)
},
...options,
})
}

export const useAddExchangeInboundItems = (
id: string,
orderId: string,
Expand Down
66 changes: 0 additions & 66 deletions packages/core/js-sdk/src/admin/exchange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,72 +73,6 @@ export class Exchange {
)
}

async delete(
id: string,
query?: HttpTypes.SelectParams,
headers?: ClientHeaders
) {
return await this.client.fetch<HttpTypes.AdminExchangeDeleteResponse>(
`/admin/exchanges/${id}`,
{
method: "DELETE",
headers,
query,
}
)
}

async addItems(
id: string,
body: HttpTypes.AdminAddExchangeItems,
query?: HttpTypes.SelectParams,
headers?: ClientHeaders
) {
return await this.client.fetch<HttpTypes.AdminExchangeResponse>(
`/admin/exchanges/${id}/exchange-items`,
{
method: "POST",
headers,
body,
query,
}
)
}

async updateItem(
id: string,
actionId: string,
body: HttpTypes.AdminUpdateExchangeItem,
query?: HttpTypes.SelectParams,
headers?: ClientHeaders
) {
return await this.client.fetch<HttpTypes.AdminExchangeResponse>(
`/admin/exchanges/${id}/exchange-items/${actionId}`,
{
method: "POST",
headers,
body,
query,
}
)
}

async removeItem(
id: string,
actionId: string,
query?: HttpTypes.SelectParams,
headers?: ClientHeaders
) {
return await this.client.fetch<HttpTypes.AdminReturnResponse>(
`/admin/exchanges/${id}/exchange-items/${actionId}`,
{
method: "DELETE",
headers,
query,
}
)
}

async addInboundItems(
id: string,
body: HttpTypes.AdminAddExchangeInboundItems,
Expand Down
3 changes: 0 additions & 3 deletions packages/core/types/src/http/exchange/admin/payloads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ export interface AdminCreateExchange {
metadata?: Record<string, unknown> | null
}

export interface AdminAddExchangeItems extends AdminExchangeAddItems {}
export interface AdminUpdateExchangeItem extends AdminExchangeUpdateItem {}

export interface AdminAddExchangeInboundItems extends AdminExchangeAddItems {}
export interface AdminUpdateExchangeInboundItem
extends AdminExchangeUpdateItem {}
Expand Down

0 comments on commit a0668ad

Please sign in to comment.