-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
125 additions
and
14 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
packages/admin-next/dashboard/src/hooks/api/return-reasons.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { HttpTypes } from "@medusajs/types" | ||
import { QueryKey, UseQueryOptions, useQuery } from "@tanstack/react-query" | ||
|
||
import { sdk } from "../../lib/client" | ||
import { queryKeysFactory } from "../../lib/query-key-factory" | ||
|
||
const RETURN_REASONS_QUERY_KEY = "return_reasons" as const | ||
export const returnReasonQueryKeys = queryKeysFactory(RETURN_REASONS_QUERY_KEY) | ||
|
||
export const useReturnReasons = ( | ||
query?: HttpTypes.AdminReturnReasonListParams, | ||
options?: Omit< | ||
UseQueryOptions< | ||
HttpTypes.AdminReturnReasonsResponse, | ||
Error, | ||
HttpTypes.AdminReturnReasonsResponse, | ||
QueryKey | ||
>, | ||
"queryFn" | "queryKey" | ||
> | ||
) => { | ||
const { data, ...rest } = useQuery({ | ||
queryFn: () => sdk.admin.returnReason.list(query), | ||
queryKey: returnReasonQueryKeys.list(query), | ||
...options, | ||
}) | ||
|
||
return { ...data, ...rest } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { HttpTypes } from "@medusajs/types" | ||
|
||
import { Client } from "../client" | ||
import { ClientHeaders } from "../types" | ||
|
||
export class ReturnReason { | ||
private client: Client | ||
constructor(client: Client) { | ||
this.client = client | ||
} | ||
|
||
async list( | ||
queryParams?: HttpTypes.AdminReturnReasonListParams, | ||
headers?: ClientHeaders | ||
) { | ||
return await this.client.fetch<HttpTypes.AdminReturnReasonsResponse>( | ||
"/admin/return-reasons", | ||
{ | ||
headers, | ||
query: queryParams, | ||
} | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { BaseReturnReason, BaseReturnReasonFilters } from "./common" | ||
import { FindParams } from "../common" | ||
import { OperatorMap } from "../../dal" | ||
|
||
export interface AdminReturnReason extends BaseReturnReason {} | ||
export interface AdminReturnReasonFilters extends BaseReturnReasonFilters {} | ||
|
||
export interface AdminCreateReturnReason { | ||
// TODO: | ||
value: string | ||
label: string | ||
description?: string | ||
} | ||
|
||
export interface AdminReturnReasonsResponse { | ||
return_reasons: AdminReturnReason[] | ||
} | ||
|
||
export interface AdminReturnReasonListParams extends FindParams { | ||
id?: string[] | string | OperatorMap<string | string[]> | ||
value?: string | OperatorMap<string> | ||
label?: string | OperatorMap<string> | ||
description?: string | OperatorMap<string> | ||
parent_return_reason_id?: string | OperatorMap<string | string[]> | ||
created_at?: OperatorMap<string> | ||
updated_at?: OperatorMap<string> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { BaseFilterable, OperatorMap } from "../../dal" | ||
|
||
export interface BaseReturnReason { | ||
id: string | ||
value: string | ||
label: string | ||
description?: string | ||
metadata?: Record<string, any> | null | ||
created_at?: string | ||
updated_at?: string | ||
} | ||
|
||
export interface BaseReturnReasonFilters | ||
extends BaseFilterable<BaseReturnReason> { | ||
q?: string | ||
id?: string[] | string | OperatorMap<string | string[]> | ||
value?: string | OperatorMap<string> | ||
label?: string | OperatorMap<string> | ||
description?: string | OperatorMap<string> | ||
parent_return_reason_id?: string | OperatorMap<string | string[]> | ||
created_at?: OperatorMap<string> | ||
updated_at?: OperatorMap<string> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./admin" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters